[set.cons] # 23 Containers library [[containers]](./#containers) ## 23.4 Associative containers [[associative]](associative#set.cons) ### 23.4.6 Class template set [[set]](set#cons) #### 23.4.6.2 Constructors, copy, and assignment [set.cons] [🔗](#lib:set,constructor) `constexpr explicit set(const Compare& comp, const Allocator& = Allocator()); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12866) *Effects*: Constructs an empty set using the specified comparison object and allocator[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12870) *Complexity*: Constant[.](#2.sentence-1) [🔗](#lib:set,constructor_) `template constexpr set(InputIterator first, InputIterator last, const Compare& comp = Compare(), const Allocator& = Allocator()); ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12883) *Effects*: Constructs an emptyset using the specified comparison object and allocator, and inserts elements from the range [first, last)[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12891) *Complexity*: Linear in N if the range [first, last) is already sorted with respect to comp and otherwise NlogN, where N islast - first[.](#4.sentence-1) [🔗](#lib:set,constructor__) `template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]") R> constexpr set(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12909) *Effects*: Constructs an empty set using the specified comparison object and allocator, and inserts elements from the range rg[.](#5.sentence-1) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12914) *Complexity*: Linear in N if rg is already sorted with respect to comp and otherwise NlogN, where N is ranges​::​distance(rg)[.](#6.sentence-1)