Reputation: 467
A class WithTTMember
has a template member type named TT
.
struct WithTTMember {
template<typename> using TT = void;
};
Another class ExpectTT
takes a template template parameter:
template< template<typename> typename TT >
struct ExpectTT {};
ExpectTT<WithTTMember::TT>
can be successfully instantiated.
A third class ExpectTWithTT
expects a template parameter with a template member type named TT
, and instantiates ExpectTT
using it:
template<typename T>
struct ExpectTWithTT {
using X = ExpectTT<typename T::TT>; // this doesn't compile
};
I expect ExpectTWithTT<WithTTMember>::X
to be the same type as ExpectTT<WithTTMember::TT>
. However the code above is fails to compile.
I tried injecting the faulty line with a combination of template
and typename
keywords following compiler messages and my instinct, but I couldn't get it to work.
How can I express what I want?
Any C++ version is fine.
Upvotes: 4
Views: 475
Reputation: 172924
You should use template
keyword to tell that T::TT
is a template.
template<typename T>
struct ExpectTWithTT {
using X = ExpectTT<T::template TT>;
// ^^^^^^^^
};
Upvotes: 5