SFINAE works differently in cases of type and non-type template parameters

后端 未结 5 476
遇见更好的自我
遇见更好的自我 2020-11-28 13:25

Why does this code work:

template<
    typename T, 
    std::enable_if_t::value, T>* = nullptr>
void Add(T) {}

templa         


        
5条回答
  •  情书的邮戳
    2020-11-28 14:03

    I think the problem is the fact that you can use a function even if a default template parameter does not compile by specifying a different value for it. Think of what would happen if you specified two template parameters in a call to add.

提交回复
热议问题