std::tuple<int, int, int> f();
std::tuple<int, int, float, int> g();
C++ 1Z將介紹語法結構綁定,這將有可能寫的,而不是
int a, b, c;
std::tie(a, b, c) = f();
像
auto [a, b, c] = f();
然而,std::tie
也允許指定std::ignore
忽略某些組件,例如:
std::tie(a, b, std::ignore, c) = g();
是否有可能使用新的結構化綁定語法來做類似的事情?它將如何工作?
只是在那裏放了一個任意的名字。 –
@ n.m。會不會有一個任意的名字創建一個副本? –
@Piotr我認爲沒有比'std :: ignore'更多的副本。由於我們保證了copy elision,所以虛擬變量被初始化;使用'std :: tie',初始化位於std :: ignore分配的rhs中的臨時對象。 – j6t