是否存在限制未来 C++ 标准引入多个 return 值的因素?

Is there something that limits the future C++ standard from introducing multiple return values?

在较新版本的 C++ 标准中,我们可以编写具有多个 return 值的函数,例如

std::tuple<int, std::string, float> someFunction0();

这迫使我们将函数调用为

int a;
std::string last_name;
float f_par;
std::tie(a, last_name, f_par) = someFunction0();

我的问题是,是否有什么东西阻止 C++ 委员会引入 "simpler" 形式的多 return 值语法?比如

[int, std::string, float] someFunction1();

这将允许您在调用函数时声明更多内联

[int a, std::string last_name, float f_par] = someFunction1();

(可能有比我提供的更好的语法解决方案。)

编译器方面,这应该不是问题,对吧?

在你的例子中std::tuple<int, std::string, float> someFunction0();仍然是returns一个tuple对象,由多个子对象组成。

is there something that prevents the C++ committee from introducing a "simpler" form of multiple return value syntax?

你可以使用 C++17 structured binding declaration 到 unpack/destructure 它:

Case 2: binding a tuple-like type

float x{};
char  y{};
int   z{};

std::tuple<float&,char&&,int> tpl(x,std::move(y),z);
const auto& [a,b,c] = tpl;
// a names a structured binding that refers to x; decltype(a) is float&
// b names a structured binding that refers to y; decltype(b) is char&&
// c names a structured binding that refers to the 3rd element of tpl; decltype(c) is co`