bsl::swap

swap overloads

Synopses

Declared in <bslstl_deque.h>

Exchange the stop states referred to by lhs and rhs.

void
swap(
    stop_source& lhs,
    stop_source& rhs) noexcept;
» more...

Exchange the stop states referred to by lhs and rhs.

void
swap(
    stop_token& lhs,
    stop_token& rhs) noexcept;
» more...

Exchange the values of the specified a and b objects.

void
swap(
    vector& a,
    vector& b) noexcept(noexcept(a.d_impl.swap(b.d_impl)));
» more...

Exchange the targets held by the specified a and b functions.

template<class PROTOTYPE>
void
swap(
    function<PROTOTYPE>& a,
    function<PROTOTYPE>& b) noexcept;
» more...

Exchange the values of two optionals.

template<class t_TYPE>
void
swap(
    bsl::optional<t_TYPE>& lhs,
    bsl::optional<t_TYPE>& rhs)
requires BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value;
» more...

Exchange the values of two optionals.

template<class t_TYPE>
constexpr
void
swap(
    bsl::optional<t_TYPE>& lhs,
    bsl::optional<t_TYPE>& rhs)
requires !BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value;
» more...

Exchange the values of two optionals.

template<class t_TYPE>
void
swap(
    bsl::optional<t_TYPE>& lhs,
    std::optional<t_TYPE>& rhs)
requires !BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value;
» more...

Exchange the values of the specified lhs and rhs optional objects.

template<class t_TYPE>
constexpr
void
swap(
    std::optional<t_TYPE>& lhs,
    bsl::optional<t_TYPE>& rhs)
requires !BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value;
» more...

Exchange the states of the specified shared_ptr objects a and b.

template<class ELEMENT_TYPE>
void
swap(
    shared_ptr<ELEMENT_TYPE>& a,
    shared_ptr<ELEMENT_TYPE>& b) noexcept;
» more...

Exchange the states of the specified weak_ptr objects a and b.

template<class ELEMENT_TYPE>
void
swap(
    weak_ptr<ELEMENT_TYPE>& a,
    weak_ptr<ELEMENT_TYPE>& b) noexcept;
» more...

Exchange the values of the specified a and b deques.

template<
    class VALUE_TYPE,
    class ALLOCATOR>
void
swap(
    deque<VALUE_TYPE, ALLOCATOR>& a,
    deque<VALUE_TYPE, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Exchange the values of the specified a and b lists.

template<
    class VALUE,
    class ALLOCATOR>
void
swap(
    list<VALUE, ALLOCATOR>& a,
    list<VALUE, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Swap the values of the specified a and b pairs.

template<
    class T1,
    class T2>
void
swap(
    pair<T1, T2>& a,
    pair<T1, T2>& b) noexcept(noexcept(a.swap(b)))
requires bsl::is_swappable<T1>::value && bsl::is_swappable<T2>::value;
» more...

Swap the values of the specified lhs and rhs queues.

template<
    class VALUE,
    class CONTAINER>
void
swap(
    queue<VALUE, CONTAINER>& lhs,
    queue<VALUE, CONTAINER>& rhs) noexcept(false);
» more...

Swap the value of the specified lhs stack with the value of the specified rhs stack.

template<
    class VALUE,
    class CONTAINER>
void
swap(
    stack<VALUE, CONTAINER>& lhs,
    stack<VALUE, CONTAINER>& rhs) noexcept(false);
» more...

Efficiently exchange the values of the specified lhs and rhs objects.

template<
    class t_HEAD,
    class... t_TAIL>
void
swap(
    bsl::variant<t_HEAD, t_TAIL...>& lhs,
    bsl::variant<t_HEAD, t_TAIL...>& rhs);
» more...

Exchange the contents of two vectors.

template<
    class VALUE_TYPE,
    class ALLOCATOR>
void
swap(
    vector<VALUE_TYPE, ALLOCATOR>& a,
    vector<VALUE_TYPE, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Efficiently exchange the values of the specified a and b objects.

template<
    class CHAR_TYPE,
    class CHAR_TRAITS,
    class ALLOCATOR>
void
swap(
    basic_istringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& a,
    basic_istringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& b);
» more...

Efficiently exchange the values of the specified a and b objects.

template<
    class CHAR_TYPE,
    class CHAR_TRAITS,
    class ALLOCATOR>
void
swap(
    basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& a,
    basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& b);
» more...

Exchange the contents of two strings.

template<
    class CHAR_TYPE,
    class CHAR_TRAITS,
    class ALLOCATOR>
void
swap(
    basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& a,
    basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Efficiently exchange the values of the specified a and b objects.

template<
    class CHAR_TYPE,
    class CHAR_TRAITS,
    class ALLOCATOR>
void
swap(
    basic_stringbuf<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& a,
    basic_stringbuf<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& b);
» more...

Efficiently exchange the values of the specified a and b objects.

template<
    class CHAR_TYPE,
    class CHAR_TRAITS,
    class ALLOCATOR>
void
swap(
    basic_stringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& a,
    basic_stringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& b);
» more...

Swap the specified a with the specified b using a.swap(b) expression.

template<
    class CHAR,
    class TRAITS,
    class ALLOCATOR>
void
swap(
    basic_syncbuf<CHAR, TRAITS, ALLOCATOR>& a,
    basic_syncbuf<CHAR, TRAITS, ALLOCATOR>& b);
» more...

Exchange the values of the specified a and b multisets.

template<
    class KEY,
    class COMPARATOR,
    class ALLOCATOR>
void
swap(
    multiset<KEY, COMPARATOR, ALLOCATOR>& a,
    multiset<KEY, COMPARATOR, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Exchange the container and comparator of a with those of b.

template<
    class VALUE,
    class CONTAINER,
    class COMPARATOR>
void
swap(
    priority_queue<VALUE, CONTAINER, COMPARATOR>& a,
    priority_queue<VALUE, CONTAINER, COMPARATOR>& b) noexcept(false);
» more...

Exchange the value and comparator of a with those of b.

template<
    class KEY,
    class COMPARATOR,
    class ALLOCATOR>
void
swap(
    set<KEY, COMPARATOR, ALLOCATOR>& a,
    set<KEY, COMPARATOR, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Exchange the contents of the specified hash multisets.

template<
    class _Value,
    class _HashFcn,
    class _EqualKey,
    class _Alloc>
void
swap(
    hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& lhs,
    hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& rhs);
» more...

Exchange the contents of the specified hash sets.

template<
    class _Value,
    class _HashFcn,
    class _EqualKey,
    class _Alloc>
void
swap(
    hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& lhs,
    hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& rhs);
» more...

Exchange the value and comparator of a with those of b.

template<
    class KEY,
    class VALUE,
    class COMPARATOR,
    class ALLOCATOR>
void
swap(
    map<KEY, VALUE, COMPARATOR, ALLOCATOR>& a,
    map<KEY, VALUE, COMPARATOR, ALLOCATOR>& b) noexcept(false);
» more...

Exchange the value and comparator of a with those of b.

template<
    class KEY,
    class VALUE,
    class COMPARATOR,
    class ALLOCATOR>
void
swap(
    multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& a,
    multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& b) noexcept(false);
» more...

Exchange the values of the specified a and b objects.

template<
    class KEY,
    class HASH,
    class EQUAL,
    class ALLOCATOR>
void
swap(
    unordered_multiset<KEY, HASH, EQUAL, ALLOCATOR>& a,
    unordered_multiset<KEY, HASH, EQUAL, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Exchange the contents of a and b.

template<
    class KEY,
    class HASH,
    class EQUAL,
    class ALLOCATOR>
void
swap(
    unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& a,
    unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& b) noexcept(noexcept(a.swap(b)));
» more...

Exchange the contents of the specified hash maps.

template<
    class _Key,
    class _Tp,
    class _HashFcn,
    class _EqualKey,
    class _Alloc>
void
swap(
    hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc>& lhs,
    hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc>& rhs);
» more...

Exchange the contents of the specified hash multimaps.

template<
    class _Key,
    class _Tp,
    class _HashFcn,
    class _EqualKey,
    class _Alloc>
void
swap(
    hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc>& lhs,
    hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc>& rhs);
» more...

Exchange the contents of a with those of b.

template<
    class KEY,
    class VALUE,
    class HASH,
    class EQUAL,
    class ALLOCATOR>
void
swap(
    unordered_map<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& a,
    unordered_map<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& b) noexcept(false);
» more...

Exchange the value of a with that of b.

template<
    class KEY,
    class VALUE,
    class HASH,
    class EQUAL,
    class ALLOCATOR>
void
swap(
    unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& a,
    unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& b) noexcept(false);
» more...

Parameters

NameDescription
lhsfirst source participating in the swap
rhssecond source participating in the swap
afirst vector to swap
bsecond vector to swap