Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/143.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 为什么'std::is_constructible_v<;int[2],int,int>;==假的`_C++_Arrays_C++17 - Fatal编程技术网

C++ 为什么'std::is_constructible_v<;int[2],int,int>;==假的`

C++ 为什么'std::is_constructible_v<;int[2],int,int>;==假的`,c++,arrays,c++17,C++,Arrays,C++17,可复制示例: #include <type_traits> static_assert(std::is_constructible_v<int[2], int, int>, "fails against my expectations"); #包括 静态断言(std::is_constructible_v,“与我的期望不符”); 我用clang 5和gcc 7对此进行了测试。std::is_constructible的目的和定义是检查指定类型的对象是否可以按照以下方式

可复制示例:

#include <type_traits>
static_assert(std::is_constructible_v<int[2], int, int>, "fails against my expectations");
#包括
静态断言(std::is_constructible_v,“与我的期望不符”);

我用clang 5和gcc 7对此进行了测试。

std::is_constructible的目的和定义是检查指定类型的对象是否可以按照以下方式构造:

T obj(std::declval<Args>()...);
tobj(std::declval()…);

对于一个数组来说,上面的内容并不是很好的格式。数组没有任何构造函数,它是一个聚合,应该用聚合初始化来初始化。

std::is_constructible的目的和定义是检查指定类型的对象是否可以按照以下方式构造:

T obj(std::declval<Args>()...);
tobj(std::declval()…);
对于一个数组来说,上面的内容并不是很好的格式。数组没有任何构造函数,它是一个聚合,应该使用聚合初始化进行初始化。

来自:

如果T是一个对象或引用类型,并且变量定义为T obj(std::declval),那么聚合初始化在这里起作用,而不是构造。

来自:


如果T是一个对象或引用类型,变量定义为
T obj(std::declval),那么聚合初始化在这里起作用,而不是构造。

为什么您希望它为真?数组没有构造函数。From:“If
T
是一个对象或引用类型,变量定义为
T obj(std::declval()…);
格式正确,提供的成员常量值等于
true
。在所有其他情况下,值为
false
int-obj[2](int,int)
定义不明确。不要将构造与聚合初始化混淆。为什么希望它为true?数组没有构造函数。从:“如果
T
是对象或引用类型,并且变量定义
T obj(std::declval());
格式正确,则提供的成员常量值等于
true
。在所有其他情况下,值为
false
int obj[2](int,int)
定义不明确。不要将构造与聚合初始化混淆。