Function template return type deduction

后端 未结 5 728
南旧
南旧 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 02:54

    Let the compiler deduce the return type (as of C++14):

    template 
    decltype(auto) AliasGetNode(CType& cobject)
    {
        return cobject.getNode(0);
    }
    

提交回复
热议问题