Przestrzenie nazw
Warianty

std::pair::swap

Z cppreference.com
<tbody> </tbody>
void swap(pair& other) noexcept(/* see below */);
(od C++11)

Zamienia ze sobą wartości elementów par, first z other.first oraz second z other.second.

Parametry

other - pary, których wartości zostaną ze sobązamienione

Zwracana wartość

(brak)

Wyjątki

noexcept specification:  (od C++11)

<tbody> </tbody>
noexcept( noexcept(swap(first, other.first)) && noexcept(swap(second, other.second)) )

Example

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

Wynik:

(10, test)

Zobacz także

zamienia ze sobą wartości dwóch obiektów
(szablon funkcji) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.