std::any(3cxx)

πŸ’– std::any β€” the 3cxx manual page, bestie edition πŸ’–

okay so you opened the manual for std::any from the libstdc++ girlies and you need it explained with ✨flavor✨. welcome. sit down. hydrate. this container is iconic and you're about to understand it fr fr.


🌸 NAME 🌸

std::any β€” a type-safe container of any type. yes bestie, any. she contains multitudes πŸ’…


✨ SYNOPSIS ✨

#include <any>

πŸŽ€ Public Member Functions πŸŽ€

  • constexpr any () noexcept β€” bestie's default constructor, she makes an empty object. no thoughts, head empty, valid state πŸ’–
  • template<typename _Tp, typename _VTp = _Decay_if_not_any<_Tp>, typename _Mgr = _Manager<_VTp>, enable_if_t< is_copy_constructible_v< _VTp > &&!__is_in_place_type_v< _VTp >, bool > = true> any (_Tp &&__value) β€” construct with a copy of __value as the contained object. yes she copied your whole personality, and honestly? slay.
  • any (any &&__other) noexcept β€” move constructor, she transfers the state from __other. not copying, transferring. main character energy.
  • any (const any &__other) β€” copy constructor, copies the state of __other. twin behavior 🌸
  • template<typename _Tp, typename... _Args, typename _VTp = decay_t<_Tp>, typename _Mgr = _Manager<_VTp>, __any_constructible_t< _VTp, _Args &&... > = false> any (in_place_type_t< _Tp >, _Args &&... __args) β€” construct with an object created from __args as the contained object. build-a-bear but it's a type πŸ”₯
  • template<typename _Tp, typename _Up, typename... _Args, typename _VTp = decay_t<_Tp>, typename _Mgr = _Manager<_VTp>, __any_constructible_t< _VTp, initializer_list< _Up > &, _Args &&... > = false> any (in_place_type_t< _Tp >, initializer_list< _Up > __il, _Args &&... __args) β€” construct with an object created from __il and __args as the contained object. now with curly-brace sprinkle πŸ“
  • ~any () β€” destructor, she calls reset(). it's giving graceful exit ✨
  • template<typename _Tp, typename... _Args> __emplace_t< decay_t< _Tp >, _Args... > emplace (_Args &&... __args) β€” emplace with an object created from __args as the contained object. in-place glow-up πŸ’…
  • template<typename _Tp, typename _Up, typename... _Args> __emplace_t< decay_t< _Tp >, initializer_list< _Up > &, _Args &&... > emplace (initializer_list< _Up > __il, _Args &&... __args) β€” emplace with an object created from __il and __args as the contained object. same glow-up, extra initializer_list flavor πŸŽ€
  • bool has_value () const noexcept β€” reports whether there is a contained object or not. the vibe check. does she have something in her or not πŸ‘€
  • template<typename _Tp> enable_if_t< is_copy_constructible< _Decay_if_not_any< _Tp > >::value, any & > operator= (_Tp &&__rhs) β€” store a copy of __rhs as the contained object. glow-up via assignment πŸ’œ
  • any & operator= (any &&__rhs) noexcept β€” move assignment operator. she's taking what __rhs had, no cap.
  • any & operator= (const any &__rhs) β€” copy the state of another object. matching outfits fr fr.
  • void reset () noexcept β€” if not empty, destroy the contained object. she's clearing her camera roll 🧹
  • void swap (any &__rhs) β€” ... correction bestie: void swap (any &__rhs) noexcept β€” exchange state with another object. trading bracelets, but with state 🌈
  • const type_info & type () const noexcept β€” the typeid of the contained object, or typeid(void) if empty. showing her ID at the door πŸ’–

🌟 Detailed Description 🌟

A type-safe container of any type.

An any object's state is either empty or it stores a contained object of CopyConstructible type.

Since

C++17. she's not new but she IS timeless πŸ‘‘


πŸ’« Constructor & Destructor Documentation πŸ’«

std::any::any () inline, constexpr, noexcept

Default constructor, creates an empty object.

Referenced by any(), operator=(), operator=(), and operator=().

std::any::any (const any & __other) inline

Copy constructor, copies the state of __other.

std::any::any (any && __other) inline, noexcept

Move constructor, transfer the state from __other.

Postcondition

!__other.has_value() (this postcondition is a GNU extension)

References any(), and has_value().

template<typename _Tp, typename _VTp = _Decay_if_not_any<_Tp>, typename _Mgr = _Manager<_VTp>, enable_if_t< is_copy_constructible_v< _VTp > &&!__is_in_place_type_v< _VTp >, bool > = true> std::any::any (_Tp && __value) inline

Construct with a copy of __value as the contained object.

References std::forward().

template<typename _Tp, typename... _Args, typename _VTp = decay_t<_Tp>, typename _Mgr = _Manager<_VTp>, __any_constructible_t< _VTp, _Args &&... > = false> std::any::any (in_place_type_t< _Tp > , _Args &&... __args) inline, explicit

Construct with an object created from __args as the contained object.

References std::forward().

template<typename _Tp, typename _Up, typename... _Args, typename _VTp = decay_t<_Tp>, typename _Mgr = _Manager<_VTp>, __any_constructible_t< _VTp, initializer_list< _Up > &, _Args &&... > = false> std::any::any (in_place_type_t< _Tp > , initializer_list< _Up > __il, _Args &&... __args) inline, explicit

Construct with an object created from __il and __args as the contained object.

References std::forward().

std::any::~any () inline

Destructor, calls reset().


πŸ”₯ Member Function Documentation πŸ”₯

template<typename _Tp, typename... _Args> __emplace_t< decay_t< _Tp >, _Args... > std::any::emplace (_Args &&... __args) inline

Emplace with an object created from __args as the contained object.

References std::forward().

template<typename _Tp, typename _Up, typename... _Args> __emplace_t< decay_t< _Tp >, initializer_list< _Up > &, _Args &&... > std::any::emplace (initializer_list< _Up > __il, _Args &&... __args) inline

Emplace with an object created from __il and __args as the contained object.

References std::forward().

bool std::any::has_value () const inline, noexcept

Reports whether there is a contained object or not.

Referenced by any(), reset(), and type().

template<typename _Tp> enable_if_t< is_copy_constructible< _Decay_if_not_any< _Tp > >::value, any & > std::any::operator= (_Tp && __rhs) inline

Store a copy of __rhs as the contained object.

References any(), and std::forward().

any & std::any::operator= (any && __rhs) inline, noexcept

Move assignment operator.

Postcondition

!__rhs.has_value() (not guaranteed for other implementations)

⚠️ bestie read that parenthetical again β€” that postcondition is not guaranteed for other implementations. do not build your whole life plan on it πŸ™ˆ

References any(), and reset().

any & std::any::operator= (const any & __rhs) inline

Copy the state of another object.

References any().

void std::any::reset () inline, noexcept

If not empty, destroy the contained object.

References has_value().

Referenced by operator=().

void std::any::swap (any & __rhs) inline, noexcept

Exchange state with another object.

const type_info & std::any::type () const inline, noexcept

The typeid of the contained object, or typeid(void) if empty.

References has_value().


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. not a human, just a robot doing her little documentation duties 🫢


aaaand that's the whole page bestie!! this manual page is brought to you by libstdc++, page std::any(3cxx) β€” go forth and store any type safely, you absolute icon πŸ’–βœ¨πŸŒˆ