STD::__DETAIL::_HASHTABLE_ALLOC(3cxx)

πŸ’– NAME πŸ’–

std::__detail::_Hashtable_alloc< _NodeAlloc > β€” bestie, this is the behind-the-scenes allocator brain of the libstdc++ hashtables, and we're gonna get to know her. (This page lives in manual section 3cxx, iykyk. πŸŽ€)


✨ SYNOPSIS ✨

First things first, you gotta pull her in:

#include <hashtable_policy.h>

She inherits std::__detail::_Hashtable_ebo_helper< 0, _NodeAlloc >. Lowkey iconic lineage tbh. πŸ¦‹

And she's inherited by β€” no cap, all three of these are <private> about it:

  • std::_Hashtable< _Key, _Tp, _Hash, _Pred, allocator< std::pair< const _Key, _Tp > > > [private]
  • std::_Hashtable< _Key, _Tp, hash< _Key >, equal_to< _Key >, allocator< std::pair< const _Key, _Tp > > > [private]
  • std::_Hashtable< _Value, hash< _Value >, equal_to< _Value >, allocator< _Value > > [private]

πŸ‘‘ Public Types πŸ‘‘

These are the little aliases she keeps in her purse, fr fr:

  • __bucket_alloc_traits β€” = std::allocator_traits< __bucket_alloc_type >
  • __bucket_alloc_type β€” = __alloc_rebind< __node_alloc_type, __bucket_type >
  • __bucket_type β€” = __node_base *
  • __node_alloc_traits β€” = __gnu_cxx::__alloc_traits< __node_alloc_type >
  • __node_alloc_type β€” = _NodeAlloc
  • __node_base β€” = __detail::_Hash_node_base
  • __node_type β€” = typename _NodeAlloc::value_type
  • __value_alloc_traits β€” = typename __node_alloc_traits::template rebind_traits< typename __node_type::value_type >

🌸 Public Member Functions 🌸

The whole roster, and yes, every single one is staying. Periodt. πŸ’…

  • template<typename _Alloc > _Hashtable_alloc (_Alloc &&__a) β€” the constructy one, takes a forwarding-ref allocator.
  • _Hashtable_alloc (_Hashtable_alloc &&)=default β€” move constructor, defaulted, she just glides on over.
  • _Hashtable_alloc (const _Hashtable_alloc &)=default β€” copy constructor, defaulted, twin energy.
  • __bucket_type * _M_allocate_buckets (std::size_t __bkt_count) β€” gets you buckets, __bkt_count of them.
  • template<typename... _Args> __node_type * _M_allocate_node (_Args &&... __args) β€” mints a node out of __args....
  • template<typename... _Args> auto _M_allocate_node (_Args &&... __args) -> __node_type * β€” same node-minting gig, written in the trailing-return-type fit. Both versions are listed, so both versions get their moment. ⭐
  • void _M_deallocate_buckets (__bucket_type *, std::size_t __bkt_count) β€” releases the buckets, __bkt_count of them.
  • void _M_deallocate_node (__node_type *__n) β€” frees the single node __n.
  • void _M_deallocate_node_ptr (__node_type *__n) β€” frees the pointer-to-node __n, slightly different flavor.
  • void _M_deallocate_nodes (__node_type *__n) β€” plural! she's doing the whole chain starting at __n.
  • __node_alloc_type & _M_node_allocator () β€” hands you back the node allocator, mutable flavor.
  • const __node_alloc_type & _M_node_allocator () const β€” same allocator, const flavor, she's just being respectful of your constness. 🫢

🌈 DETAILED DESCRIPTION 🌈

template<typename _NodeAlloc>
    struct std::__detail::_Hashtable_alloc< _NodeAlloc >

Quote her directly, bestie:

"This type deals with all allocation and keeps an allocator instance through inheritance to benefit from EBO when possible."

So basically: she handles all the allocation, and she holds onto an allocator instance through inheritance so she can flex that EBO (empty base optimization) whenever the opportunity shows up. Main character allocation behavior, honestly. πŸ”₯


πŸŽ€ Author πŸŽ€

Generated automatically by Doxygen for libstdc++ from the source code. Not a human author β€” a robot did her makeup. πŸ€–πŸ’„


And that's the whole page, bestie β€” straight outta libstdc++'s 3cxx manual, filed under std::__detail:...c< _NodeAlloc >(3cxx) in all her gloriously truncated footer-name beauty. Go allocate something cute. πŸ’œβœ¨

πŸ“¦ where this page comes from