std::pointe...::to_address(3)

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

✨ NAME ✨

okay bestie, this is the page for std::pointer_traits::to_address β€” and yes, the NAME line is literally std::pointer_traits::to_address - std::pointer_traits::to_address, the symmetry is iconic πŸ’…. You’re in the C++ Standard Libary manual, under the header std::pointe...::to_address(3) (the abbreviation is part of the vibe, don’t panic).

🌸 Synopsis 🌸

okay so, here’s the setup, defined in header <memory>:

Defined in header <memory>
static element_type* to_address( pointer p )     (since C++20)
noexcept;                                        (optional member of program-defined specialization)

noexcept; is an optional member of program-defined specialization β€” optional, bestie, so it might not be there in a custom specialization. No cap.

This function constructs a raw pointer that references the same object as its pointer-like ("fancy pointer") argument. It’s giving β€œraw address, but make it fancy-adjacent” ✨.

This function, if defined, is the inverse of pointer_to, and exists as the customization point to be called by std::to_address. Periodt.

πŸŽ€ Parameters πŸŽ€

  • p β€” fancy pointer/pointer-like object. That’s the one and only parameter, and it’s carrying the whole plot 🫢.

πŸ¦‹ Return value πŸ¦‹

A raw pointer of the type element_type* that references the same memory location as the argument p. Slay, that’s the return value, no extra lore.

🌟 See also 🌟

  • pointer_to β€” obtains a dereferenceable pointer to its argument; [static] (public static member function)
  • to_address β€” obtains a raw pointer from a pointer-like type; (C++20) (function template)

that’s the whole glow-up, bestie πŸ’– Source/version: http://cppreference.com β€’ Date: 2024.06.10 β€’ Page: std::pointe...::to_address(3). mwah, go be a raw-pointer main character πŸŽ€

πŸ“¦ where this page comes from