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

std::pair::swap

Материал из 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)
 
void swap(pair& other);
(начиная с C++11)
Обмены first с other.first и second с other.second.
Original:
Swaps first with other.first and second with other.second.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Содержание

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

other -
пара значений для замены
Original:
pair of values to swap
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Возвращаемое значение

(Нет)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Исключения

noexcept-спецификация:  (начиная с C++11)
noexcept(

     noexcept(std::swap(first, p.first)) &&
     noexcept(std::swap(second, p.second))

)

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

#include <iostream>
#include <utility>
#include <string>
int main()
{
    std::pair<int, std::string> p1, p2;
    p1 = std::make_pair(10, "test");
    p2.swap(p1);
    std::cout << "(" << p2.first << ", " << p2.second << ")\n";
}

Вывод:

(10, test)

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