0

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

  • 1
    `typename Helper::Map::template GetType<0>`, I think? – HolyBlackCat Aug 24 '23 at 10:43
  • 1
    _"essentially a tuple"_ - why not _exactly_ a `std::tuple`? – Ted Lyngmo Aug 24 '23 at 10:44
  • @TedLyngmo it has more functionality not included in the example given, also I wrote it before realizing a tuple would have covered most of what I was looking to do, regardless, I don't think using a Tuple would solve the issue at hand though I will give it a quick try. – Nathaniel Smith Aug 24 '23 at 10:56

1 Answers1

1

thanks to @HolyBlackCat for the answer the following works:

using FType = typename Helper<T>::Map::template GetType<0>;