Espacios de nombres
Variantes

std::tie

De cppreference.com
 
 
Biblioteca de servicios
 
 
<tbody> </tbody>
Definido en el archivo de encabezado <tuple>
template< class... Types > tuple<Types&...> tie( Types&... args );
(desde C++11)
Crea una tupla de referencias lvalue a sus argumentos o instancias de std::ignore .
Original:
Creates a tuple of lvalue references to its arguments or instances of std::ignore.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parámetros

args -
cero o más argumentos lvalue para la construcción de la tupla
Original:
zero or more lvalue arguments to construct the tuple from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valor de retorno

Un objeto que contiene referencias al respecto std::tuple lvalue .
Original:
A std::tuple object containing lvalue referenes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Excepciones

Especificación noexcept:  
<tbody> </tbody>
noexcept
  (desde C++11)

Ejemplo

std::tie se puede utilizar para introducir lexicográfico comparación con una estructura o desempaquetar una tupla:
Original:
std::tie can be used to introduce lexicographical comparison to a struct or to unpack a tuple:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <string>
#include <set>
#include <tuple>

struct S {
    int n;
    std::string s;
    float d;
    bool operator<(const S& rhs) const
    {
        // compares n to rhs.n,
        // then s to rhs.s,
        // then d to rhs.d
        return std::tie(n, s, d) < std::tie(rhs.n, rhs.s, rhs.d);
    }
};

int main()
{
    std::set<S> set_of_s; // S is LessThanComparable

    S value{42, "Test", 3.14};
    std::set<S>::iterator iter;
    bool inserted;
    // unpacks the return value of insert into iter and inserted
    std::tie(iter, inserted) = set_of_s.insert(value);
    if(inserted)
        std::cout << "Value was inserted sucessfully\n";
}

Salida:

Value was inserted sucessfully
Crea un objeto de tupla del tipo definido por los tipos de argumentos.
(plantilla de función) [editar]
Crea una tupla de referencias r-valor.
(plantilla de función) [editar]
Crea una tupla mediante la concatenación de cualquier número de tuplas.
(plantilla de función) [editar]
Marcador de posición para saltarse un elemento cuando se desempaca una tupla utilizando tie.
(constante) [editar]