#include
<tuple>
template<class... Types> tuple<Types&...> tie(Types&... t)
Bindet eine Liste von Variablen zu einem Tupel von Referenzen. Der Platzhalter std::ignore
kann für Stellen genutzt werden, die nicht belegt werden sollen.
t | Variablenliste |
Rückgabewert: Tupel.
get(),
make_tuple(),
cref(),
ref(),
std::pair<T1, T2>
.
#include <iostream> #include <string> #include <tuple> int main() { std::string x = "Himmel"; char y = "&"; const char* const z = "Hoelle"; auto t = std::make_tuple(x,y,z); std::cout << std::get<0>(t) << std::get<1>(t) << std::get<2>(t) << '\n'; std::tie(x,y,std::ignore) = t; std::cout << x << y << z << '\n'; }