mardi 27 février 2018

Incorrect number of template arguments with decltype.

In the below program when compiling it complains that there should be 2 template arguments but there is only 1.

template<typename T, typename U = T, 
    typename = std::enable_if<std::is_convertible<std::decltype(int()), int>::value>::type>
void func(T t, U u){}

However the below code compiles,

template<typename T, typename U = T, 
    typename = std::enable_if<std::is_convertible<int, int>::value>::type>
void func(T t, U u){}

I am wondering what the difference between the two is and how I might make this code compile.

Aucun commentaire:

Enregistrer un commentaire