[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/utility/tuple [Back]  [Original]

std::tuple cppreference.com
cppreference.com
Espaces de noms
Variantes

std::tuple

De cppreference.com
 
 
 
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
 
<tbody> </tbody>
Dclar dans l'en-tte <tuple>
template< class... Types > class tuple;
(depuis C++11)

La class template std::tuple est une collection de taille fixe valeurs htrognes. Il s'agit d'une gnralisation de std::pair .

Fonctions membres

construit un nouveau tuple
(fonction membre publique)
affecte le contenu d'un tuple un autre
(fonction membre publique)
change les contenus de deux tuples
(fonction membre publique)

Fonctions tiers

cre un objet tuple du type dfini 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 gnrique) [edit]
cre un tuple de rfrences lvalue ou dcompresse 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 gnrique) [edit]
cre un tuple des rfrences rvalue
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.

(fonction gnrique) [edit]
cre un tuple en concatnant 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 gnrique) [edit]
tuple accde lment spcifi
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.

(fonction gnrique) [edit]
compare lexicographiquement les valeurs dans le tuple
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.

(fonction gnrique) [edit]
l'algorithme spcialis std::swap
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.

(fonction gnrique) [edit]

Classes d'aide

obtient la taille de tuple au moment de la compilation
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.

(classe gnrique spcialise) [edit]
obtient le type de l'lment spcifi
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.

(classe gnrique spcialise) [edit]
se spcialise le trait de type std::uses_allocator
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.

(classe gnrique spcialise) [edit]
valeur rserve pour sauter un lment lorsque vous dballez un tuple utilisant tie
(constante) [edit]

Exemple

#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) << ", "
              << "note : " << std::get<1>(student0) << ", "
              << "nom : " << 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 << ", "
              << "note : " << grade1 << ", "
              << "nom : " << name1 << '\n';
}



Web Proxy Viewer  |  New URL  |  Original Page