Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.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++ 什么是自动括号列表语法?_C++_C++17_Auto_Decomposition - Fatal编程技术网

C++ 什么是自动括号列表语法?

C++ 什么是自动括号列表语法?,c++,c++17,auto,decomposition,C++,C++17,Auto,Decomposition,对我的问题给出了一个现已删除的答案,其中使用了以下行: auto [x, y] = div_t{ 1, 0 }; 从答案中的代码来看,这就像是div\u t结构的tie。我希望有人能解释这里发生了什么。完整的功能代码如下所示: constexpr bool first_quot() { auto [x, y] = std::div_t{1, 0}; (void)y; return x; } 在大多数情况下,它被称为“分解声明”,并在第8.5节[dcl.decomp]中

对我的问题给出了一个现已删除的答案,其中使用了以下行:

auto [x, y] = div_t{ 1, 0 };
从答案中的代码来看,这就像是
div\u t
结构的
tie
。我希望有人能解释这里发生了什么。完整的功能代码如下所示:

constexpr bool first_quot() {
    auto [x, y] = std::div_t{1, 0};
    (void)y;
    return x;
}

在大多数情况下,它被称为“分解声明”,并在第8.5节[dcl.decomp]中定义。

这就是所谓的。是的,它的工作原理与tie类似(但它可以一次完成自动声明、定义和初始化)事实上,我的答案是错误的使用结构绑定。。。我的答案应该更像是
constexpr bool first][u quot(){return std::div_t{1,0}.quot;}
(因此甚至不需要c++17)来按照我的意图工作:)但由于它被删除了,我还没有编辑它:)@Someprogrammerdude,我能说服你找到那个信息并把它作为答案键入吗?当我查找时,我不认为这是一种潜在的语法。我当然希望有机会阅读并理解这里发生的事情。现在,当我知道规范中的实际术语时,我到处都能找到参考资料,包括……:)@正是乔纳桑米。不幸的是,我不认为可以对未命名的变量使用结构绑定(或者不管它现在叫什么)。。。