CRTP: How to infer type of member to be used as return type?
问题 I would like to make the return type of a CRTP base method depend on the type of a member in the derived, as for example in: template <typename C> struct sum_a_b { ??? sum() { return static_cast<C*>(this)->a + static_cast<C*>(this)->b; } } template <typename T> struct a_b : sum_a_b<a_b<T>> { T a,b; }; What should I put in place of ??? I tried different ways to declare the return type : template <typename T> struct base { int get_ok() { return static_cast<T*>(this)->value; } auto get_invalid()