bsl::variant::operator=

Assignment operators

Synopses

Declared in <bslstl_variant.h>

If rhs holds the same alternative type as this object, copy assign the contained value of rhs to the contained value of this object. Otherwise, destroy the contained value of this object (if any) and, if rhs holds a value, copy-construct the corresponding alternative of this object from the contained value of rhs. The allocators of this object and rhs both remain unchanged. This operator is deleted unless all alternatives are copy constructible and copy assignable. If the construction of a new alternative object exits via an exception, this variant object is left in a valueless by exception state. This is different from the standard, which requires a temporary copy of rhs to be made if copy construction of the active alternative is not noexcept (see [variant.assign]for details). The standard behavior causes unnecessary performance degradation in cases where the alternative constructor does not throw, yet is not marked noexcept; this behavior is therefore not implemented in bsl::variant. For simplicity of implementation, this method also differs from the standard in the following ways: * conditional triviality is not implemented * constexpr is not implemented * noexcept specification is not implemented

variant&
operator=(variant const& rhs) = default;
» more...

If rhs holds the same alternative type as this object, move assign the contained value of rhs to the contained value of this object. Otherwise, destroy the contained value of this object (if any) and, if rhs holds a value, move-construct the corresponding alternative of this object from the contained value of rhs. The allocators of this object and rhs both remain unchanged. If the construction of a new alternative object throws an exception, this variant object is left in a valueless by exception state. This operator participes in overload resolution only if all alternatives are move constructible and mvoe assignable. For simplicity of implementation, this method differs from the standard in the following ways: * conditional triviality is not implemented * constexpr is not implemented * noexcept specification is not implemented

variant&
operator=(variant&& rhs) = default;
» more...

Assign to this object the specified value. The alternative corresponding to value is the best match among all alternatives for which the expression t_ALT_TYPE x[]= {std::forward<t_TYPE>(value)}; is well formed, and this operator participates in overload resolution only if there is a unique best matching alternative and that alternative is both constructible and assignable from value. If this variant already holds the alternative corresponding to value, the contained value is assigned to from value; otherwise, any contained value is destroyed and the alternative corresponding to value is direct-initialized from value. Note that if the construction of a new alternative object exits via an exception, this variant object may be left in a valueless by exception state. This is different from the standard, which requires a temporary alternative object to be constructed if such construction is not noexcept (see [variant.assign]for details). The standard behavior causes unnecessary performance degradation in cases where the alternative constructor does not throw, yet is not marked noexcept; this behavior is therefore not implemented in bsl::variant. For simplicity of implementation, this method also differs from the standard in the following ways: * constexpr is not implemented * noexcept specification is not implemented

template<class t_TYPE>
variant&
operator=(t_TYPE&& value)
requires BloombergLP::bslstl::Variant_AssignsFromType<variant, t_TYPE>::value;
» more...