[ Web Proxy ]
URL:
Viewing: http://pt.cppreference.com/cpp/utility/piecewise_construct_t [Back]  [Original]

std::piecewise_construct_t - cppreference.com
cppreference.com
Espaos nominais
Variantes

std::piecewise_construct_t

De cppreference.com

<metanoindex/>

 
 
Biblioteca de utilitrios
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memria dinmica
De tratamento de erros
Utilidades do programa
Variadic funes
Data e hora
Objetos de funo
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avanar e avanar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
std::pair
Funes de membro
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
No-membros funes
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.
(C++11)
Classes auxiliares
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.
(C++11)
 
<tbody> </tbody>
Definido no cabealho <utility>
struct piecewise_construct_t { };
(desde C++11)

std::piecewise_construct_t is an empty struct tag type used to disambiguate between different functions that take two tuple arguments.

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.

Exemplo

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

Sada:

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

Veja tambm

um objeto de piecewise_construct_t tipo usado para remover a ambigidade funes para construo por partes
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]

Web Proxy Viewer  |  New URL  |  Original Page