std::experi...y::operator=(3)
π 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. π«Ά
- Assigns by copying the state of
rhs, as if byany(rhs).swap(*this). copy girl summer π - Assigns by moving the state of
rhs, as if byany(std::move(rhs)).swap(*this).rhsis left in a valid but unspecified state after the assignment β so like, it's alive but not necessarily the same vibe, yk? π¦ - Assigns the type and value of
rhs, as if byany(std::forward<ValueType>(rhs)).swap(*this). Ifstd::is_copy_constructible<std::decay_t<ValueType>>::valueis false, the program is ill-formed. This overload participates in overload resolution only ifstd::decay_t<ValueType>is not the same type asany. 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 ofCopyConstructible. 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 ananyobject (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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms