Namensräume
Varianten
Aktionen

std::forward_as_tuple

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

 
 
 
std::tuple
Member-Funktionen
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
Non-Member-Funktionen
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
Helper-Klassen
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 );
(seit C++11)
Erzeugt ein Tupel von Verweisen auf die Argumente args für die Weiterleitung als Argument an eine Funktion. Die Tupel hat rvalue Referenzdaten Mitglieder, wenn rvalues ​​als Argumente verwendet werden, und sonst lvalue Referenzdaten Mitglieder. Wenn rvalues ​​verwendet werden, muss das Ergebnis dieser Funktion vor der nächsten Sequenz Punkt verzehrt werden .
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.

Inhaltsverzeichnis

[Bearbeiten] Parameter

args -
null oder mehr Argumente, um die Tupel aus zu bauen
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.

[Bearbeiten] Rückgabewert

A std::tuple Objekt wie von std::tuple<Types&&...>(std::forward<Types>(args)...) erstellt
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.

[Bearbeiten] Ausnahmen

noexcept specification:  
noexcept
  (seit C++11)

[Bearbeiten] Beispiel

#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);
}

Output:

m[10] = aaaaaaaaaaaaaaaaaaaa
erzeugt eine tuple Objekt des Typs von den Argumenttypen definiert
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.

(Funktions-Template) [edit]
schafft eine tuple der lvalue Referenzen oder entpackt ein Tupel in einzelne Objekte
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.

(Funktions-Template) [edit]
erzeugt eine tuple durch Verketten beliebige Anzahl von Tupeln
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.

(Funktions-Template) [edit]