0

(First, apologies if my use of terms is not correct/standard, I hope it is sufficient to get the gist... pointers welcome to fix title/wording!)

Overview of goal

The Class will inherit template-name specialised for every type in the list.

Implementation

The non-valid C++ code is essentially as follows (I make this valid in the next snippet under GCC)

/// NOTE: The example is not complete... just to abbreviate the Godbolt example
template<typename Type>
struct TemplateName 
{};

template<typename TemplateName, typename... Types>
class HandleAllTypeImpl<TemplateName, std::tuple<Types...> >
    : public TemplateName<Datas>...
{};

To make this valid the TemplateName must be a full type so I made a dummy container type and then can use TemplateName::Impl to access and instantiate the templated member

/// NOTE: The example is not complete... just to abbreviate the Godbolt example

struct TemplateName 
{ 
    template<typename Type>
    struct Impl 
    {};
}

template<typename TemplateName, typename... Types>
class HandleAllTypeImpl<TemplateName, std::tuple<Types...> >
    : public TemplateName::Impl<Datas>...
{};

Full example - works under GCC, fails under MSVC

https://godbolt.org/z/898hE8MhY

MSVC error reported

The error is reported on the use of TemplateName::Impl<Datas>as

error C2143: syntax error: missing ',' before '<'

Crog
  • 1,112
  • 8
  • 16
  • What is `public TemplateName::Impl...` intended to be, a pack expansion or a fold expression? Because [MSVC if you use the right flags](https://godbolt.org/z/aYz7TYMoq) sees it as just invalid (reminder MSVC is not flag compatible with GCC) – Mgetz Nov 04 '21 at 13:11
  • @Mgetz Thanks, I see `/permissive-` gives some extras info on the issue but doens't help solve it yet. The 'aim' is this should expand to the following, if this is cold a fold expression or pack expansion I am not sure on the terminology yet: `public TemplateName::Impl, public TemplateName::Impl` where the list is a `std::tuple` – Crog Nov 04 '21 at 13:17
  • 1
    Looks like you're missing some keywords https://godbolt.org/z/83dKnqnGG, also it was the `/std:c++17` that gave the extras because that's now MSVC sets its standards `/permissive-` was to ensure it was using two phase correctly – Mgetz Nov 04 '21 at 13:18
  • @Mgetz Thanks, I hadn't noticed that it didn indeed have the fix in the log, I havn't used the `template` after as `::` before. If you post as solution I can accept. Bonus would be if it is possible to remove the need for the `DummyTypeToPassTemplate` to contain the template type being used. Maybe a separate issue – Crog Nov 04 '21 at 13:22
  • Trying to find the dupe, I'm almost sure this is one. – Mgetz Nov 04 '21 at 13:24
  • Loks like same solution but in my case the syntax was valid for GCC but not for MSVC – Crog Nov 04 '21 at 13:27
  • It's highly plausible that's a GCC extension. But I can't confirm. – Mgetz Nov 04 '21 at 13:28
  • 1
    Are you looking for template template parameter? `template – Jarod42 Nov 04 '21 at 13:29
  • Missing some template for dependent name: `TemplateName::template Impl...` – Jarod42 Nov 04 '21 at 13:32

0 Answers0