0

The following code is an error in GCC trunk and Clang trunk:

https://godbolt.org/z/YYzdeh

#include <variant>

template <template <typename...> typename Container,
          typename Type,
          typename ... More>
struct Contain
{
    using type = Container<Type, More...>;
};

template <template <typename...> typename Container,
          typename Type>
struct Contain<Container, Type>
{
    using type = Container<Type>;
};

template <template <typename...> typename Container,
          typename Type,
          typename ... More>
using Contain_t = typename Contain<Container, Type, More ...>::type;


template <typename ... A>
using C_ok = typename Contain< std::variant, A ... >::type;


template <typename ... A>
using C_bad = Contain_t< std::variant, A ... >;

Why does parameter pack A split correctly into Type and More ... in C_ok but not in C_bad?

Fixed: Template parameter Type in Contain_t was redundant.

template <template <typename...> typename Container,
          /* typename Type, */
          typename ... More>
using Contain_t = typename Contain<Container, /* Type, */ More ...>::type;

(Please ignore that it will not work when called with 0 parameters)

4

0 回答 0