在下面的代码中,为什么第二个和第三个概念会产生编译错误?
#include <tuple>
template <class P>
concept IsPair1 = std::tuple_size<P>::value == 2;
template <class P>
concept IsPair2 = std::tuple_size_v<P> == 2;
template <class P>
concept IsPair3 = requires { typename std::tuple_size<P>; } && std::tuple_size_v<P> == 2;
constexpr bool intIsPair1 = IsPair1<int>; // OK, false
constexpr bool intIsPair2 = IsPair2<int>; // error: incomplete type 'std::tuple_size<int>' used in nested name specifier
constexpr bool intIsPair3 = IsPair3<int>; // error: incomplete type 'std::tuple_size<int>' used in nested name specifier
Run Code Online (Sandbox Code Playgroud)
/usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/tuple:1334:61: error: incomplete type 'std::tuple_size<int>' used …Run Code Online (Sandbox Code Playgroud)