Espaces de noms
Variantes
Affichages
Actions

std::forward_as_tuple

De cppreference.com
< cpp‎ | utility‎ | tuple

 
 
 
std::tuple
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple::tuple
tuple::operator=
tuple::swap
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
make_tuple
tie
forward_as_tuple
None
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get
Classes d'aide
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple_size
tuple_element
uses_allocator
ignore
 
Defined in header <tuple>
template< class... Types >
tuple<Types...> forward_as_tuple( Types&&... args );
(depuis C++11)
Construit un tuple de références aux arguments en args appropriés pour transmettre en tant qu'argument à une fonction. Le tuple a rvalue membres de données de référence lorsque rvalues ​​sont utilisés comme arguments, et a par ailleurs référence lvalue membres de données. Si rvalues ​​sont utilisés, le résultat de cette fonction doit être consommé avant le point de séquence suivante .
Original:
Constructs a tuple of references to the arguments in args suitable for forwarding as an argument to a function. The tuple has rvalue reference data members when rvalues are used as arguments, and otherwise has lvalue reference data members. If rvalues are used, the result of this function must be consumed before the next sequence point.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Sommaire

[modifier] Paramètres

args -
zéro ou plusieurs arguments pour construire le tuple
Original:
zero or more 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.

[modifier] Retourne la valeur

Un objet std::tuple créé comme par std::tuple<Types&&...>(std::forward<Types>(args)...)
Original:
A std::tuple object created as if by std::tuple<Types&&...>(std::forward<Types>(args)...)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Exceptions

noexcept specification:  
noexcept
   (depuis C++11)

[modifier] Exemple

#include <iostream>
#include <map>
#include <tuple>
#include <string>
 
int main()
{
    std::map<int, std::string> m;
 
    // same as m.emplace(10, 20, 'a');
    m.emplace(std::forward_as_tuple(10, std::string(20, 'a')));
    std::cout << "m[10] = " << m[10] << '\n';
 
    // The following is an error: it produces a
    // std::tuple<int&&, std::string&&> holding two dangling references.
    //
    // auto t = std::forward_as_tuple(10, std::string(20, 'a'));
    // m.emplace(t);
}

Résultat :

m[10] = aaaaaaaaaaaaaaaaaaaa
crée un objet tuple du type défini par les types d'arguments
Original:
creates a tuple object of the type defined by the argument types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
crée un tuple de références lvalue ou décompresse un tuple dans des objets individuels
Original:
creates a tuple of lvalue references or unpacks a tuple into individual objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
crée un tuple en concaténant un certain nombre de tuples
Original:
creates a tuple by concatenating any number of tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]