Namensräume
Varianten
Aktionen

std::tuple

Aus cppreference.com
< cpp‎ | utility


 
 
 
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 >
class tuple;
(seit C++11)
Vorlage Klasse std::tuple ist eine feste Größe Sammlung von heterogenen Werte. Es ist eine Verallgemeinerung der std::pair .
Original:
Class template std::tuple is a fixed-size collection of heterogeneous values. It is a generalization of std::pair.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Inhaltsverzeichnis

[Bearbeiten] Member-Funktionen

baut eine neue tuple
Original:
constructs a new tuple
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)
ordnet den Inhalt eines tuple zum anderen
Original:
assigns the contents of one tuple to another
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)
tauscht die Inhalte von zwei tuples
Original:
swaps the contents of two tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)

[Bearbeiten] Non-Member-Funktionen

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]
schafft eine tuple der rvalue Referenzen
Original:
creates a tuple of rvalue references
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]
Tupel zugreift angegebene Element
Original:
tuple accesses specified element
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]
lexikographisch vergleicht die Werte in dem Tupel
Original:
lexicographically compares the values in the tuple
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]
spezialisiert die std::swap Algorithmus
Original:
specializes the std::swap algorithm
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]

[Bearbeiten] Helper-Klassen

erhält die Größe der tuple bei der Kompilierung
Original:
obtains the size of tuple at compile time
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(class Template-Spezialisierung) [edit]
erhält den Typ des angegebenen Elements
Original:
obtains the type of the specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(class Template-Spezialisierung) [edit]
spezialisiert die std::uses_allocator Typ Merkmal
Original:
specializes the std::uses_allocator type trait
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(class Template-Spezialisierung) [edit]
Platzhalter, um ein Element zu überspringen, wenn Auspacken einer tuple mit tie
Original:
placeholder to skip an element when unpacking a tuple using tie
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(konstanten) [edit]

[Bearbeiten] Beispiel

#include <tuple>
#include <iostream>
#include <string>
#include <stdexcept>
 
std::tuple<double, char, std::string> get_student(int id)
{
    if (id == 0) return std::make_tuple(3.8, 'A', "Lisa Simpson");
    if (id == 1) return std::make_tuple(2.9, 'C', "Milhouse Van Houten");
    if (id == 2) return std::make_tuple(1.7, 'D', "Ralph Wiggum");
    throw std::invalid_argument("id");
}
 
int main()
{
    auto student0 = get_student(0);
    std::cout << "ID: 0, "
              << "GPA: " << std::get<0>(student0) << ", "
              << "grade: " << std::get<1>(student0) << ", "
              << "name: " << std::get<2>(student0) << '\n';
 
    double gpa1;
    char grade1;
    std::string name1;
    std::tie(gpa1, grade1, name1) = get_student(1);
    std::cout << "ID: 1, "
              << "GPA: " << gpa1 << ", "
              << "grade: " << grade1 << ", "
              << "name: " << name1 << '\n';
}

Output:

ID: 0, GPA: 3.8, grade: A, name: Lisa Simpson
ID: 1, GPA: 2.9, grade: C, name: Milhouse Van Houten