I have some class C
with const
and non-const
getters for some generic type Node
:
template <typename NodeType>
class CParent{};
class Node {};
class C : public CParent<Node> {
Node& getNode(Index i);
const Node& getNode(Index i) const;
};
Now I want to create an alias function that call getNode
for an object of class C
:
template <class CType>
NodeType& AliasGetNode(CType* cobject);
But how do I deduce NodeType
? i.e., if I call AliasGetNode<const C>(c)
and AliasGetNode<C>(c)
, NodeType
should be respectively const Node&
and Node&
.
How can I do this?
I tried the result_of
and decltype
approaches but have not been successful.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…