mercredi 28 décembre 2016

Why does SFINAE not work with std::enable_if_t?

#include <vector>
#include <list>
#include <iostream>

template
<
    typename T,
    template<typename, typename = std::allocator<T>> class C,
    typename = std::enable_if_t
    <
    std::is_same<std::vector<T>, C<T>>::value
    >
>
void f(const C<T> coll)
{
    std::cout << "vector" << std::endl;
}

template
<
    typename T,
    template<typename, typename = std::allocator<T>> class C,
    typename = std::enable_if_t
    <
    std::is_same<std::list<T>, C<T>>::value
    >
>
void f(const C<T> coll)
{
    std::cout << "list" << std::endl;
}

int main()
{
        std::vector<int> c1{ 1, 2, 3 };
        std::list<int> c2{ 1, 2, 3 };       
        f(c1);
        f(c2);
}

Clang 3.8 complains:

error : template parameter redefines default argument: typename = std::enable_if_t

What's the wrong?

Aucun commentaire:

Enregistrer un commentaire