std::align_val_t(3)

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

πŸ’– NAME πŸ’–

std::align_val_t β€” std::align_val_t. That's the name, bestie, and it's iconic for exactly that reason 🫢. This page is from the C++ Standard Libary (yes, that's the manual name right there β€” spelling included, not me being quirky πŸ’…).


✨ Synopsis ✨

Defined in header <new>:

enum class align_val_t : std::size_t {};

(since C++17) πŸŽ€

Both new-expression and delete-expression, when used with objects whose alignment requirement is greater than __STDCPP_DEFAULT_NEW_ALIGNMENT__, pass that alignment requirement as an argument of type std::align_val_t to the selected allocation/deallocation function. That's the whole mechanic, and it ate ✨.


🌸 Notes 🌸

Alignment (as obtained by alignof) has the type std::size_t, but placement forms of allocation and deallocation functions that take std::size_t as an additional parameter are already in use, so this type is used instead. No cap, the std::size_t slot was already in use, so this type steps in instead πŸ’….

Feature-test macro check:

  • __cpp_aligned_new β€” value 201606L, std (C++17), feature: Dynamic memory allocation for over-aligned data. That's the receipt 🧾✨.

πŸ‘€ See also πŸ‘€

  • operator new β€” allocation functions
  • operator new[] β€” (function)
  • operator delete β€” deallocation functions
  • operator delete[] β€” (function)

mwah πŸ’‹ β€” source http://cppreference.com, version/date 2024.06.10, page std::align_val_t(3).

πŸ“¦ where this page comes from