optional& operator=(T* value) { if (valid()) unchecked_destroy(); if (value == nullptr) { return *this; } unchecked_place(value); return *this; }
optional& operator=(optional&& that) { if (std::addressof(that) == this) return *this; if (valid() && that.valid()) **this = std::move(*that); else if (valid()) unchecked_destroy(); else if (that.valid()) unchecked_place(std::move(*that)); else present = false; return *this; }
optional( T&& t ) { unchecked_place( std::move( t ) ); }
optional( const T& t ) { unchecked_place( t ); }
explicit optional( in_place_t, Tn&&... argn ) { unchecked_place( std::forward<Tn>( argn )... ); }
void place( Tn&&... argn ) { assert( !present ); unchecked_place( std::forward<Tn>( argn )... ); }
optional& operator=(const T& right) { if (valid()) unchecked_destroy(); unchecked_place(right); return *this; }
optional& operator=(T&& right) { if (valid()) unchecked_destroy(); unchecked_place(std::move(right)); return *this; }
optional(optional&& that) : present(false) { if (that.valid()) unchecked_place(std::move(*that)); }
optional(const optional& that) : present(false) { if (that.valid()) unchecked_place(*that); }
optional& operator=(T& value) { if (valid()) unchecked_destroy(); unchecked_place(value); return *this; }
void place(Tn&&... argn) { assert(!valid()); unchecked_place(std::forward<Tn>(argn)...); }