Partager via


tie Function

Fait tuple des références d'élément.

template<class T1, class T2, ..., class TN>
    tuple<T1&, T2&, ..., TN&>
    tie(T1& t1, T2& t2, ..., TN& tN);

Paramètres

  • TN
    Le type de base du nième élément de tuple.

Notes

La fonction de modèle retourne tuple<T1&, T2&, ..., TN&>(t1, t2, ..., tN).

Exemple

 

// std_tr1__tuple__tie.cpp 
// compile with: /EHsc 
#include <tuple> 
#include <iostream> 
 
typedef std::tuple<int, double, int, double> Mytuple; 
int main() 
    { 
    Mytuple c0(0, 1, 2, 3); 
 
// display contents " 0 1 2 3" 
    std::cout << " " << std::get<0>(c0); 
    std::cout << " " << std::get<1>(c0); 
    std::cout << " " << std::get<2>(c0); 
    std::cout << " " << std::get<3>(c0); 
    std::cout << std::endl; 
 
    int v4 = 4; 
    double v5 = 5; 
    int v6 = 6; 
    double v7 = 7; 
    std::tie(v4, v5, v6, v7) = c0; 
 
// display contents " 0 1 2 3" 
    std::cout << " " << v4; 
    std::cout << " " << v5; 
    std::cout << " " << v6; 
    std::cout << " " << v7; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
  

Configuration requise

en-tête : <tuple>

l'espace de noms : DST

Voir aussi

Référence

<tuple>

make_tuple Function