Пространства имён
Варианты
Действия

std::piecewise_construct

Материал из cppreference.com

 
 
 
std::pair
Член функций
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
Не являющиеся членами функций
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)
Вспомогательные классы
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)
 
constexpr piecewise_construct_t piecewise_construct = std::piecewise_construct_t();
(начиная с C++11)
Постоянная std::piecewise_construct является экземпляром типа пустые теги структуры std::piecewise_construct_t.
Original:
The constant std::piecewise_construct is an instance of an empty struct tag type std::piecewise_construct_t.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Пример

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

Вывод:

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

[править] См. также

тег типа используются для выбора правильной перегрузки функции для кусочно строительства
Original:
tag type used to select correct function overload 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.

(класс) [edit]