[#bsl-set-0d] = xref:bsl.adoc[bsl]::set :relfileprefix: ../ :mrdocs: 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>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class KEY, class COMPARATOR = std::less<KEY>, class ALLOCATOR = xref:bsl/allocator-0df.adoc[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 [cols="1,4"] |=== | Name| Description | xref:bsl/set-0d/allocator_type.adoc[`allocator_type`] | This `typedef` is an alias to the (template parameter) `ALLOCATOR`. | xref:bsl/set-0d/const_iterator.adoc[`const_iterator`] | This `typedef` is an alias to `iterator`. | xref:bsl/set-0d/const_pointer.adoc[`const_pointer`] | This `typedef` is an alias to the allocator const‐pointer type. | xref:bsl/set-0d/const_reference.adoc[`const_reference`] | This `typedef` is an alias for `const_reference`. | xref:bsl/set-0d/const_reverse_iterator.adoc[`const_reverse_iterator`] | This `typedef` is an alias to the const reverse iterator type. | xref:bsl/set-0d/difference_type.adoc[`difference_type`] | This `typedef` is an alias to the allocator difference type. | xref:bsl/set-0d/iterator.adoc[`iterator`] | This `typedef` is an alias to the red‐black tree iterator type. | xref:bsl/set-0d/key_compare.adoc[`key_compare`] | This `typedef` is an alias to the (template parameter) `COMPARATOR`. | xref:bsl/set-0d/key_type.adoc[`key_type`] | This `typedef` is an alias to the (template parameter) `KEY` type. | xref:bsl/set-0d/pointer.adoc[`pointer`] | This `typedef` is an alias to the allocator pointer type. | xref:bsl/set-0d/reference.adoc[`reference`] | This `typedef` is an alias to `value_type&`. | xref:bsl/set-0d/reverse_iterator.adoc[`reverse_iterator`] | This `typedef` is an alias to the reverse iterator type. | xref:bsl/set-0d/size_type.adoc[`size_type`] | This `typedef` is an alias to the allocator size type. | xref:bsl/set-0d/value_compare.adoc[`value_compare`] | This `typedef` is an alias to `key_compare`. | xref:bsl/set-0d/value_type.adoc[`value_type`] | This `typedef` is an alias to `key_type`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/set-0d/2constructor-006.adoc[`set`] [.small]#[constructor]# | Constructors | xref:bsl/set-0d/2destructor.adoc[`~set`] [.small]#[destructor]# | Destroy this object. | xref:bsl/set-0d/operator_assign-06.adoc[`operator=`] | Assignment operators | xref:bsl/set-0d/begin-054.adoc[`begin`] | `begin` overloads | xref:bsl/set-0d/cbegin.adoc[`cbegin`] | Return a const iterator to the first element, or `cend` if empty. | xref:bsl/set-0d/cend.adoc[`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. | xref:bsl/set-0d/clear.adoc[`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. | xref:bsl/set-0d/contains-0b.adoc[`contains`] | `contains` overloads | xref:bsl/set-0d/count-0a3.adoc[`count`] | `count` overloads | xref:bsl/set-0d/crbegin.adoc[`crbegin`] | Return a const reverse iterator to the last element, or `crend`. | xref:bsl/set-0d/crend.adoc[`crend`] | Return a const reverse iterator to prior‐to‐the‐beginning. | xref:bsl/set-0d/emplace.adoc[`emplace`] | Emplace a newly constructed `value_type` if not already present. | xref:bsl/set-0d/emplace_hint.adoc[`emplace_hint`] | Emplace a newly constructed `value_type` near `hint` if not present. | xref:bsl/set-0d/empty.adoc[`empty`] | Return `true` if this set contains no elements, and `false` otherwise. | xref:bsl/set-0d/end-0c.adoc[`end`] | `end` overloads | xref:bsl/set-0d/equal_range-07.adoc[`equal_range`] | `equal_range` overloads | xref:bsl/set-0d/erase-05.adoc[`erase`] | `erase` overloads | xref:bsl/set-0d/find-0a.adoc[`find`] | `find` overloads | xref:bsl/set-0d/get_allocator.adoc[`get_allocator`] | Return (a copy of) the allocator used for memory allocation by this set. | xref:bsl/set-0d/insert-00a.adoc[`insert`] | `insert` overloads | xref:bsl/set-0d/insert_range.adoc[`insert_range`] | Insert each unique value from the specified `range`. | xref:bsl/set-0d/key_comp.adoc[`key_comp`] | Return the key‐comparison functor used by this set. | xref:bsl/set-0d/lower_bound-0b.adoc[`lower_bound`] | `lower_bound` overloads | xref:bsl/set-0d/max_size.adoc[`max_size`] | Return a theoretical upper bound on this set's size. | xref:bsl/set-0d/rbegin-08.adoc[`rbegin`] | `rbegin` overloads | xref:bsl/set-0d/rend-0b.adoc[`rend`] | `rend` overloads | xref:bsl/set-0d/size.adoc[`size`] | Return the number of elements in this set. | xref:bsl/set-0d/swap.adoc[`swap`] | Exchange the value and comparator with `other`. | xref:bsl/set-0d/upper_bound-0c.adoc[`upper_bound`] | `upper_bound` overloads | xref:bsl/set-0d/value_comp.adoc[`value_comp`] | Return a functor for comparing two `value_type` objects. |=== == Deduction Guides [cols="1,4"] |=== | Name| Description | xref:bsl/set-03.adoc[`set<KEY>`] | Deduce `KEY` from an initializer_list when an allocator pointer is given. | xref:bsl/set-051.adoc[`set<KEY>`] | Deduce `KEY` from iterators when an allocator pointer is supplied. | xref:bsl/set-09.adoc[`set<KEY, COMPARATOR>`] | Deduce `KEY` and `COMPARATOR` from an initializer_list with an allocator pointer. | xref:bsl/set-0f9.adoc[`set<KEY, COMPARATOR>`] | Deduce `KEY` and `COMPARATOR` from iterators when an allocator pointer is given. | xref:bsl/set-0f6.adoc[`set<KEY, COMPARATOR, ALLOCATOR>`] | Deduce `KEY`, `COMPARATOR`, and `ALLOCATOR` from an initializer_list constructor. | xref:bsl/set-0a.adoc[`set<KEY, COMPARATOR, ALLOCATOR>`] | Deduce `KEY`, `COMPARATOR`, and `ALLOCATOR` from an iterator‐range constructor. | xref:bsl/set-05a.adoc[`set<KEY, std::less<KEY>, ALLOCATOR>`] | Deduce `KEY` and `ALLOCATOR` from an initializer_list constructor. | xref:bsl/set-0b.adoc[`set<KEY, std::less<KEY>, ALLOCATOR>`] | Deduce `KEY` and `ALLOCATOR` from an iterator‐range constructor. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/erase_if-04.adoc[`erase_if`] | Erase all elements in `s` that satisfy `predicate`. | xref:bsl/operator_3way-0da.adoc[`operator<=>`] | Perform a lexicographic three‐way comparison of `lhs` and `rhs`. | xref:bsl/operator_eq-045.adoc[`operator==`] | Return `true` if `lhs` and `rhs` have the same value, and `false` otherwise. | xref:bsl/swap-0c8.adoc[`swap`] | Exchange the value and comparator of `a` with those of `b`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#