Original Post
Check out this code, which compiles fine: Now contrast to this code, which gives a "; missing before <" error in the struct Derived definition of get(): I can sort-of see why -- the compiler doesn't know that I intend to pass a "base" in as type B, so it doesn't know that get<>() is an explicit specialization. How can I work around this, other than adding Base as an explicit base class to the Derived template?
template<typename T> struct Trait {
typedef T Type;
};
struct Base {
template<typename T> typename Trait<T>::Type get() const;
};
template<typename T> struct Derived : public Base {
template<> typename Trait<T>::Type get<T>() const { return 0; }
};
template<typename T> struct Trait {
typedef T Type;
};
struct Base {
template<typename T> typename Trait<T>::Type get() const;
};
template<typename T, typename B> struct Derived : public B {
template<> typename Trait<T>::Type get<T>() const { return 0; }
};