I have a helper struct that is specialized for certain types, it contains a map that is essentially a tuple with some helper functions specifically a GetType using:
template <class T, class ... Fs>
struct Map
{
template<size_t I>
using GetType = Get<I, Fs...>::Result::Type;
};
later I use this in a templated function:
template <class T>
void foo()
{
using FType = Helper<T>::Map::GetType<0>; // gives error;
}
the compiler gives the following error: "syntax error: '<' was unexpected here; expected ';' however no such error is given when I use the same code in a cpp file with a defined T type, I assume I need to somehow specify that GetType<> returns a typename but I'm not sure how, I've tried "= typename Helper::Map::GetType<0>" and "= Helper::Map::typename GetType<0>" but neither work
some more code for a minimum producible example
template <class F, size_t O>
struct Field
{
using Type = F;
using Offset = std::integral_constant<size_t, O>;
};
template<size_t, typename ...>
struct Get;
template <size_t D, typename T, typename ... Ts>
struct Get<D, T, Ts...> : public Get<D - 1, Ts...>
{ };
template <typename T, typename ... Ts>
struct Get<0, T, Ts...>
{
using Result = T;
};
template<class T>
struct Helper;
struct A
{
int a, b;
}
template<>
Helper<A>
{
using Map = Map<A, Field<int, offsetof(A, a)>, Field<int, offsetof(A, b)>>;
};
note that "using FType = Helper::Map::GetType<0>" compiles however the generic template function "foo" does not