Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/header/flat set"

From cppreference.com
< cpp‎ | header
m (+' ' around "implementation-defined" - not-a-type-name (vs, e.g. "container-compatible-range"))
m (+<compare>: present in drafts N4950 & N4971::24.6.5 [http://eel.is/c++draft/flat.set.syn])
 
(2 intermediate revisions by one user not shown)
Line 5: Line 5:
 
{{dsc begin}}
 
{{dsc begin}}
 
{{dsc h1|Includes}}
 
{{dsc h1|Includes}}
 +
{{dsc inc|cpp/header/dsc compare}}
 
{{dsc inc|cpp/header/dsc initializer_list}}
 
{{dsc inc|cpp/header/dsc initializer_list}}
 
{{dsc h1|Classes}}
 
{{dsc h1|Classes}}
 
{{dsc inc|cpp/container/dsc flat_set}}
 
{{dsc inc|cpp/container/dsc flat_set}}
 
{{dsc inc|cpp/container/dsc flat_multiset}}
 
{{dsc inc|cpp/container/dsc flat_multiset}}
{{dsc inc|cpp/container/dsc sorted_unique_t}}
 
{{dsc inc|cpp/container/dsc sorted_equivalent_t}}
 
 
{{dsc inc|cpp/container/dsc uses_allocator|flat_set}}
 
{{dsc inc|cpp/container/dsc uses_allocator|flat_set}}
 
{{dsc inc|cpp/container/dsc uses_allocator|flat_multiset}}
 
{{dsc inc|cpp/container/dsc uses_allocator|flat_multiset}}
Line 16: Line 15:
 
{{dsc inc|cpp/container/dsc erase_if|flat_set}}
 
{{dsc inc|cpp/container/dsc erase_if|flat_set}}
 
{{dsc inc|cpp/container/dsc erase_if|flat_multiset}}
 
{{dsc inc|cpp/container/dsc erase_if|flat_multiset}}
{{dsc h1|Constants}}
+
{{dsc h1|Tags}}
 
{{dsc inc|cpp/container/dsc sorted_unique}}
 
{{dsc inc|cpp/container/dsc sorted_unique}}
 
{{dsc inc|cpp/container/dsc sorted_equivalent}}
 
{{dsc inc|cpp/container/dsc sorted_equivalent}}
Line 22: Line 21:
  
 
===Synopsis===
 
===Synopsis===
{{source|1=
+
{{cpp/synopsis/flat_set}}
#include <initializer_list>
+
 
+
namespace std {
+
  // class template flat_set
+
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
+
    class flat_set;
+
 
+
  struct sorted_unique_t { explicit sorted_unique_t() = default; };
+
  inline constexpr sorted_unique_t sorted_unique{};
+
 
+
  template<class Key, class Compare, class KeyContainer, class Predicate>
+
    size_t erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred);
+
 
+
  template<class Key, class Compare, class KeyContainer, class Allocator>
+
    struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>;
+
 
+
  // class template flat_multiset
+
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
+
    class flat_multiset;
+
 
+
  struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; };
+
  inline constexpr sorted_equivalent_t sorted_equivalent{};
+
 
+
  template<class Key, class Compare, class KeyContainer, class Predicate>
+
    size_t erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred);
+
 
+
  template<class Key, class Compare, class KeyContainer, class Allocator>
+
    struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>;
+
}
+
}}
+
 
+
====Class template {{lc|std::flat_set}}====
+
{{source|1=
+
namespace std {
+
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
+
  class flat_set {
+
  public:
+
    // types
+
    using key_type                  = Key;
+
    using value_type                = Key;
+
    using key_compare              = Compare;
+
    using value_compare            = Compare;
+
    using reference                = value_type&;
+
    using const_reference          = const value_type&;
+
    using size_type                = typename KeyContainer::size_type;
+
    using difference_type          = typename KeyContainer::difference_type;
+
    using iterator                  = /* implementation-defined */;
+
    using const_iterator            = /* implementation-defined */;
+
    using reverse_iterator          = std::reverse_iterator<iterator>;
+
    using const_reverse_iterator    = std::reverse_iterator<const_iterator>;
+
    using container_type            = KeyContainer;
+
 
+
    // constructors
+
    flat_set() : flat_set(key_compare()) { }
+
 
+
    explicit flat_set(container_type cont);
+
    template<class Allocator>
+
      flat_set(const container_type& cont, const Allocator& a);
+
 
+
    flat_set(sorted_unique_t, container_type cont)
+
      : c(std::move(cont)), compare(key_compare()) { }
+
    template<class Allocator>
+
      flat_set(sorted_unique_t, const container_type& cont, const Allocator& a);
+
 
+
    explicit flat_set(const key_compare& comp)
+
      : c(), compare(comp) { }
+
    template<class Allocator>
+
      flat_set(const key_compare& comp, const Allocator& a);
+
    template<class Allocator>
+
      explicit flat_set(const Allocator& a);
+
 
+
    template<class InputIterator>
+
      flat_set(InputIterator first, InputIterator last,
+
              const key_compare& comp = key_compare())
+
        : c(), compare(comp)
+
        { insert(first, last); }
+
    template<class InputIterator, class Allocator>
+
      flat_set(InputIterator first, InputIterator last,
+
              const key_compare& comp, const Allocator& a);
+
    template<class InputIterator, class Allocator>
+
      flat_set(InputIterator first, InputIterator last, const Allocator& a);
+
 
+
    template</*container-compatible-range*/<value_type> R>
+
      flat_set(from_range_t fr, R&& rg)
+
        : flat_set(fr, std::forward<R>(range), key_compare()) { }
+
    template</*container-compatible-range*/<value_type> R, class Allocator>
+
      flat_set(from_range_t, R&& rg, const Allocator& a);
+
    template</*container-compatible-range*/<value_type> R>
+
      flat_set(from_range_t, R&& rg, const key_compare& comp)
+
        : flat_set(comp)
+
        { insert_range(std::forward<R>(range)); }
+
    template</*container-compatible-range*/<value_type> R, class Allocator>
+
      flat_set(from_range_t, R&& rg, const key_compare& comp,
+
                const Allocator& a);
+
 
+
    template<class InputIterator>
+
      flat_set(sorted_unique_t, InputIterator first, InputIterator last,
+
              const key_compare& comp = key_compare())
+
        : c(first, last), compare(comp) { }
+
    template<class InputIterator, class Allocator>
+
      flat_set(sorted_unique_t, InputIterator first, InputIterator last,
+
              const key_compare& comp, const Allocator& a);
+
    template<class InputIterator, class Allocator>
+
      flat_set(sorted_unique_t, InputIterator first, InputIterator last,
+
              const Allocator& a);
+
 
+
    flat_set(initializer_list<key_type> il,
+
            const key_compare& comp = key_compare())
+
        : flat_set(il.begin(), il.end(), comp) { }
+
    template<class Allocator>
+
      flat_set(initializer_list<key_type> il,
+
              const key_compare& comp, const Allocator& a);
+
    template<class Allocator>
+
      flat_set(initializer_list<key_type> il, const Allocator& a);
+
 
+
    flat_set(sorted_unique_t s, initializer_list<key_type> il,
+
            const key_compare& comp = key_compare())
+
        : flat_set(s, il.begin(), il.end(), comp) { }
+
    template<class Allocator>
+
      flat_set(sorted_unique_t, initializer_list<key_type> il,
+
              const key_compare& comp, const Allocator& a);
+
    template<class Allocator>
+
      flat_set(sorted_unique_t, initializer_list<key_type> il,
+
              const Allocator& a);
+
 
+
    flat_set& operator=(initializer_list<key_type>);
+
 
+
    // iterators
+
    iterator              begin() noexcept;
+
    const_iterator        begin() const noexcept;
+
    iterator              end() noexcept;
+
    const_iterator        end() const noexcept;
+
 
+
    reverse_iterator      rbegin() noexcept;
+
    const_reverse_iterator rbegin() const noexcept;
+
    reverse_iterator      rend() noexcept;
+
    const_reverse_iterator rend() const noexcept;
+
 
+
    const_iterator        cbegin() const noexcept;
+
    const_iterator        cend() const noexcept;
+
    const_reverse_iterator crbegin() const noexcept;
+
    const_reverse_iterator crend() const noexcept;
+
 
+
    // capacity
+
    [[nodiscard]] bool empty() const noexcept;
+
    size_type size() const noexcept;
+
    size_type max_size() const noexcept;
+
 
+
    // modifiers
+
    template<class... Args> pair<iterator, bool> emplace(Args&&... args);
+
    template<class... Args>
+
      iterator emplace_hint(const_iterator position, Args&&... args);
+
 
+
    pair<iterator, bool> insert(const value_type& x)
+
      { return emplace(x); }
+
    pair<iterator, bool> insert(value_type&& x)
+
      { return emplace(std::move(x)); }
+
    template<class K> pair<iterator, bool> insert(K&& x);
+
    iterator insert(const_iterator position, const value_type& x)
+
      { return emplace_hint(position, x); }
+
    iterator insert(const_iterator position, value_type&& x)
+
      { return emplace_hint(position, std::move(x)); }
+
    template<class K> iterator insert(const_iterator hint, K&& x);
+
 
+
    template<class InputIterator>
+
      void insert(InputIterator first, InputIterator last);
+
    template<class InputIterator>
+
      void insert(sorted_unique_t, InputIterator first, InputIterator last);
+
    template</*container-compatible-range*/<value_type> R>
+
      void insert_range(R&& rg);
+
 
+
    void insert(initializer_list<key_type> il)
+
      { insert(il.begin(), il.end()); }
+
    void insert(sorted_unique_t s, initializer_list<key_type> il)
+
      { insert(s, il.begin(), il.end()); }
+
 
+
    container_type extract() &&;
+
    void replace(container_type&&);
+
 
+
    iterator erase(iterator position);
+
    iterator erase(const_iterator position);
+
    size_type erase(const key_type& x);
+
    template<class K> size_type erase(K&& x);
+
    iterator erase(const_iterator first, const_iterator last);
+
 
+
    void swap(flat_set& y) noexcept;
+
    void clear() noexcept;
+
 
+
    // observers
+
    key_compare key_comp() const;
+
    value_compare value_comp() const;
+
 
+
    // set operations
+
    iterator find(const key_type& x);
+
    const_iterator find(const key_type& x) const;
+
    template<class K> iterator find(const K& x);
+
    template<class K> const_iterator find(const K& x) const;
+
 
+
    size_type count(const key_type& x) const;
+
    template<class K> size_type count(const K& x) const;
+
 
+
    bool contains(const key_type& x) const;
+
    template<class K> bool contains(const K& x) const;
+
 
+
    iterator lower_bound(const key_type& x);
+
    const_iterator lower_bound(const key_type& x) const;
+
    template<class K> iterator lower_bound(const K& x);
+
    template<class K> const_iterator lower_bound(const K& x) const;
+
 
+
    iterator upper_bound(const key_type& x);
+
    const_iterator upper_bound(const key_type& x) const;
+
    template<class K> iterator upper_bound(const K& x);
+
    template<class K> const_iterator upper_bound(const K& x) const;
+
 
+
    pair<iterator, iterator> equal_range(const key_type& x);
+
    pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
+
    template<class K>
+
      pair<iterator, iterator> equal_range(const K& x);
+
    template<class K>
+
      pair<const_iterator, const_iterator> equal_range(const K& x) const;
+
 
+
    friend bool operator==(const flat_set& x, const flat_set& y);
+
 
+
    friend /*synth-three-way-result*/<value_type>
+
      operator<=>(const flat_set& x, const flat_set& y);
+
 
+
    friend void swap(flat_set& x, flat_set& y) noexcept { x.swap(y); }
+
 
+
  private:
+
    container_type c;          // exposition only
+
    key_compare compare;        // exposition only
+
  };
+
 
+
  template<class InputIterator, class Compare = less</*iter-value-type*/<InputIterator>>>
+
    flat_set(InputIterator, InputIterator, Compare = Compare())
+
      -> flat_set</*iter-value-type*/<InputIterator>, Compare>;
+
 
+
  template<class InputIterator, class Compare = less</*iter-value-type*/<InputIterator>>>
+
    flat_set(sorted_unique_t, InputIterator, InputIterator, Compare = Compare())
+
      -> flat_set</*iter-value-type*/<InputIterator>, Compare>;
+
 
+
  template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
+
          class Allocator = allocator<ranges::range_value_t<R>>>
+
    flat_set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
+
      -> flat_set<ranges::range_value_t<R>, Compare>;
+
 
+
  template<ranges::input_range R, class Allocator>
+
    flat_set(from_range_t, R&&, Allocator)
+
      -> flat_set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>>;
+
 
+
  template<class Key, class Compare = less<Key>>
+
    flat_set(initializer_list<Key>, Compare = Compare())
+
      -> flat_set<Key, Compare>;
+
 
+
  template<class Key, class Compare = less<Key>>
+
    flat_set(sorted_unique_t, initializer_list<Key>, Compare = Compare())
+
      -> flat_set<Key, Compare>;
+
 
+
  template<class Key, class Compare, class KeyContainer, class Allocator>
+
    struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>
+
      : bool_constant<uses_allocator_v<KeyContainer, Allocator>> { };
+
}
+
}}
+
 
+
====Class template {{lc|std::flat_multiset}}====
+
{{source|1=
+
namespace std {
+
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
+
  class flat_multiset {
+
  public:
+
    // types
+
    using key_type                  = Key;
+
    using value_type                = Key;
+
    using key_compare              = Compare;
+
    using value_compare            = Compare;
+
    using reference                = value_type&;
+
    using const_reference          = const value_type&;
+
    using size_type                = typename KeyContainer::size_type;
+
    using difference_type          = typename KeyContainer::difference_type;
+
    using iterator                  = /* implementation-defined */;
+
    using const_iterator            = /* implementation-defined */;
+
    using reverse_iterator          = std::reverse_iterator<iterator>;
+
    using const_reverse_iterator    = std::reverse_iterator<const_iterator>;
+
    using container_type            = KeyContainer;
+
 
+
    // constructors
+
    flat_multiset() : flat_multiset(key_compare()) { }
+
 
+
    explicit flat_multiset(container_type cont);
+
    template<class Allocator>
+
      flat_multiset(const container_type& cont, const Allocator& a);
+
 
+
    flat_multiset(sorted_equivalent_t, container_type cont)
+
      : c(std::move(cont)), compare(key_compare()) { }
+
    template<class Allocator>
+
      flat_multiset(sorted_equivalent_t, const container_type&, const Allocator& a);
+
 
+
    explicit flat_multiset(const key_compare& comp)
+
      : c(), compare(comp) { }
+
    template<class Allocator>
+
      flat_multiset(const key_compare& comp, const Allocator& a);
+
    template<class Allocator>
+
      explicit flat_multiset(const Allocator& a);
+
 
+
    template<class InputIterator>
+
      flat_multiset(InputIterator first, InputIterator last,
+
                    const key_compare& comp = key_compare())
+
        : c(), compare(comp)
+
        { insert(first, last); }
+
    template<class InputIterator, class Allocator>
+
      flat_multiset(InputIterator first, InputIterator last,
+
                    const key_compare& comp, const Allocator& a);
+
    template<class InputIterator, class Allocator>
+
      flat_multiset(InputIterator first, InputIterator last,
+
                    const Allocator& a);
+
 
+
    template</*container-compatible-range*/<value_type> R>
+
      flat_multiset(from_range_t fr, R&& rg)
+
        : flat_multiset(fr, std::forward<R>(range), key_compare()) { }
+
    template</*container-compatible-range*/<value_type> R, class Allocator>
+
      flat_multiset(from_range_t, R&& rg, const Allocator& a);
+
    template</*container-compatible-range*/<value_type> R>
+
      flat_multiset(from_range_t, R&& rg, const key_compare& comp)
+
        : flat_multiset(comp)
+
        { insert_range(std::forward<R>(range)); }
+
    template</*container-compatible-range*/<value_type> R, class Allocator>
+
      flat_multiset(from_range_t, R&& rg, const key_compare& comp,
+
                    const Allocator& a);
+
 
+
    template<class InputIterator>
+
      flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last,
+
                    const key_compare& comp = key_compare())
+
        : c(first, last), compare(comp) { }
+
    template<class InputIterator, class Allocator>
+
      flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last,
+
                    const key_compare& comp, const Allocator& a);
+
    template<class InputIterator, class Allocator>
+
      flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last,
+
                    const Allocator& a);
+
 
+
    flat_multiset(initializer_list<key_type> il,
+
                  const key_compare& comp = key_compare())
+
      : flat_multiset(il.begin(), il.end(), comp) { }
+
    template<class Allocator>
+
      flat_multiset(initializer_list<key_type> il,
+
                    const key_compare& comp, const Allocator& a);
+
    template<class Allocator>
+
      flat_multiset(initializer_list<key_type> il, const Allocator& a);
+
 
+
    flat_multiset(sorted_equivalent_t s, initializer_list<key_type> il,
+
                  const key_compare& comp = key_compare())
+
        : flat_multiset(s, il.begin(), il.end(), comp) { }
+
    template<class Allocator>
+
      flat_multiset(sorted_equivalent_t, initializer_list<key_type> il,
+
                    const key_compare& comp, const Allocator& a);
+
    template<class Allocator>
+
      flat_multiset(sorted_equivalent_t, initializer_list<key_type> il,
+
                    const Allocator& a);
+
 
+
    flat_multiset& operator=(initializer_list<key_type>);
+
 
+
    // iterators
+
    iterator              begin() noexcept;
+
    const_iterator        begin() const noexcept;
+
    iterator              end() noexcept;
+
    const_iterator        end() const noexcept;
+
 
+
    reverse_iterator      rbegin() noexcept;
+
    const_reverse_iterator rbegin() const noexcept;
+
    reverse_iterator      rend() noexcept;
+
    const_reverse_iterator rend() const noexcept;
+
 
+
    const_iterator        cbegin() const noexcept;
+
    const_iterator        cend() const noexcept;
+
    const_reverse_iterator crbegin() const noexcept;
+
    const_reverse_iterator crend() const noexcept;
+
 
+
    // capacity
+
    [[nodiscard]] bool empty() const noexcept;
+
    size_type size() const noexcept;
+
    size_type max_size() const noexcept;
+
 
+
    // modifiers
+
    template<class... Args> iterator emplace(Args&&... args);
+
    template<class... Args>
+
      iterator emplace_hint(const_iterator position, Args&&... args);
+
 
+
    iterator insert(const value_type& x)
+
      { return emplace(x); }
+
    iterator insert(value_type&& x)
+
      { return emplace(std::move(x)); }
+
    iterator insert(const_iterator position, const value_type& x)
+
      { return emplace_hint(position, x); }
+
    iterator insert(const_iterator position, value_type&& x)
+
      { return emplace_hint(position, std::move(x)); }
+
 
+
    template<class InputIterator>
+
      void insert(InputIterator first, InputIterator last);
+
    template<class InputIterator>
+
      void insert(sorted_equivalent_t, InputIterator first, InputIterator last);
+
    template</*container-compatible-range*/<value_type> R>
+
      void insert_range(R&& rg);
+
 
+
    void insert(initializer_list<key_type> il)
+
      { insert(il.begin(), il.end()); }
+
    void insert(sorted_equivalent_t s, initializer_list<key_type> il)
+
      { insert(s, il.begin(), il.end()); }
+
 
+
    container_type extract() &&;
+
    void replace(container_type&&);
+
 
+
    iterator erase(iterator position);
+
    iterator erase(const_iterator position);
+
    size_type erase(const key_type& x);
+
    template<class K> size_type erase(K&& x);
+
    iterator erase(const_iterator first, const_iterator last);
+
 
+
    void swap(flat_multiset& y) noexcept;
+
    void clear() noexcept;
+
 
+
    // observers
+
    key_compare key_comp() const;
+
    value_compare value_comp() const;
+
 
+
    // set operations
+
    iterator find(const key_type& x);
+
    const_iterator find(const key_type& x) const;
+
    template<class K> iterator find(const K& x);
+
    template<class K> const_iterator find(const K& x) const;
+
 
+
    size_type count(const key_type& x) const;
+
    template<class K> size_type count(const K& x) const;
+
 
+
    bool contains(const key_type& x) const;
+
    template<class K> bool contains(const K& x) const;
+
 
+
    iterator lower_bound(const key_type& x);
+
    const_iterator lower_bound(const key_type& x) const;
+
    template<class K> iterator lower_bound(const K& x);
+
    template<class K> const_iterator lower_bound(const K& x) const;
+
 
+
    iterator upper_bound(const key_type& x);
+
    const_iterator upper_bound(const key_type& x) const;
+
    template<class K> iterator upper_bound(const K& x);
+
    template<class K> const_iterator upper_bound(const K& x) const;
+
 
+
    pair<iterator, iterator> equal_range(const key_type& x);
+
    pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
+
    template<class K>
+
      pair<iterator, iterator> equal_range(const K& x);
+
    template<class K>
+
      pair<const_iterator, const_iterator> equal_range(const K& x) const;
+
 
+
    friend bool operator==(const flat_multiset& x, const flat_multiset& y);
+
 
+
    friend /*synth-three-way-result*/<value_type>
+
      operator<=>(const flat_multiset& x, const flat_multiset& y);
+
 
+
    friend void swap(flat_multiset& x, flat_multiset& y) noexcept
+
      { x.swap(y); }
+
 
+
  private:
+
    container_type c;      // exposition only
+
    key_compare compare;    // exposition only
+
  };
+
 
+
  template<class InputIterator, class Compare = less</*iter-value-type*/<InputIterator>>>
+
    flat_multiset(InputIterator, InputIterator, Compare = Compare())
+
      -> flat_multiset</*iter-value-type*/<InputIterator>,
+
                      /*iter-value-type*/<InputIterator>,
+
                      Compare>;
+
 
+
  template<class InputIterator, class Compare = less</*iter-value-type*/<InputIterator>>>
+
    flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, Compare = Compare())
+
      -> flat_multiset</*iter-value-type*/<InputIterator>,
+
                      /*iter-value-type*/<InputIterator>, Compare>;
+
 
+
  template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
+
          class Allocator = allocator<ranges::range_value_t<R>>>
+
    flat_multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
+
      -> flat_multiset<ranges::range_value_t<R>, Compare>;
+
 
+
  template<ranges::input_range R, class Allocator>
+
    flat_multiset(from_range_t, R&&, Allocator)
+
      -> flat_multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>>;
+
 
+
  template<class Key, class Compare = less<Key>>
+
    flat_multiset(initializer_list<Key>, Compare = Compare())
+
      -> flat_multiset<Key, Compare>;
+
 
+
  template<class Key, class Compare = less<Key>>
+
  flat_multiset(sorted_equivalent_t, initializer_list<Key>, Compare = Compare())
+
      -> flat_multiset<Key, Compare>;
+
 
+
  template<class Key, class Compare, class KeyContainer, class Allocator>
+
    struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>
+
      : bool_constant<uses_allocator_v<KeyContainer, Allocator>> { };
+
}
+
}}
+
  
 
===References===
 
===References===

Latest revision as of 12:19, 24 December 2023

 
 
Standard library headers
General utilities
<any> (C++17)
<bitset>
<bit> (C++20)
<charconv> (C++17)
<expected> (C++23)
<format> (C++20)
<functional>
<optional> (C++17)
<tuple> (C++11)
<typeindex> (C++11)
<utility>
<variant> (C++17)
Containers
<array> (C++11)
<deque>
<flat_map> (C++23)
<flat_set> (C++23)
<forward_list> (C++11)
<inplace_vector> (C++26)   
<list>
<map>
<mdspan> (C++23)
<queue>
<set>
<span> (C++20)
<stack>
<unordered_map> (C++11)
<unordered_set> (C++11)
<vector>
Iterators
<iterator>
Ranges
<generator> (C++23)
<ranges> (C++20)
 

This header is part of the containers library.

Contents

Includes

(C++20)
Three-way comparison operator support[edit]
std::initializer_list class template[edit]

Classes

(C++23)
adapts a container to provide a collection of unique keys, sorted by keys
(class template) [edit]
adapts a container to provide a collection of keys, sorted by keys
(class template) [edit]
specializes the std::uses_allocator type trait
(class template specialization) [edit]
specializes the std::uses_allocator type trait
(class template specialization) [edit]

Functions

erases all elements satisfying specific criteria
(function template) [edit]
erases all elements satisfying specific criteria
(function template) [edit]

Tags

indicates that elements of a range are sorted and unique
(tag)[edit]
indicates that elements of a range are sorted (uniqueness is not required)
(tag)[edit]

[edit] Synopsis

#include <compare>
#include <initializer_list>
 
namespace std {
  // class template flat_set
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
  class flat_set;
 
  struct sorted_unique_t
  {
    explicit sorted_unique_t() = default;
  };
  inline constexpr sorted_unique_t sorted_unique{};
 
  template<class Key, class Compare, class KeyContainer, class Allocator>
  struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>;
 
  // erasure for flat_set
  template<class Key, class Compare, class KeyContainer, class Predicate>
  typename flat_set<Key, Compare, KeyContainer>::size_type erase_if(
    flat_set<Key, Compare, KeyContainer>& c,
    Predicate pred);
 
  // class template flat_multiset
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
  class flat_multiset;
 
  struct sorted_equivalent_t
  {
    explicit sorted_equivalent_t() = default;
  };
  inline constexpr sorted_equivalent_t sorted_equivalent{};
 
  template<class Key, class Compare, class KeyContainer, class Allocator>
  struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>;
 
  // erasure for flat_multiset
  template<class Key, class Compare, class KeyContainer, class Predicate>
  typename flat_multiset<Key, Compare, KeyContainer>::size_type erase_if(
    flat_multiset<Key, Compare, KeyContainer>& c,
    Predicate pred);
}

[edit] Class template std::flat_set

namespace std {
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
  class flat_set
  {
  public:
    // types
    using key_type               = Key;
    using value_type             = Key;
    using key_compare            = Compare;
    using value_compare          = Compare;
    using reference              = value_type&;
    using const_reference        = const value_type&;
    using size_type              = typename KeyContainer::size_type;
    using difference_type        = typename KeyContainer::difference_type;
    using iterator               = /* implementation-defined */;
    using const_iterator         = /* implementation-defined */;
    using reverse_iterator       = std::reverse_iterator<iterator>;
    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
    using container_type         = KeyContainer;
 
    // constructors
    flat_set()
      : flat_set(key_compare())
    {
    }
 
    explicit flat_set(const key_compare& comp)
      : /*c*/()
      , /*compare*/(comp)
    {
    }
 
    explicit flat_set(container_type cont, const key_compare& comp = key_compare());
 
    flat_set(sorted_unique_t,
             container_type cont,
             const key_compare& comp = key_compare())
      : /*c*/(std::move(cont))
      , /*compare*/(comp)
    {
    }
 
    template<class InputIter>
    flat_set(InputIter first, InputIter last, const key_compare& comp = key_compare())
      : /*c*/()
      , /*compare*/(comp)
    {
      insert(first, last);
    }
 
    template<class InputIter>
    flat_set(sorted_unique_t,
             InputIter first,
             InputIter last,
             const key_compare& comp = key_compare())
      : /*c*/(first, last)
      , /*compare*/(comp)
    {
    }
 
    template<container-compatible-range<value_type> R>
    flat_set(from_range_t fr, R&& rg)
      : flat_set(fr, std::forward<R>(rg), key_compare())
    {
    }
    template<container-compatible-range<value_type> R>
    flat_set(from_range_t, R&& rg, const key_compare& comp)
      : flat_set(comp)
    {
      insert_range(std::forward<R>(rg));
    }
 
    flat_set(initializer_list<value_type> il, const key_compare& comp = key_compare())
      : flat_set(il.begin(), il.end(), comp)
    {
    }
 
    flat_set(sorted_unique_t s,
             initializer_list<value_type> il,
             const key_compare& comp = key_compare())
      : flat_set(s, il.begin(), il.end(), comp)
    {
    }
 
    // constructors with allocators
 
    template<class Alloc>
    explicit flat_set(const Alloc& a);
    template<class Alloc>
    flat_set(const key_compare& comp, const Alloc& a);
    template<class Alloc>
    flat_set(const container_type& cont, const Alloc& a);
    template<class Alloc>
    flat_set(const container_type& cont, const key_compare& comp, const Alloc& a);
    template<class Alloc>
    flat_set(sorted_unique_t, const container_type& cont, const Alloc& a);
    template<class Alloc>
    flat_set(sorted_unique_t,
             const container_type& cont,
             const key_compare& comp,
             const Alloc& a);
    template<class Alloc>
    flat_set(const flat_set&, const Alloc& a);
    template<class Alloc>
    flat_set(flat_set&&, const Alloc& a);
    template<class InputIter, class Alloc>
    flat_set(InputIter first, InputIter last, const Alloc& a);
    template<class InputIter, class Alloc>
    flat_set(InputIter first, InputIter last, const key_compare& comp, const Alloc& a);
    template<class InputIter, class Alloc>
    flat_set(sorted_unique_t, InputIter first, InputIter last, const Alloc& a);
    template<class InputIter, class Alloc>
    flat_set(sorted_unique_t,
             InputIter first,
             InputIter last,
             const key_compare& comp,
             const Alloc& a);
    template<container-compatible-range<value_type> R, class Alloc>
    flat_set(from_range_t, R&& rg, const Alloc& a);
    template<container-compatible-range<value_type> R, class Alloc>
    flat_set(from_range_t, R&& rg, const key_compare& comp, const Alloc& a);
    template<class Alloc>
    flat_set(initializer_list<value_type> il, const Alloc& a);
    template<class Alloc>
    flat_set(initializer_list<value_type> il, const key_compare& comp, const Alloc& a);
    template<class Alloc>
    flat_set(sorted_unique_t, initializer_list<value_type> il, const Alloc& a);
    template<class Alloc>
    flat_set(sorted_unique_t,
             initializer_list<value_type> il,
             const key_compare& comp,
             const Alloc& a);
 
    flat_set& operator=(initializer_list<value_type>);
 
    // iterators
    iterator begin() noexcept;
    const_iterator begin() const noexcept;
    iterator end() noexcept;
    const_iterator end() const noexcept;
 
    reverse_iterator rbegin() noexcept;
    const_reverse_iterator rbegin() const noexcept;
    reverse_iterator rend() noexcept;
    const_reverse_iterator rend() const noexcept;
 
    const_iterator cbegin() const noexcept;
    const_iterator cend() const noexcept;
    const_reverse_iterator crbegin() const noexcept;
    const_reverse_iterator crend() const noexcept;
 
    // capacity
    [[nodiscard]] bool empty() const noexcept;
    size_type size() const noexcept;
    size_type max_size() const noexcept;
 
    // modifiers
    template<class... Args>
    pair<iterator, bool> emplace(Args&&... args);
    template<class... Args>
    iterator emplace_hint(const_iterator position, Args&&... args);
 
    pair<iterator, bool> insert(const value_type& x) { return emplace(x); }
    pair<iterator, bool> insert(value_type&& x) { return emplace(std::move(x)); }
    template<class K>
    pair<iterator, bool> insert(K&& x);
    iterator insert(const_iterator position, const value_type& x)
    {
      return emplace_hint(position, x);
    }
    iterator insert(const_iterator position, value_type&& x)
    {
      return emplace_hint(position, std::move(x));
    }
    template<class K>
    iterator insert(const_iterator hint, K&& x);
 
    template<class InputIter>
    void insert(InputIter first, InputIter last);
    template<class InputIter>
    void insert(sorted_unique_t, InputIter first, InputIter last);
    template<container-compatible-range<value_type> R>
    void insert_range(R&& rg);
 
    void insert(initializer_list<value_type> il) { insert(il.begin(), il.end()); }
    void insert(sorted_unique_t s, initializer_list<value_type> il)
    {
      insert(s, il.begin(), il.end());
    }
 
    container_type extract() &&;
    void replace(container_type&&);
 
    iterator erase(iterator position);
    iterator erase(const_iterator position);
    size_type erase(const key_type& x);
    template<class K>
    size_type erase(K&& x);
    iterator erase(const_iterator first, const_iterator last);
 
    void swap(flat_set& y) noexcept;
    void clear() noexcept;
 
    // observers
    key_compare key_comp() const;
    value_compare value_comp() const;
 
    // set operations
    iterator find(const key_type& x);
    const_iterator find(const key_type& x) const;
    template<class K>
    iterator find(const K& x);
    template<class K>
    const_iterator find(const K& x) const;
 
    size_type count(const key_type& x) const;
    template<class K>
    size_type count(const K& x) const;
 
    bool contains(const key_type& x) const;
    template<class K>
    bool contains(const K& x) const;
 
    iterator lower_bound(const key_type& x);
    const_iterator lower_bound(const key_type& x) const;
    template<class K>
    iterator lower_bound(const K& x);
    template<class K>
    const_iterator lower_bound(const K& x) const;
 
    iterator upper_bound(const key_type& x);
    const_iterator upper_bound(const key_type& x) const;
    template<class K>
    iterator upper_bound(const K& x);
    template<class K>
    const_iterator upper_bound(const K& x) const;
 
    pair<iterator, iterator> equal_range(const key_type& x);
    pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
    template<class K>
    pair<iterator, iterator> equal_range(const K& x);
    template<class K>
    pair<const_iterator, const_iterator> equal_range(const K& x) const;
 
    friend bool operator==(const flat_set& x, const flat_set& y);
 
    friend /*synth-three-way-result*/<value_type> operator<=>(const flat_set& x,
                                                              const flat_set& y);
 
    friend void swap(flat_set& x, flat_set& y) noexcept { x.swap(y); }
 
  private:
    container_type /*c*/;    // exposition only
    key_compare /*compare*/; // exposition only
  };
 
  template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
  flat_set(KeyContainer, Compare = Compare())
    -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
  template<class KeyContainer, class Allocator>
  flat_set(KeyContainer, Allocator) -> flat_set<typename KeyContainer::value_type,
                                                less<typename KeyContainer::value_type>,
                                                KeyContainer>;
  template<class KeyContainer, class Compare, class Allocator>
  flat_set(KeyContainer, Compare, Allocator)
    -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
 
  template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
  flat_set(sorted_unique_t, KeyContainer, Compare = Compare())
    -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
  template<class KeyContainer, class Allocator>
  flat_set(sorted_unique_t, KeyContainer, Allocator)
    -> flat_set<typename KeyContainer::value_type,
                less<typename KeyContainer::value_type>,
                KeyContainer>;
  template<class KeyContainer, class Compare, class Allocator>
  flat_set(sorted_unique_t, KeyContainer, Compare, Allocator)
    -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
 
  template<class InputIter, class Compare = less</*iter-value-type*/<InputIter>>>
  flat_set(InputIter, InputIter, Compare = Compare())
    -> flat_set</*iter-value-type*/<InputIter>, Compare>;
 
  template<class InputIter, class Compare = less</*iter-value-type*/<InputIter>>>
  flat_set(sorted_unique_t, InputIter, InputIter, Compare = Compare())
    -> flat_set</*iter-value-type*/<InputIter>, Compare>;
 
  template<ranges::input_range R,
           class Compare   = less<ranges::range_value_t<R>>,
           class Allocator = allocator<ranges::range_value_t<R>>>
  flat_set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
    -> flat_set<ranges::range_value_t<R>,
                Compare,
                vector<ranges::range_value_t<R>,
                       /*alloc-rebind*/<Allocator, ranges::range_value_t<R>>>>;
 
  template<ranges::input_range R, class Allocator>
  flat_set(from_range_t, R&&, Allocator)
    -> flat_set<ranges::range_value_t<R>,
                less<ranges::range_value_t<R>>,
                vector<ranges::range_value_t<R>,
                       /*alloc-rebind*/<Allocator, ranges::range_value_t<R>>>>;
 
  template<class Key, class Compare = less<Key>>
  flat_set(initializer_list<Key>, Compare = Compare()) -> flat_set<Key, Compare>;
 
  template<class Key, class Compare = less<Key>>
  flat_set(sorted_unique_t, initializer_list<Key>, Compare = Compare())
    -> flat_set<Key, Compare>;
 
  template<class Key, class Compare, class KeyContainer, class Allocator>
  struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>
    : bool_constant<uses_allocator_v<KeyContainer, Allocator>>
  {};
}

[edit] Class template std::flat_multiset

namespace std {
  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
  class flat_multiset
  {
  public:
    // types
    using key_type               = Key;
    using value_type             = Key;
    using key_compare            = Compare;
    using value_compare          = Compare;
    using reference              = value_type&;
    using const_reference        = const value_type&;
    using size_type              = typename KeyContainer::size_type;
    using difference_type        = typename KeyContainer::difference_type;
    using iterator               = /* implementation-defined */;
    using const_iterator         = /* implementation-defined */;
    using reverse_iterator       = std::reverse_iterator<iterator>;
    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
    using container_type         = KeyContainer;
 
    // constructors
    flat_multiset()
      : flat_multiset(key_compare())
    {
    }
 
    explicit flat_multiset(const key_compare& comp)
      : /*c*/()
      , /*compare*/(comp)
    {
    }
 
    explicit flat_multiset(container_type cont, const key_compare& comp = key_compare());
 
    flat_multiset(sorted_equivalent_t,
                  container_type cont,
                  const key_compare& comp = key_compare())
      : /*c*/(std::move(cont))
      , /*compare*/(comp)
    {
    }
 
    template<class InputIter>
    flat_multiset(InputIter first,
                  InputIter last,
                  const key_compare& comp = key_compare())
      : /*c*/()
      , /*compare*/(comp)
    {
      insert(first, last);
    }
 
    template<class InputIter>
    flat_multiset(sorted_equivalent_t,
                  InputIter first,
                  InputIter last,
                  const key_compare& comp = key_compare())
      : /*c*/(first, last)
      , /*compare*/(comp)
    {
    }
 
    template<container-compatible-range<value_type> R>
    flat_multiset(from_range_t fr, R&& rg)
      : flat_multiset(fr, std::forward<R>(rg), key_compare())
    {
    }
    template<container-compatible-range<value_type> R>
    flat_multiset(from_range_t, R&& rg, const key_compare& comp)
      : flat_multiset(comp)
    {
      insert_range(std::forward<R>(rg));
    }
 
    flat_multiset(initializer_list<value_type> il,
                  const key_compare& comp = key_compare())
      : flat_multiset(il.begin(), il.end(), comp)
    {
    }
 
    flat_multiset(sorted_equivalent_t s,
                  initializer_list<value_type> il,
                  const key_compare& comp = key_compare())
      : flat_multiset(s, il.begin(), il.end(), comp)
    {
    }
 
    // constructors with allocators
 
    template<class Alloc>
    explicit flat_multiset(const Alloc& a);
    template<class Alloc>
    flat_multiset(const key_compare& comp, const Alloc& a);
    template<class Alloc>
    flat_multiset(const container_type& cont, const Alloc& a);
    template<class Alloc>
    flat_multiset(const container_type& cont, const key_compare& comp, const Alloc& a);
    template<class Alloc>
    flat_multiset(sorted_equivalent_t, const container_type& cont, const Alloc& a);
    template<class Alloc>
    flat_multiset(sorted_equivalent_t,
                  const container_type& cont,
                  const key_compare& comp,
                  const Alloc& a);
    template<class Alloc>
    flat_multiset(const flat_multiset&, const Alloc& a);
    template<class Alloc>
    flat_multiset(flat_multiset&&, const Alloc& a);
    template<class InputIter, class Alloc>
    flat_multiset(InputIter first, InputIter last, const Alloc& a);
    template<class InputIter, class Alloc>
    flat_multiset(InputIter first,
                  InputIter last,
                  const key_compare& comp,
                  const Alloc& a);
    template<class InputIter, class Alloc>
    flat_multiset(sorted_equivalent_t, InputIter first, InputIter last, const Alloc& a);
    template<class InputIter, class Alloc>
    flat_multiset(sorted_equivalent_t,
                  InputIter first,
                  InputIter last,
                  const key_compare& comp,
                  const Alloc& a);
    template<container-compatible-range<value_type> R, class Alloc>
    flat_multiset(from_range_t, R&& rg, const Alloc& a);
    template<container-compatible-range<value_type> R, class Alloc>
    flat_multiset(from_range_t, R&& rg, const key_compare& comp, const Alloc& a);
    template<class Alloc>
    flat_multiset(initializer_list<value_type> il, const Alloc& a);
    template<class Alloc>
    flat_multiset(initializer_list<value_type> il,
                  const key_compare& comp,
                  const Alloc& a);
    template<class Alloc>
    flat_multiset(sorted_equivalent_t, initializer_list<value_type> il, const Alloc& a);
    template<class Alloc>
    flat_multiset(sorted_equivalent_t,
                  initializer_list<value_type> il,
                  const key_compare& comp,
                  const Alloc& a);
 
    flat_multiset& operator=(initializer_list<value_type>);
 
    // iterators
    iterator begin() noexcept;
    const_iterator begin() const noexcept;
    iterator end() noexcept;
    const_iterator end() const noexcept;
 
    reverse_iterator rbegin() noexcept;
    const_reverse_iterator rbegin() const noexcept;
    reverse_iterator rend() noexcept;
    const_reverse_iterator rend() const noexcept;
 
    const_iterator cbegin() const noexcept;
    const_iterator cend() const noexcept;
    const_reverse_iterator crbegin() const noexcept;
    const_reverse_iterator crend() const noexcept;
 
    // capacity
    [[nodiscard]] bool empty() const noexcept;
    size_type size() const noexcept;
    size_type max_size() const noexcept;
 
    // modifiers
    template<class... Args>
    iterator emplace(Args&&... args);
    template<class... Args>
    iterator emplace_hint(const_iterator position, Args&&... args);
 
    iterator insert(const value_type& x) { return emplace(x); }
    iterator insert(value_type&& x) { return emplace(std::move(x)); }
    iterator insert(const_iterator position, const value_type& x)
    {
      return emplace_hint(position, x);
    }
    iterator insert(const_iterator position, value_type&& x)
    {
      return emplace_hint(position, std::move(x));
    }
 
    template<class InputIter>
    void insert(InputIter first, InputIter last);
    template<class InputIter>
    void insert(sorted_equivalent_t, InputIter first, InputIter last);
    template<container-compatible-range<value_type> R>
    void insert_range(R&& rg);
 
    void insert(initializer_list<value_type> il) { insert(il.begin(), il.end()); }
    void insert(sorted_equivalent_t s, initializer_list<value_type> il)
    {
      insert(s, il.begin(), il.end());
    }
 
    container_type extract() &&;
    void replace(container_type&&);
 
    iterator erase(iterator position);
    iterator erase(const_iterator position);
    size_type erase(const key_type& x);
    template<class K>
    size_type erase(K&& x);
    iterator erase(const_iterator first, const_iterator last);
 
    void swap(flat_multiset& y) noexcept;
    void clear() noexcept;
 
    // observers
    key_compare key_comp() const;
    value_compare value_comp() const;
 
    // set operations
    iterator find(const key_type& x);
    const_iterator find(const key_type& x) const;
    template<class K>
    iterator find(const K& x);
    template<class K>
    const_iterator find(const K& x) const;
 
    size_type count(const key_type& x) const;
    template<class K>
    size_type count(const K& x) const;
 
    bool contains(const key_type& x) const;
    template<class K>
    bool contains(const K& x) const;
 
    iterator lower_bound(const key_type& x);
    const_iterator lower_bound(const key_type& x) const;
    template<class K>
    iterator lower_bound(const K& x);
    template<class K>
    const_iterator lower_bound(const K& x) const;
 
    iterator upper_bound(const key_type& x);
    const_iterator upper_bound(const key_type& x) const;
    template<class K>
    iterator upper_bound(const K& x);
    template<class K>
    const_iterator upper_bound(const K& x) const;
 
    pair<iterator, iterator> equal_range(const key_type& x);
    pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
    template<class K>
    pair<iterator, iterator> equal_range(const K& x);
    template<class K>
    pair<const_iterator, const_iterator> equal_range(const K& x) const;
 
    friend bool operator==(const flat_multiset& x, const flat_multiset& y);
 
    friend /*synth-three-way-result*/<value_type> operator<=>(const flat_multiset& x,
                                                              const flat_multiset& y);
 
    friend void swap(flat_multiset& x, flat_multiset& y) noexcept { x.swap(y); }
 
  private:
    container_type /*c*/;    // exposition only
    key_compare /*compare*/; // exposition only
  };
 
  template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
  flat_multiset(KeyContainer, Compare = Compare())
    -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
  template<class KeyContainer, class Allocator>
  flat_multiset(KeyContainer, Allocator)
    -> flat_multiset<typename KeyContainer::value_type,
                     less<typename KeyContainer::value_type>,
                     KeyContainer>;
  template<class KeyContainer, class Compare, class Allocator>
  flat_multiset(KeyContainer, Compare, Allocator)
    -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
 
  template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
  flat_multiset(sorted_equivalent_t, KeyContainer, Compare = Compare())
    -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
  template<class KeyContainer, class Allocator>
  flat_multiset(sorted_equivalent_t, KeyContainer, Allocator)
    -> flat_multiset<typename KeyContainer::value_type,
                     less<typename KeyContainer::value_type>,
                     KeyContainer>;
  template<class KeyContainer, class Compare, class Allocator>
  flat_multiset(sorted_equivalent_t, KeyContainer, Compare, Allocator)
    -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
 
  template<class InputIter, class Compare = less</*iter-value-type*/<InputIter>>>
  flat_multiset(InputIter, InputIter, Compare = Compare())
    -> flat_multiset</*iter-value-type*/<InputIter>, Compare>;
 
  template<class InputIter, class Compare = less</*iter-value-type*/<InputIter>>>
  flat_multiset(sorted_equivalent_t, InputIter, InputIter, Compare = Compare())
    -> flat_multiset</*iter-value-type*/<InputIter>, Compare>;
 
  template<ranges::input_range R,
           class Compare   = less<ranges::range_value_t<R>>,
           class Allocator = allocator<ranges::range_value_t<R>>>
  flat_multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
    -> flat_multiset<ranges::range_value_t<R>,
                     Compare,
                     vector<ranges::range_value_t<R>,
                            /*alloc-rebind*/<Allocator, ranges::range_value_t<R>>>>;
 
  template<ranges::input_range R, class Allocator>
  flat_multiset(from_range_t, R&&, Allocator)
    -> flat_multiset<ranges::range_value_t<R>,
                     less<ranges::range_value_t<R>>,
                     vector<ranges::range_value_t<R>,
                            /*alloc-rebind*/<Allocator, ranges::range_value_t<R>>>>;
 
  template<class Key, class Compare = less<Key>>
  flat_multiset(initializer_list<Key>, Compare = Compare())
    -> flat_multiset<Key, Compare>;
 
  template<class Key, class Compare = less<Key>>
  flat_multiset(sorted_equivalent_t, initializer_list<Key>, Compare = Compare())
    -> flat_multiset<Key, Compare>;
 
  template<class Key, class Compare, class KeyContainer, class Allocator>
  struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>
    : bool_constant<uses_allocator_v<KeyContainer, Allocator>>
  {};
}

[edit] References

  • C++23 standard (ISO/IEC 14882:2024):
  • 24.6.5 Header <flat_set> synopsis [flat.set.syn]
  • 24.6.11.2 Definition [flat.set.defn]
  • 24.6.12.2 Definition [flat.multiset.defn]