STD::__DEBUG::UNORDERED_SET(3)

✨ NAME ✨

okay so bestie, meet std::__debug::unordered_set< _Value, _Hash, _Pred, _Alloc > β€” it's a Class std::unordered_set with safety/checking/debug instrumentation. yes literally the same set you know and love but wearing a hi-vis vest πŸ’…

this is a Library Functions Manual page from libstdc++, so buckle up πŸŽ€


🌸 SYNOPSIS 🌸

#include <unordered_set>

Inherits __gnu_debug::_Safe_container< _SafeContainer, _Alloc, _SafeBase, _IsCxx11AllocatorAware >. yes it's got a whole family tree, main character energy fr fr πŸ‘‘

πŸ’– Public Types

  • typedef _Base::allocator_type allocator_type β€” the allocator type, straight from _Base
  • typedef __gnu_debug::_Safe_iterator< _Base_const_iterator, unordered_set > const_iterator β€” const iterator, but make it safe (it's a _Safe_iterator bestie)
  • typedef __gnu_debug::_Safe_local_iterator< _Base_const_local_iterator, unordered_set > const_local_iterator β€” const local iterator, also safety-instrumented, _Safe_local_iterator coded
  • typedef _Base::const_pointer const_pointer β€” const pointer, from _Base
  • typedef _Base::const_reference const_reference β€” const reference, from _Base
  • typedef _Base::difference_type difference_type β€” difference type, from _Base
  • typedef _Base::hasher hasher β€” the hasher type
  • typedef __gnu_debug::_Safe_iterator< _Base_iterator, unordered_set > iterator β€” the iterator, and yes it's a _Safe_iterator so it's checking on you πŸ‘€
  • typedef _Base::key_equal key_equal β€” key equality predicate type
  • typedef _Base::key_type key_type β€” key type
  • typedef __gnu_debug::_Safe_local_iterator< _Base_local_iterator, unordered_set > local_iterator β€” local iterator, _Safe_local_iterator flavored
  • typedef _Base::pointer pointer β€” pointer
  • typedef _Base::reference reference β€” reference
  • typedef _Base::size_type size_type β€” size type
  • typedef _Base::value_type value_type β€” value type

πŸ¦‹ Public Member Functions

the constructor lineup is honestly giving runway show, there's one for every occasion:

  • unordered_set (_Base_ref __x) β€” builds from a _Base_ref
  • template<typename _InputIterator> unordered_set (_InputIterator __first, _InputIterator __last, const allocator_type &__a) β€” range + allocator
  • template<typename _InputIterator> unordered_set (_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type &__a) β€” range + bucket count + allocator
  • template<typename _InputIterator> unordered_set (_InputIterator __first, _InputIterator __last, size_type __n, const hasher &__hf, const allocator_type &__a) β€” range + bucket count + hasher + allocator
  • template<typename _InputIterator> unordered_set (_InputIterator __first, _InputIterator __last, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type()) β€” the full range version, all defaults baked in
  • unordered_set (const allocator_type &__a) β€” just an allocator
  • unordered_set (const unordered_set &)=default β€” copy ctor, defaulted, iconic
  • unordered_set (const unordered_set &__uset, const allocator_type &__a) β€” copy + allocator
  • unordered_set (initializer_list< value_type > __l, const allocator_type &__a) β€” init list + allocator
  • unordered_set (initializer_list< value_type > __l, size_type __n, const allocator_type &__a) β€” init list + bucket count + allocator
  • unordered_set (initializer_list< value_type > __l, size_type __n, const hasher &__hf, const allocator_type &__a) β€” init list + bucket count + hasher + allocator
  • unordered_set (initializer_list< value_type > __l, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type()) β€” init list, everything defaulted
  • unordered_set (size_type __n, const allocator_type &__a) β€” bucket count + allocator
  • unordered_set (size_type __n, const hasher &__hf, const allocator_type &__a) β€” bucket count + hasher + allocator
  • unordered_set (size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type()) β€” bucket count with the full default squad
  • unordered_set (unordered_set &&)=default β€” move ctor, defaulted, we love a clean handoff πŸ’…
  • unordered_set (unordered_set &&__uset, const allocator_type &__a) noexcept(noexcept(_Base(std::move(__uset), __a))) β€” move + allocator, with that exact noexcept spec, no cap

then the actual moves:

  • const _Base & _M_base () const noexcept β€” grab the const _Base underneath, noexcept
  • _Base & _M_base () noexcept β€” grab the non-const _Base, also noexcept
  • const_iterator begin () const noexcept β€” start of the const iterator run
  • iterator begin () noexcept β€” start of the iterator run
  • local_iterator begin (size_type __b) β€” start of bucket __b
  • const_local_iterator begin (size_type __b) const β€” const start of bucket __b
  • size_type bucket_size (size_type __b) const β€” how many things are chilling in bucket __b
  • const_iterator cbegin () const noexcept β€” const begin, noexcept
  • const_local_iterator cbegin (size_type __b) const β€” const start of bucket __b
  • const_iterator cend () const noexcept β€” const end, noexcept
  • const_local_iterator cend (size_type __b) const β€” const end of bucket __b
  • void clear () noexcept β€” wipe it, noexcept
  • template<typename... _Args> std::pair< iterator, bool > emplace (_Args &&... __args) β€” construct in place, hands back the iterator plus a bool
  • template<typename... _Args> iterator emplace_hint (const_iterator __hint, _Args &&... __args) β€” in-place construct with a hint, returns an iterator
  • const_iterator end () const noexcept β€” end of the const run, noexcept
  • iterator end () noexcept β€” end of the run, noexcept
  • local_iterator end (size_type __b) β€” end of bucket __b
  • const_local_iterator end (size_type __b) const β€” const end of bucket __b
  • std::pair< iterator, iterator > equal_range (const key_type &__key) β€” the range matching __key
  • std::pair< const_iterator, const_iterator > equal_range (const key_type &__key) const β€” const version of the same
  • _Base_iterator erase (_Base_const_iterator __it) β€” erase by _Base_const_iterator, returns a _Base_iterator
  • template<__heterogeneous_hash_key< unordered_set > _Kt> size_type erase (_Kt &&__key) β€” heterogeneous erase, gives you a size_type
  • size_type erase (const key_type &__key) β€” erase by key, gives you a size_type
  • iterator erase (const_iterator __first, const_iterator __last) β€” erase a whole [__first, __last) range
  • iterator erase (const_iterator __it) β€” erase one const iterator
  • iterator erase (iterator __it) β€” erase one iterator
  • iterator find (const key_type &__key) β€” go find __key
  • const_iterator find (const key_type &__key) const β€” const find
  • template<typename _InputIterator> void insert (_InputIterator __first, _InputIterator __last) β€” insert a range, returns void
  • template<__heterogeneous_hash_key< unordered_set > _Kt> std::pair< iterator, bool > insert (_Kt &&__obj) β€” heterogeneous insert β†’ std::pair< iterator, bool >
  • std::pair< iterator, bool > insert (const value_type &__obj) β€” insert a const value β†’ std::pair< iterator, bool >
  • template<__heterogeneous_hash_key< unordered_set > _Kt> iterator insert (const_iterator __hint, _Kt &&__obj) β€” heterogeneous insert with a hint
  • iterator insert (const_iterator __hint, const value_type &__obj) β€” insert with a hint, const value
  • iterator insert (const_iterator __hint, value_type &&__obj) β€” insert with a hint, rvalue value
  • void insert (std::initializer_list< value_type > __l) β€” dump a whole init list in, returns void
  • std::pair< iterator, bool > insert (value_type &&__obj) β€” insert an rvalue β†’ std::pair< iterator, bool >
  • float max_load_factor () const noexcept β€” read the max load factor, a float, noexcept
  • void max_load_factor (float __f) β€” set the max load factor to __f
  • unordered_set & operator= (const unordered_set &)=default β€” copy assign, defaulted
  • unordered_set & operator= (initializer_list< value_type > __l) β€” assign from an init list
  • unordered_set & operator= (unordered_set &&)=default β€” move assign, defaulted
  • void swap (unordered_set &__x) noexcept(noexcept(declval< _Base & >().swap(__x))) β€” swap with __x, with that exact noexcept spec

🌈 Protected Member Functions

  • constexpr void _M_swap (const _Safe_container &__x) const noexcept β€” the internal swap, constexpr, const, noexcept, protected. she's shy but powerful πŸ’œ

🫢 Friends

  • template<typename _ItT, typename _SeqT, typename _CatT> class ::__gnu_debug::_Safe_iterator β€” friend class
  • template<typename _ItT, typename _SeqT> class ::__gnu_debug::_Safe_local_iterator β€” friend class

πŸ’– Detailed Description πŸ’–

the full tea, template signature and all:

template<typename _Value, typename _Hash = std::hash<_Value>, typename _Pred
    = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value>>
class std::__debug::unordered_set< _Value, _Hash, _Pred, _Alloc >

and the class describes itself as:

"Class std::unordered_set with safety/checking/debug instrumentation.

so yeah β€” same unordered_set, extra checking, extra safety, extra debug. it's the version that actually notices when you do something unhinged πŸ™ˆ


πŸ‘‘ Author

Generated automatically by Doxygen for libstdc++ from the source code. (not a human author bestie, it's a robot that read the source so you don't have to πŸ€–βœ¨)


and that's the whole page!! this came from libstdc++, manual page for std::__debug::unordered_set< _Value, _Hash, _Pred, _Alloc > in section 3, and it's the debug/safety-instrumented one β€” so if you're out here with unchecked iterators, that's giving undefined behaviour and this class is literally the vibe check for that πŸ’€ slay responsibly, periodt πŸŽ€πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms