[#bsl-set-0d]
= xref:bsl.adoc[bsl]::set
:relfileprefix: ../
:mrdocs:

This class template implements a value&hyphen;semantic container type holding an ordered sequence of unique keys (of the template parameter type, `KEY`)&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;set&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class COMPARATOR = std::less&lt;KEY&gt;,
    class ALLOCATOR = xref:bsl/allocator-0df.adoc[allocator&lt;KEY&gt;]&gt;
class set;
----

== Description

This class&colon; &ast; supports a complete set of _value&hyphen;semantic_ operations except for `BDEX` serialization &ast; is _exception&hyphen;neutral_ (agnostic except for the `at` method) &ast; is _alias&hyphen;safe_ &ast; is `const` _thread&hyphen;safe_ For terminology see &lcub;`bsldoc&lowbar;glossary`&rcub;&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/set-0d/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR`&period;
| xref:bsl/set-0d/const_iterator.adoc[`const&lowbar;iterator`] 
| This `typedef` is an alias to `iterator`&period;
| xref:bsl/set-0d/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias to the allocator const&hyphen;pointer type&period;
| xref:bsl/set-0d/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias for `const&lowbar;reference`&period;
| xref:bsl/set-0d/const_reverse_iterator.adoc[`const&lowbar;reverse&lowbar;iterator`] 
| This `typedef` is an alias to the const reverse iterator type&period;
| xref:bsl/set-0d/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias to the allocator difference type&period;
| xref:bsl/set-0d/iterator.adoc[`iterator`] 
| This `typedef` is an alias to the red&hyphen;black tree iterator type&period;
| xref:bsl/set-0d/key_compare.adoc[`key&lowbar;compare`] 
| This `typedef` is an alias to the (template parameter) `COMPARATOR`&period;
| xref:bsl/set-0d/key_type.adoc[`key&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `KEY` type&period;
| xref:bsl/set-0d/pointer.adoc[`pointer`] 
| This `typedef` is an alias to the allocator pointer type&period;
| xref:bsl/set-0d/reference.adoc[`reference`] 
| This `typedef` is an alias to `value&lowbar;type&amp;`&period;
| xref:bsl/set-0d/reverse_iterator.adoc[`reverse&lowbar;iterator`] 
| This `typedef` is an alias to the reverse iterator type&period;
| xref:bsl/set-0d/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias to the allocator size type&period;
| xref:bsl/set-0d/value_compare.adoc[`value&lowbar;compare`] 
| This `typedef` is an alias to `key&lowbar;compare`&period;
| xref:bsl/set-0d/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to `key&lowbar;type`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/set-0d/2constructor-006.adoc[`set`]         [.small]#[constructor]#
| Constructors
| xref:bsl/set-0d/2destructor.adoc[`&#126;set`] [.small]#[destructor]#
| Destroy this object&period;
| xref:bsl/set-0d/operator_assign-06.adoc[`operator&equals;`] 
| 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&period;
| xref:bsl/set-0d/cend.adoc[`cend`] 
| Return an iterator providing non&hyphen;modifiable access to the past&hyphen;the&hyphen;end element in the ordered sequence of `value&lowbar;type` objects maintained by this set&period;
| xref:bsl/set-0d/clear.adoc[`clear`] 
| Remove all entries from this set&period; Note that the set is empty after this call, but allocated memory may be retained for future use&period;
| 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`&period;
| xref:bsl/set-0d/crend.adoc[`crend`] 
| Return a const reverse iterator to prior&hyphen;to&hyphen;the&hyphen;beginning&period;
| xref:bsl/set-0d/emplace.adoc[`emplace`] 
| Emplace a newly constructed `value&lowbar;type` if not already present&period;
| xref:bsl/set-0d/emplace_hint.adoc[`emplace&lowbar;hint`] 
| Emplace a newly constructed `value&lowbar;type` near `hint` if not present&period;
| xref:bsl/set-0d/empty.adoc[`empty`] 
| Return `true` if this set contains no elements, and `false` otherwise&period;
| xref:bsl/set-0d/end-0c.adoc[`end`] 
| `end` overloads
| xref:bsl/set-0d/equal_range-07.adoc[`equal&lowbar;range`] 
| `equal&lowbar;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&lowbar;allocator`] 
| Return (a copy of) the allocator used for memory allocation by this set&period;
| xref:bsl/set-0d/insert-00a.adoc[`insert`] 
| `insert` overloads
| xref:bsl/set-0d/insert_range.adoc[`insert&lowbar;range`] 
| Insert each unique value from the specified `range`&period;
| xref:bsl/set-0d/key_comp.adoc[`key&lowbar;comp`] 
| Return the key&hyphen;comparison functor used by this set&period;
| xref:bsl/set-0d/lower_bound-0b.adoc[`lower&lowbar;bound`] 
| `lower&lowbar;bound` overloads
| xref:bsl/set-0d/max_size.adoc[`max&lowbar;size`] 
| Return a theoretical upper bound on this set&apos;s size&period;
| 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&period;
| xref:bsl/set-0d/swap.adoc[`swap`] 
| Exchange the value and comparator with `other`&period;
| xref:bsl/set-0d/upper_bound-0c.adoc[`upper&lowbar;bound`] 
| `upper&lowbar;bound` overloads
| xref:bsl/set-0d/value_comp.adoc[`value&lowbar;comp`] 
| Return a functor for comparing two `value&lowbar;type` objects&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/set-03.adoc[`set&lt;KEY&gt;`] 
| Deduce `KEY` from an initializer&lowbar;list when an allocator pointer is given&period;
| xref:bsl/set-051.adoc[`set&lt;KEY&gt;`] 
| Deduce `KEY` from iterators when an allocator pointer is supplied&period;
| xref:bsl/set-09.adoc[`set&lt;KEY, COMPARATOR&gt;`] 
| Deduce `KEY` and `COMPARATOR` from an initializer&lowbar;list with an allocator pointer&period;
| xref:bsl/set-0f9.adoc[`set&lt;KEY, COMPARATOR&gt;`] 
| Deduce `KEY` and `COMPARATOR` from iterators when an allocator pointer is given&period;
| xref:bsl/set-0f6.adoc[`set&lt;KEY, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce `KEY`, `COMPARATOR`, and `ALLOCATOR` from an initializer&lowbar;list constructor&period;
| xref:bsl/set-0a.adoc[`set&lt;KEY, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce `KEY`, `COMPARATOR`, and `ALLOCATOR` from an iterator&hyphen;range constructor&period;
| xref:bsl/set-05a.adoc[`set&lt;KEY, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce `KEY` and `ALLOCATOR` from an initializer&lowbar;list constructor&period;
| xref:bsl/set-0b.adoc[`set&lt;KEY, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce `KEY` and `ALLOCATOR` from an iterator&hyphen;range constructor&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/erase_if-04.adoc[`erase&lowbar;if`]
| Erase all elements in `s` that satisfy `predicate`&period;
| xref:bsl/operator_3way-0da.adoc[`operator&lt;&equals;&gt;`]
| Perform a lexicographic three&hyphen;way comparison of `lhs` and `rhs`&period;
| xref:bsl/operator_eq-045.adoc[`operator&equals;&equals;`]
| Return `true` if `lhs` and `rhs` have the same value, and `false` otherwise&period;
| xref:bsl/swap-0c8.adoc[`swap`]
| Exchange the value and comparator of `a` with those of `b`&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
