This class template implements a value‐semantic container type holding an ordered sequence of unique keys (of the template parameter type, KEY).

Synopsis

Declared in <bslstl_set.h>

template<
    class KEY,
    class COMPARATOR = std::less<KEY>,
    class ALLOCATOR = allocator<KEY>>
class set;

Description

This class: * supports a complete set of value‐semantic operations except for BDEX serialization * is exception‐neutral (agnostic except for the at method) * is alias‐safe * is const thread‐safe For terminology see {`bsldoc_glossary`}.

Type Aliases

Name

Description

allocator_type

This typedef is an alias to the (template parameter) ALLOCATOR.

const_iterator

This typedef is an alias to iterator.

const_pointer

This typedef is an alias to the allocator const‐pointer type.

const_reference

This typedef is an alias for const_reference.

const_reverse_iterator

This typedef is an alias to the const reverse iterator type.

difference_type

This typedef is an alias to the allocator difference type.

iterator

This typedef is an alias to the red‐black tree iterator type.

key_compare

This typedef is an alias to the (template parameter) COMPARATOR.

key_type

This typedef is an alias to the (template parameter) KEY type.

pointer

This typedef is an alias to the allocator pointer type.

reference

This typedef is an alias to value_type&.

reverse_iterator

This typedef is an alias to the reverse iterator type.

size_type

This typedef is an alias to the allocator size type.

value_compare

This typedef is an alias to key_compare.

value_type

This typedef is an alias to key_type.

Member Functions

Name

Description

set [constructor]

Constructors

~set [destructor]

Destroy this object.

operator=

Assignment operators

begin

begin overloads

cbegin

Return a const iterator to the first element, or cend if empty.

cend

Return an iterator providing non‐modifiable access to the past‐the‐end element in the ordered sequence of value_type objects maintained by this set.

clear

Remove all entries from this set. Note that the set is empty after this call, but allocated memory may be retained for future use.

contains

contains overloads

count

count overloads

crbegin

Return a const reverse iterator to the last element, or crend.

crend

Return a const reverse iterator to prior‐to‐the‐beginning.

emplace

Emplace a newly constructed value_type if not already present.

emplace_hint

Emplace a newly constructed value_type near hint if not present.

empty

Return true if this set contains no elements, and false otherwise.

end

end overloads

equal_range

equal_range overloads

erase

erase overloads

find

find overloads

get_allocator

Return (a copy of) the allocator used for memory allocation by this set.

insert

insert overloads

insert_range

Insert each unique value from the specified range.

key_comp

Return the key‐comparison functor used by this set.

lower_bound

lower_bound overloads

max_size

Return a theoretical upper bound on this set's size.

rbegin

rbegin overloads

rend

rend overloads

size

Return the number of elements in this set.

swap

Exchange the value and comparator with other.

upper_bound

upper_bound overloads

value_comp

Return a functor for comparing two value_type objects.

Deduction Guides

Name

Description

set<KEY>

Deduce KEY from an initializer_list when an allocator pointer is given.

set<KEY>

Deduce KEY from iterators when an allocator pointer is supplied.

set<KEY, COMPARATOR>

Deduce KEY and COMPARATOR from an initializer_list with an allocator pointer.

set<KEY, COMPARATOR>

Deduce KEY and COMPARATOR from iterators when an allocator pointer is given.

set<KEY, COMPARATOR, ALLOCATOR>

Deduce KEY, COMPARATOR, and ALLOCATOR from an initializer_list constructor.

set<KEY, COMPARATOR, ALLOCATOR>

Deduce KEY, COMPARATOR, and ALLOCATOR from an iterator‐range constructor.

set<KEY, std::less<KEY>, ALLOCATOR>

Deduce KEY and ALLOCATOR from an initializer_list constructor.

set<KEY, std::less<KEY>, ALLOCATOR>

Deduce KEY and ALLOCATOR from an iterator‐range constructor.

Non-Member Functions

Name

Description

erase_if

Erase all elements in s that satisfy predicate.

operator<=>

Perform a lexicographic three‐way comparison of lhs and rhs.

operator==

Return true if lhs and rhs have the same value, and false otherwise.

swap

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

Created with MrDocs