警告:分解声明仅适用于 -std=c++1z 或 -std=gnu++1
warning: decomposition declaration only available with -std=c++1z or -std=gnu++1
我收到了这个警告:
warning: decomposition declaration only available with -std=c++1z or -std=gnu++1
对于此代码:
#include<algorithm>
#include<vector>
int main(){
std::vector<int> vect{ 10, 20, 30 };
const auto [min, max] = std::minmax_element(vect.begin(), vect.end());
return 0;
}
在此上下文中,分解声明是什么意思?
what does it mean?
该警告意味着您使用了 C++17 标准(其工作名称为 C++1z)中引入的语法/语言功能,但您正在为较旧的标准版本进行编译。
what does decomposition declaration in this context means?
“分解声明”是 structured bindings 的另一个名称,它是在线上使用的新(大概)语言功能:
const auto [min, max] = std::minmax_element(vect.begin(), vect.end());
结构化绑定(即分解声明)的简化语法是:
auto [ identifier-list ] = expression ;
我收到了这个警告:
warning: decomposition declaration only available with -std=c++1z or -std=gnu++1
对于此代码:
#include<algorithm>
#include<vector>
int main(){
std::vector<int> vect{ 10, 20, 30 };
const auto [min, max] = std::minmax_element(vect.begin(), vect.end());
return 0;
}
在此上下文中,分解声明是什么意思?
what does it mean?
该警告意味着您使用了 C++17 标准(其工作名称为 C++1z)中引入的语法/语言功能,但您正在为较旧的标准版本进行编译。
what does decomposition declaration in this context means?
“分解声明”是 structured bindings 的另一个名称,它是在线上使用的新(大概)语言功能:
const auto [min, max] = std::minmax_element(vect.begin(), vect.end());
结构化绑定(即分解声明)的简化语法是:
auto [ identifier-list ] = expression ;