- 225 名前:221 mailto:sage [2011/12/27(火) 11:13:38.25 ]
- ttp://stackoverflow.com/questions/6006614/c-static-polymorphism-crtp-and-using-typedefs-from-derived-classes
によるとこんな感じ。 メタにやるのは難しいのですかね。 template <typename T> struct trait; template <class Derived> struct Base { typedef typename trait<Derived>::type type; }; template <typename T> struct Sub: Base<Sub<T>> { typedef T type; }; template <typename T> struct trait<Sub<T>> { typedef T type; }; int main() { Sub<int> s; return 0; }
|

|