C++23)   
|  |   
  
The default constructor is provided if and only if ` T ` models [ `
default_initializable ` ](/w/cpp/concepts/default_initializable
"cpp/concepts/default initializable") .

A default-constructed wrapper contains a value-initialized ` T ` object.

##  Assignment operators

|  (1)  |   
---|---|---  
constexpr  /*copyable-box*/  & operator  =  (  const  /*copyable-box*/  &
other  )  ;  
noexcept  (  /* see below */  )  ;  |  |  (since C++20)    
(until C++23)  
constexpr  /*movable-box*/  & operator  =  (  const  /*movable-box*/  & other
)  ;  
noexcept  (  /* see below */  )  requires [ std::  copy_constructible  ](http://en.cppreference.com/w/cpp/concepts/copy_constructible) < T  > ;  |  |  (since C++23)   
|  (2)  |   
constexpr  /*copyable-box*/  & operator  =  (  /*copyable-box*/  && other  )  
noexcept  (  [ std::  is_nothrow_move_constructible_v  ](http://en.cppreference.com/w/cpp/types/is_move_constructible) < T  > )  ;  |  |  (since C++20)    
(until C++23)  
constexpr  /*movable-box*/  & operator  =  (  /*movable-box*/  && other  )  
noexcept  (  [ std::  is_nothrow_move_constructible_v  ](http://en.cppreference.com/w/cpp/types/is_move_constructible) < T  > )  ;  |  |  (since C++23)   
|  |   
  
1)  If  [ std::  copyable
](http://en.cppreference.com/w/cpp/concepts/copyable) < T  > is not modeled,
the copy assignment operator is equivalently defined as:  constexpr
/*copyable-box*/  & operator  =  (  const  /*copyable-box*/  & other  )  
noexcept  (  [ std::  is_nothrow_copy_constructible_v
](http://en.cppreference.com/w/cpp/types/is_copy_constructible) < T  > )  
{  
if  (  this  !  =  [ std::  addressof
](http://en.cppreference.com/w/cpp/memory/addressof) (  other  )  )  
if  (  other  )  
emplace  (  *  other  )  ;  
else  
reset  (  )  ;  
  
return  *  this  ;  
}  |  (until C++23)   
---|---  
constexpr  /*movable-box*/  & operator  =  (  const  /*movable-box*/  & other
)  
noexcept  (  [ std::  is_nothrow_copy_constructible_v
](http://en.cppreference.com/w/cpp/types/is_copy_constructible) < T  > )  
requires [ std::  copy_constructible
](http://en.cppreference.com/w/cpp/concepts/copy_constructible) < T  >  
{  
if  (  this  !  =  [ std::  addressof
](http://en.cppreference.com/w/cpp/memory/addressof) (  other  )  )  
if  (  other  )  
emplace  (  *  other  )  ;  
else  
reset  (  )  ;  
  
return  *  this  ;  
}  |  (since C++23)   
Otherwise, it is identical to [ the copy assignment operator of `
std::optional ` ](/w/cpp/utility/optional/operator%3D
"cpp/utility/optional/operator=") .

2)  If  [ std::  movable  ](http://en.cppreference.com/w/cpp/concepts/movable)
< T  > is not modeled, the move assignment operator is equivalently defined
as:  constexpr  /*copyable-box*/  & operator  =  (  /*copyable-box*/  && other
)  
noexcept  (  [ std::  is_nothrow_move_constructible_v
](http://en.cppreference.com/w/cpp/types/is_move_constructible) < T  > )  
{  
if  (  this  !  =  [ std::  addressof
](http://en.cppreference.com/w/cpp/memory/addressof) (  other  )  )  
if  (  other  )  
emplace  (  std  ::  move  (  *  other  )  )  ;  
else  
reset  (  )  ;  
  
return  *  this  ;  
}  |  (until C++23)   
---|---  
constexpr  /*movable-box*/  & operator  =  (  /*movable-box*/  && other  )  
noexcept  (  [ std::  is_nothrow_move_constructible_v
](http://en.cppreference.com/w/cpp/types/is_move_constructible) < T  > )  
{  
if  (  this  !  =  [ std::  addressof
](http://en.cppreference.com/w/cpp/memory/addressof) (  other  )  )  
if  (  other  )  
emplace  (  std  ::  move  (  *  other  )  )  ;  
else  
reset  (  )  ;  
  
return  *  this  ;  
}  |  (since C++23)   
Otherwise, it is identical to [ the move assignment operator of `
std::optional ` ](/w/cpp/utility/optional/operator%3D
"cpp/utility/optional/operator=") .

##  Members identical to  std::  optional

###  Member functions

[ (constructor)  ](/w/cpp/utility/optional/optional "cpp/utility/optional/optional") |  constructs the ` optional ` object