Wrap Loki::Typelist with C++11 variadic template
-
13-11-2019 - |
Вопрос
I am trying to avoid LOKI_TYPELIST_n macros, so I though I can write simple Loki::Typelist wrapper.
template <typename...Ts>
struct TYPELIST;
template <>
struct TYPELIST<>
{
typedef Loki::NullType Result;
};
template <typename HEAD, typename...Ts>
struct TYPELIST<HEAD,Ts...>
{
typedef Loki::Typelist<HEAD, TYPELIST<Ts...>::Result> Result;
};
Upon compilation I get the following error:
error: type/value mismatch at argument 2 in template parameter list for ‘template<class T, class U> struct Loki::Typelist’
error: expected a type, got ‘TYPELIST<Ts ...>::Result’
I though TYPELIST<Ts...>::Result
is a type. What is wrong with it?
GCC 4.6.2 here.
I want to use it like this:
typedef TYPELIST<
EventTank1,
EventTank2,
EventTank3
>::Result EVENTS_ALL__;
Thank you.
Решение
You forgot the typename
word in front of TYPELIST<Ts ...>::Result
. Just because you know it is a type does not mean that the compiler knows it too (if only!).
Не связан с StackOverflow