std::tie(myint, std::ignore, mychar)
возвращает тип
std::tuple<int&, decltype((std::ignore)), char&>
, где int&
— это ссылка на myint
, а char&
— на mychar
.
Когда этому возвращенному кортежу ссылок присваивается mytuple
, каждое значение в mytuple
присваивается соответствующей ссылке, хранящейся в возвращенном кортеже. Это приводит к обновлению myint
и mychar
на месте.
std::tie(myint, std::ignore, mychar) // <-- expression
std::tuple<int&, decltype((std::ignore)), char&> // <-- type
std::tie(myint, std::ignore, mychar) = mytuple;
std::tuple<int&, decltype((std::ignore)), char&> = std::tuple<int, T, char>&;
// functions as
std::tuple<int , T , char >&
// ↓↓ = = = ↓↓
std::tuple<int&, decltype((std::ignore)), char&>
// end result:
myint = std::get<0>(mytuple);
mychar = std::get<2>(mytuple);
int& = int&;
char& = char&;
person
ildjarn
schedule
20.11.2016