Function template return type deduction

后端 未结 5 730
南旧
南旧 2020-12-11 02:34

I have some class C with const and non-const getters for some generic type Node:

template 

        
5条回答
  •  不知归路
    2020-12-11 03:14

    Define a simple helper trait, which will add/remove const from a type based on whether another type is const:

    template 
    using copy_const = typename std::conditional<
      std::is_const::value,
      const Dst,
      typename std::remove_const::type
    >::type;
    

    And use it:

    template 
    copy_const& AliasGetNode(CType* cobject);
    

提交回复
热议问题