【发布时间】:2017-06-26 12:30:55
【问题描述】:
结构化绑定只能使用某种“结构”作为返回值吗?
归还任何类/结构,例如这里的元组工作正常:
auto f()
{
return std::make_tuple(1,2.2);
}
有没有什么东西可以实现:
auto f() -> [int,double]
{
return { 1, 2.2 }; // maybe with or without braces arround
}
【问题讨论】:
-
你可以做
auto f() -> std::tuple<int,double>。 -
正如 Nathan 所说,自 C++11 以来,任何临时聚合需求都得到满足。
标签: c++ c++17 structured-bindings