std::experimental::optional<T>::operator=
Min standard notice:
Replaces contents of *this with the contents of other.
# Declarations
optional& operator=( std::experimental::nullopt_t ) noexcept;
(library fundamentals TS)
optional& operator=( const optional& other );
(library fundamentals TS)
optional& operator=( optional&& other ) noexcept(/* see below */);
(library fundamentals TS)
template< class U >
optional& operator=( U&& value );
(library fundamentals TS)
# Parameters
other: another optional object whose contained value to assignvalue: value to assign to the contained value
# Return value
*this
# Notes
An optional object op may be turned into an empty optional with both op = {}; and op = nullopt;.
# Example
#include <experimental/optional>
#include <iostream>
int main()
{
std::experimental::optional<const char*> s1 = "abc", s2; // constructor
s2 = s1; // assignment
s1 = "def"; // decaying assignment (U = char[4], T = const char*)
std::cout << *s2 << ' ' << *s1 << '\n';
}