std::alloca...ts::max_size(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

✨ NAME ✨

okay so bestie, this is the std::alloca...ts::max_size(3) page from the C++ Standard Libary manual πŸ’… β€” and the NAME is literally std::allocator_traits::max_size β€” std::allocator_traits::max_size. yes, iconically redundant, we love that for us πŸŽ€.


🌸 Synopsis 🌸

Defined in header <memory>:

static size_type max_size( const Alloc& a ) noexcept;

(since C++11) (until C++20)

static constexpr size_type max_size( const Alloc& a ) noexcept;

(since C++20)

So here's the tea β˜•: if possible, this obtains the maximum theoretically possible allocation size from the allocator a, by calling a.max_size().

If the above is not possible β€” like, say, Alloc does not have the member function max_size() β€” then it returns std::numeric_limits<size_type>::max() / sizeof(value_type). no cap, that's the fallback πŸ’«.


πŸŽ€ Parameters πŸŽ€

  • a β€” allocator to detect πŸ”

πŸ¦‹ Return value πŸ¦‹

Theoretical maximum allocation size. periodt πŸ’….


πŸ’… Defect reports πŸ’…

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. yes, we're going back in time, main character energy πŸ•°οΈβœ¨.

  • LWG 2162, applied to C++11 β€” behavior as published: max_size was not β€œrequied” to be noexcept (their spelling, not mine 😭); correct behavior: required.
  • LWG 2466, applied to C++11 β€” behavior as published: the theoretical maximum allocation size in bytes was returned as the fallback; correct behavior: the size in elements is returned. slay for correctness 🌟.

🌈 See also 🌈

  • max_size β€” returns the largest supported allocation size (until C++20) (public member function of std::allocator<T>) πŸ‘‘

okay that's the whole vibe πŸ’– β€” footer tea: this page is from http://cppreference.com, version date 2024.06.10, and the page tag is std::alloca...ts::max_size(3). mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from