Compilation failing in Visual Studio with template template parameter using non-type parameter pack

Viewed 142

In Visual Studio I get this compiler error with the below code which I think should compile fine (gcc 11.2 and clang 14.0 compile it). The non-type parameter pack (auto...) means I should be able to pass in a template with any number of non-type template parameters, but the compilation only succeeds when passing in a template that uses a single non-type template parameter.

Is there something I'm missing that will make this work in Visual Studio?

I'm using "/std:c++latest" on Visual Studio 2019, version 16.11.12

error C3201: the template parameter list for class template 'testValues::twoParams' does not match the template parameter list for template parameter 'X'

  namespace testValues {
    template<template<auto...> class X>
    struct templatetemplateparam {};

    template<int i>
    struct oneParam {};
    using oneParam_t = templatetemplateparam<oneParam>;

    template<int i, int j>
    struct twoParams {};
    using twoParams_t = templatetemplateparam<twoParams>;
  }

The equivalent code with a specific non-type parameter or a type parameter pack does compile, if that's relevant:

  namespace testIntValues {
    template<template<int...> class X>
    struct templatetemplateparam {};

    template<int i>
    struct oneParam {};
    using oneParam_t = templatetemplateparam<oneParam>;

    template<int i, int j>
    struct twoParams {};
    using twoParams_t = templatetemplateparam<twoParams>;
  }

  namespace testTypes {
    template<template<typename...> class X>
    struct templatetemplateparam {};

    template<typename>
    struct oneParam {};
    using oneParam_t = templatetemplateparam<oneParam>;

    template<typename, typename>
    struct twoParams {};
    using twoParams_t = templatetemplateparam<twoParams>;
  }
1 Answers
Related