다음을 통해 공유


make_tuple Function

Makes a tuple from element values.

template<class T1, class T2, ..., class TN>
    tuple<V1, V2, ..., VN>
    make_tuple(const T1& t1, const T2& t2, ..., const TN& tN);

Parameters

  • TN
    The type of the Nth function parameter.

  • tN
    The value of the Nth function parameter.

Remarks

The template function returns tuple<V1, V2, ..., VN>(t1, t2, ..., tN), where each type Vi is X& when the corresponding type Ti is cv reference_wrapper<X> and Ti otherwise.

Example

 

// std_tr1__tuple__make_tuple.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; 
 
    c0 = std::make_tuple(4, 5, 6, 7); 
 
// display contents " 4 5 6 7" 
    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; 
 
    return (0); 
    } 
 
 0 1 2 3
 4 5 6 7

Requirements

Header: <tuple>

Namespace: std

See Also

Reference

<tuple>

tie Function

Other Resources

<tuple> Members