c++ variadic templates and template template arguments: error: type/value mismatch at argument 1 in template parameter list

158 views Asked by At

I get error: type/value mismatch at argument 1 in template parameter list... when I compile the following code. The compiler is gcc version 8.2.0.

template<typename>
struct t1 {};

template<typename ...>
struct t2 {};

template<typename, typename ...>
struct t3 {};

template<template<typename> class>
struct tt1 {};

template<template<typename ...> class>
struct tt2{};

template<template<typename, typename ...> class>
struct tt3{};


tt1<t2> _1; // error
tt1<t3> _2; // error
tt2<t1> _3;
tt2<t3> _4;
tt3<t1> _5;
tt3<t2> _6; // error

Question: Why _3, _4, _5 are allowed and _1, _2, _6 are wrong?

1

There are 1 answers

0
Oliv On BEST ANSWER

These errors are errors in pre C++17. Before C++17, template template argument / parameter shall match exactly.

But since addition of P0522R0 to the standard, the rule are less strict, and this code compiles.

As of today, I thing only GCC implements it and you need to specify the standard:gcc -std=c++17 see here.