std::experi...y::operator=(3)

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

πŸ’– std::experi...y::operator=(3) πŸ’–

hey bestie, welcome to the std::experi...y::operator=(3) page from the C++ Standard Libary πŸ’– this is the assignment operator for std::experimental::any, and it's honestly giving main character energy ✨


πŸ’… NAME πŸ’…

std::experimental::any::operator= - std::experimental::any::operator=. That's the whole name, no cap, periodt πŸ’…


✨ Synopsis ✨

          any& operator=( const any& rhs );      (1) (library fundamentals TS)
          any& operator=( any&& rhs ) noexcept;  (2) (library fundamentals TS)
          template< typename ValueType >         (3) (library fundamentals TS)
              any& operator=( ValueType&& rhs );

okay so the whole assignment vibe is: assigns contents to the contained value. That's the job, bestie. 🫢

  1. Assigns by copying the state of rhs, as if by any(rhs).swap(*this). copy girl summer πŸ’–
  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 β€” so like, it's alive but not necessarily the same vibe, yk? πŸ¦‹
  3. Assigns the type and value of rhs, as if by any(std::forward<ValueType>(rhs)).swap(*this). If std::is_copy_constructible<std::decay_t<ValueType>>::value is false, the program is ill-formed. This overload participates in overload resolution only if std::decay_t<ValueType> is not the same type as any. no cap, those are the rules πŸ”₯

🌸 Template parameters 🌸

  • ValueType β€” contained value type. It's the contained value type, bestie, and that's the tea πŸŽ€

πŸ¦‹ Type requirements πŸ¦‹

  • std::decay_t<ValueType> must meet the requirements of CopyConstructible. So it's giving "must be copy constructible" energy, and that's non-negotiable πŸ’…

πŸŽ€ Parameters πŸŽ€

  • rhs β€” object whose contained value to assign. That's the object whose contained value you're assigning, fr fr.

⭐ Return value ⭐

*this β€” yes bestie, it returns *this and hands the vibe right back to you πŸ’–


πŸ”₯ Exceptions πŸ”₯

1,3) Throws 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). So if it throws, it's like nothing happened β€” strong exception guarantee, iconic πŸ˜­πŸ‘‘


πŸ‘€ See also πŸ‘€

  • constructor β€” constructs an any object (public member function). Bestie, go read the constructor page if you need the origin story 🫢

πŸ—‚οΈ Category: πŸ—‚οΈ

  • Noindexed pages. That's the category, periodt πŸ’€

that's the whole page, bestie πŸ’– brought to you by http://cppreference.com, dated 2024.06.10, for std::experi...y::operator=(3) β€” now go slay your any assignments πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from