std::any::operator=(3)

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

πŸ’– NAME πŸ’–

okay so bestie, welcome to the std::any::operator=(3) page β€” the C++ Standard Libary one ✨ this is literally the assignment operator for std::any, and its NAME is:

std::any::operator= - std::any::operator=

no cap, it’s a little redundant but that’s the NAME section and we respect it πŸ’…


✨ Synopsis ✨

any& operator=( const any& rhs );      (1) (since C++17)
any& operator=( any&& rhs ) noexcept;  (2) (since C++17)
template< typename ValueType >         (3) (since C++17)
    any& operator=( ValueType&& rhs );

Assigns contents to the contained value. yes queen, that’s the whole vibe of the function πŸ‘‘

  1. Assigns by copying the state of rhs, as if by any(rhs).swap(*this).
  2. Assigns by moving the state of rhs, as if by any(std::move(rhs)).swap(*this). rhs is left in a valid but unspecified state after the assignment.
  3. Assigns the type and value of rhs, as if by any(std::forward<ValueType>(rhs)).swap(*this). This overload participates in overload resolution only if std::decay_t<ValueType> is not the same type as any and std::is_copy_constructible_v<std::decay_t<ValueType>> is true.

🌸 Template parameters 🌸

  • ValueType β€” contained value type

πŸ¦‹ Type requirements πŸ¦‹

  • std::decay_t<ValueType> must meet the requirements of CopyConstructible.

πŸŽ€ Parameters πŸŽ€

  • rhs β€” object whose contained value to assign

⭐ Return value ⭐

  • *this

πŸ’€ Exceptions πŸ’€

1,3) Throws std::bad_alloc or any exception thrown by the constructor of the contained type. If an exception is thrown, there are no effects (strong exception guarantee).

πŸ™ˆ Example πŸ™ˆ

This section is incomplete Reason: no example

🌈 See also 🌈

  • constructor β€” constructs an any object (public member function)

πŸ“ Category πŸ“

* Todo no example


xoxo, your favorite Unix bestie πŸ’… source/version/date check: http://cppreference.com, 2024.06.10, and the page itself is std::any::operator=(3). mwah πŸ’‹

πŸ“¦ where this page comes from