编译这个:
template < class T, class Y, class ...Args >
struct isSame
{
static constexpr bool value = std::conditional<
sizeof...( Args ),
typename std::conditional<
std::is_same< T, Y >::value,
isSame< Y, Args... >, // Error!
std::false_type >::type,
std::is_same< T, Y > >::type::value;
};
int main()
{
qDebug() << isSame< double, int >::value;
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
给我这个编译器错误:
error: wrong number of template arguments (1, should be 2 or more)
Run Code Online (Sandbox Code Playgroud)
问题是isSame< double, int >有一个空的Args参数包,所以isSame< Y, Args... >实际上变得 …