Espaces de noms
Variantes
Affichages
Actions

std::piecewise_construct_t

De cppreference.com
< cpp‎ | utility
 
 
 
std::pair
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.
pair::pair
pair::operator=
pair::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_pair
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get (C++11)
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 (C++11)
tuple_element (C++11)
 
Defined in header <utility>
struct piecewise_construct_t { };
(depuis C++11)
std::piecewise_construct_t est un type struct vide balise utilisée pour lever l'ambiguïté entre les différentes fonctions qui prennent deux arguments tuple .
Original:
std::piecewise_construct_t is an empty struct tag type used to disambiguate between different functions that take two tuple arguments.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Les surcharges qui ne std::piecewise_construct_t utiliser supposer que chaque argument tuple devient l'élément d'une paire. Les surcharges qui utilisent std::piecewise_construct_t supposer que chaque argument tuple est utilisé pour construire, par morceaux, un nouvel objet du type spécifié, qui deviendra l'élément de la paire .
Original:
The overloads that do not use std::piecewise_construct_t assume that each tuple argument becomes the element of a pair. The overloads that use std::piecewise_construct_t assume that each tuple argument is used to construct, piecewise, a new object of specified type, which will become the element of the pair.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Exemple

[edit]
#include <iostream>
#include <utility>
#include <tuple>
 
struct Foo {
    Foo(std::tuple<int, float>) 
    {
        std::cout << "Constructed a Foo from a tuple\n";
    }
    Foo(int, float) 
    {
        std::cout << "Constructed a Foo from an int and a float\n";
    }
};
 
int main()
{
    std::tuple<int, float> t(1, 3.14);
    std::pair<Foo, Foo> p1(t, t);
    std::pair<Foo, Foo> p2(std::piecewise_construct, t, t);
}

Résultat :

Constructed a Foo from a tuple
Constructed a Foo from a tuple
Constructed a Foo from an int and a float
Constructed a Foo from an int and a float

[modifier] Voir aussi

un objet de piecewise_construct_t type utilisé pour lever l'ambiguïté des fonctions pour la construction par morceaux
Original:
an object of type piecewise_construct_t used to disambiguate functions for piecewise construction
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(constante) [edit]