Inhaltsverzeichnis

tie()

#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.

Parameter

t Variablenliste

Ergebnis

Rückgabewert: Tupel.

Siehe auch

get(), make_tuple(), cref(), ref(), std::pair<T1, T2>.

Beispiel

tie.cpp
#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'; 
}