jeudi 29 juin 2017

template template parameter causing compiler error in clang

I have a template that is compiling fine in MSVC (2017) but fails in clang (4.0):

#include <type_traits>

template <template <typename U, U, U> class, typename, typename>
struct meta_zip;

template <template <typename U, U, U> class OP, typename TA, TA... As, typename TB, TB... Bs>
struct meta_zip<OP, std::integer_sequence<TA, As...>, std::integer_sequence<TB, Bs...>>
{
    using common_type = typename std::common_type<TA, TB>::type;

    using type = std::integer_sequence<common_type, OP<common_type, As, Bs>::value...>;
};

template <template <typename U, U, U > class OP, typename A, typename B>
using meta_zip_t = typename meta_zip<OP, A, B>::type;

The compiler error in clang is:

template template argument has different template parameters than its corresponding template template parameter
struct meta_zip<OP, std::integer_sequence<TA, As...>, std::integer_sequence<TB, Bs...>>
                ^

I'm reasonably new to templates and don't know how to rework OP to make it work. I've tried OP<U, U, U> but that doesn't seem to help.

Aucun commentaire:

Enregistrer un commentaire