[#bsl-variant-operator_assign-03]
= xref:bsl.adoc[bsl]::xref:bsl/variant.adoc[variant]::operator&equals;
:relfileprefix: ../../
:mrdocs:

Assign to this object a copy of `rhs`&apos;s alternative&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;variant&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/variant.adoc[variant]&
operator&equals;(xref:bsl/variant.adoc[variant] const& rhs) = default;
----

== Description

If `rhs` holds the same alternative type as this object, copy assign the contained value of `rhs` to the contained value of this object&period; Otherwise, destroy the contained value of this object (if any) and, if `rhs` holds a value, copy&hyphen;construct the corresponding alternative of this object from the contained value of `rhs`&period; The allocators of this object and `rhs` both remain unchanged&period; This operator is deleted unless all alternatives are copy constructible and copy assignable&period; If the construction of a new alternative object exits via an exception, this `variant` object is left in a valueless by exception state&period; 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 &lsqb;variant&period;assign&rsqb;for details)&period; The standard behavior causes unnecessary performance degradation in cases where the alternative constructor does not throw, yet is not marked `noexcept`&semi; this behavior is therefore not implemented in `bsl&colon;&colon;variant`&period; For simplicity of implementation, this method also differs from the standard in the following ways&colon; &ast; conditional triviality is not implemented &ast; `constexpr` is not implemented &ast; `noexcept` specification is not implemented

== Return Value

reference to this object

== Parameters

[cols="1,4"]
|===
| Name| Description
| *rhs*
| variant to copy from
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
