11 #ifndef NONSTD_OPTIONAL_LITE_HPP    12 #define NONSTD_OPTIONAL_LITE_HPP    14 #define optional_lite_MAJOR  3    15 #define optional_lite_MINOR  1    16 #define optional_lite_PATCH  1    18 #define optional_lite_VERSION  optional_STRINGIFY(optional_lite_MAJOR) "." optional_STRINGIFY(optional_lite_MINOR) "." optional_STRINGIFY(optional_lite_PATCH)    20 #define optional_STRINGIFY(  x )  optional_STRINGIFY_( x )    21 #define optional_STRINGIFY_( x )  #x    25 #define optional_OPTIONAL_DEFAULT  0    26 #define optional_OPTIONAL_NONSTD   1    27 #define optional_OPTIONAL_STD      2    29 #if !defined( optional_CONFIG_SELECT_OPTIONAL )    30 # define optional_CONFIG_SELECT_OPTIONAL  ( optional_HAVE_STD_OPTIONAL ? optional_OPTIONAL_STD : optional_OPTIONAL_NONSTD )    35 #ifndef optional_CONFIG_NO_EXCEPTIONS    36 # if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)    37 #  define optional_CONFIG_NO_EXCEPTIONS  0    39 #  define optional_CONFIG_NO_EXCEPTIONS  1    46 #ifndef   optional_CPLUSPLUS    47 # if defined(_MSVC_LANG ) && !defined(__clang__)    48 #  define optional_CPLUSPLUS  (_MSC_VER == 1900 ? 201103L : _MSVC_LANG )    50 #  define optional_CPLUSPLUS  __cplusplus    54 #define optional_CPP98_OR_GREATER  ( optional_CPLUSPLUS >= 199711L )    55 #define optional_CPP11_OR_GREATER  ( optional_CPLUSPLUS >= 201103L )    56 #define optional_CPP11_OR_GREATER_ ( optional_CPLUSPLUS >= 201103L )    57 #define optional_CPP14_OR_GREATER  ( optional_CPLUSPLUS >= 201402L )    58 #define optional_CPP17_OR_GREATER  ( optional_CPLUSPLUS >= 201703L )    59 #define optional_CPP20_OR_GREATER  ( optional_CPLUSPLUS >= 202000L )    63 #define optional_CPLUSPLUS_V  ( optional_CPLUSPLUS / 100 - (optional_CPLUSPLUS > 200000 ? 2000 : 1994) )    67 #if optional_CPP17_OR_GREATER && defined(__has_include )    68 # if __has_include( <optional> )    69 #  define optional_HAVE_STD_OPTIONAL  1    71 #  define optional_HAVE_STD_OPTIONAL  0    74 # define  optional_HAVE_STD_OPTIONAL  0    77 #define optional_USES_STD_OPTIONAL  ( (optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_STD) || ((optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_DEFAULT) && optional_HAVE_STD_OPTIONAL) )    83 #ifndef nonstd_lite_HAVE_IN_PLACE_TYPES    84 #define nonstd_lite_HAVE_IN_PLACE_TYPES  1    88 #if optional_CPP17_OR_GREATER    97 using std::in_place_t;
    98 using std::in_place_type_t;
    99 using std::in_place_index_t;
   101 #define nonstd_lite_in_place_t(      T)  std::in_place_t   102 #define nonstd_lite_in_place_type_t( T)  std::in_place_type_t<T>   103 #define nonstd_lite_in_place_index_t(K)  std::in_place_index_t<K>   105 #define nonstd_lite_in_place(      T)    std::in_place_t{}   106 #define nonstd_lite_in_place_type( T)    std::in_place_type_t<T>{}   107 #define nonstd_lite_in_place_index(K)    std::in_place_index_t<K>{}   111 #else // optional_CPP17_OR_GREATER   119 struct in_place_type_tag {};
   121 template< std::
size_t K >
   122 struct in_place_index_tag {};
   126 struct in_place_t {};
   129 inline in_place_t 
in_place( detail::in_place_type_tag<T>  = detail::in_place_type_tag<T>() )
   134 template< std::
size_t K >
   135 inline in_place_t 
in_place( detail::in_place_index_tag<K>  = detail::in_place_index_tag<K>() )
   141 inline in_place_t 
in_place_type( detail::in_place_type_tag<T>  = detail::in_place_type_tag<T>() )
   146 template< std::
size_t K >
   147 inline in_place_t 
in_place_index( detail::in_place_index_tag<K>  = detail::in_place_index_tag<K>() )
   154 #define nonstd_lite_in_place_t(      T)  nonstd::in_place_t(&)( nonstd::detail::in_place_type_tag<T>  )   155 #define nonstd_lite_in_place_type_t( T)  nonstd::in_place_t(&)( nonstd::detail::in_place_type_tag<T>  )   156 #define nonstd_lite_in_place_index_t(K)  nonstd::in_place_t(&)( nonstd::detail::in_place_index_tag<K> )   158 #define nonstd_lite_in_place(      T)    nonstd::in_place_type<T>   159 #define nonstd_lite_in_place_type( T)    nonstd::in_place_type<T>   160 #define nonstd_lite_in_place_index(K)    nonstd::in_place_index<K>   164 #endif // optional_CPP17_OR_GREATER   165 #endif // nonstd_lite_HAVE_IN_PLACE_TYPES   171 #if optional_USES_STD_OPTIONAL   178     using std::bad_optional_access;
   182     using std::nullopt_t;
   184     using std::operator==;
   185     using std::operator!=;
   186     using std::operator<;
   187     using std::operator<=;
   188     using std::operator>;
   189     using std::operator>=;
   194 #else // optional_USES_STD_OPTIONAL   201 #ifndef  optional_CONFIG_MAX_ALIGN_HACK   202 # define optional_CONFIG_MAX_ALIGN_HACK  0   205 #ifndef  optional_CONFIG_ALIGN_AS   209 #ifndef  optional_CONFIG_ALIGN_AS_FALLBACK   210 # define optional_CONFIG_ALIGN_AS_FALLBACK  double   215 #if defined(__clang__)   216 # pragma clang diagnostic push   217 # pragma clang diagnostic ignored "-Wundef"   218 #elif defined(__GNUC__)   219 # pragma GCC   diagnostic push   220 # pragma GCC   diagnostic ignored "-Wundef"   221 #elif defined(_MSC_VER )   222 # pragma warning( push )   226 #define optional_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) )   241 #if defined(_MSC_VER ) && !defined(__clang__)   242 # define optional_COMPILER_MSVC_VER      (_MSC_VER )   243 # define optional_COMPILER_MSVC_VERSION  (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) )   245 # define optional_COMPILER_MSVC_VER      0   246 # define optional_COMPILER_MSVC_VERSION  0   249 #define optional_COMPILER_VERSION( major, minor, patch )  ( 10 * (10 * (major) + (minor) ) + (patch) )   251 #if defined(__GNUC__) && !defined(__clang__)   252 # define optional_COMPILER_GNUC_VERSION   optional_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)   254 # define optional_COMPILER_GNUC_VERSION   0   257 #if defined(__clang__)   258 # define optional_COMPILER_CLANG_VERSION  optional_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)   260 # define optional_COMPILER_CLANG_VERSION  0   263 #if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 140 )   264 # pragma warning( disable: 4345 )   // initialization behavior changed   267 #if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 150 )   268 # pragma warning( disable: 4814 )   // in C++14 'constexpr' will not imply 'const'   273 #define optional_HAVE(FEATURE) ( optional_HAVE_##FEATURE )   276 # define optional_HAS_CPP0X  _HAS_CPP0X   278 # define optional_HAS_CPP0X  0   283 #if optional_COMPILER_MSVC_VER >= 1900   284 # undef  optional_CPP11_OR_GREATER   285 # define optional_CPP11_OR_GREATER  1   288 #define optional_CPP11_90   (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1500)   289 #define optional_CPP11_100  (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1600)   290 #define optional_CPP11_110  (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1700)   291 #define optional_CPP11_120  (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1800)   292 #define optional_CPP11_140  (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1900)   293 #define optional_CPP11_141  (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1910)   295 #define optional_CPP14_000  (optional_CPP14_OR_GREATER)   296 #define optional_CPP17_000  (optional_CPP17_OR_GREATER)   300 #define optional_HAVE_CONSTEXPR_11      optional_CPP11_140   301 #define optional_HAVE_IS_DEFAULT        optional_CPP11_140   302 #define optional_HAVE_NOEXCEPT          optional_CPP11_140   303 #define optional_HAVE_NULLPTR           optional_CPP11_100   304 #define optional_HAVE_REF_QUALIFIER     optional_CPP11_140   308 #define optional_HAVE_CONSTEXPR_14      optional_CPP14_000   312 #define optional_HAVE_NODISCARD         optional_CPP17_000   316 #define optional_HAVE_CONDITIONAL       optional_CPP11_120   317 #define optional_HAVE_REMOVE_CV         optional_CPP11_120   318 #define optional_HAVE_TYPE_TRAITS       optional_CPP11_90   320 #define optional_HAVE_TR1_TYPE_TRAITS   (!! optional_COMPILER_GNUC_VERSION )   321 #define optional_HAVE_TR1_ADD_POINTER   (!! optional_COMPILER_GNUC_VERSION )   325 #if optional_HAVE( CONSTEXPR_11 )   326 # define optional_constexpr  constexpr   328 # define optional_constexpr     331 #if optional_HAVE( IS_DEFAULT )   332 # define optional_is_default  = default;   334 # define optional_is_default  {}   337 #if optional_HAVE( CONSTEXPR_14 )   338 # define optional_constexpr14  constexpr   340 # define optional_constexpr14     343 #if optional_HAVE( NODISCARD )   344 # define optional_nodiscard  [[nodiscard]]   346 # define optional_nodiscard     349 #if optional_HAVE( NOEXCEPT )   350 # define optional_noexcept  noexcept   352 # define optional_noexcept     355 #if optional_HAVE( NULLPTR )   356 # define optional_nullptr  nullptr   358 # define optional_nullptr  NULL   361 #if optional_HAVE( REF_QUALIFIER )   363 # define optional_ref_qual  &   364 # define optional_refref_qual  &&   366 # define optional_ref_qual     367 # define optional_refref_qual     372 #if optional_CONFIG_NO_EXCEPTIONS   375 # include <stdexcept>   378 #if optional_CPP11_OR_GREATER   379 # include <functional>   382 #if optional_HAVE( INITIALIZER_LIST )   383 # include <initializer_list>   386 #if optional_HAVE( TYPE_TRAITS )   387 # include <type_traits>   388 #elif optional_HAVE( TR1_TYPE_TRAITS )   389 # include <tr1/type_traits>   394 #if optional_CPP11_OR_GREATER   396 #define optional_REQUIRES_0(...) \   397     template< bool B = (__VA_ARGS__), typename std::enable_if<B, int>::type = 0 >   399 #define optional_REQUIRES_T(...) \   400     , typename = typename std::enable_if< (__VA_ARGS__), nonstd::optional_lite::detail::enabler >::type   402 #define optional_REQUIRES_R(R, ...) \   403     typename std::enable_if< (__VA_ARGS__), R>::type   405 #define optional_REQUIRES_A(...) \   406     , typename std::enable_if< (__VA_ARGS__), void*>::type = nullptr   414 namespace nonstd { 
namespace optional_lite {
   418 #if optional_CPP11_OR_GREATER   421     template< 
typename T > T & 
move( T & t ) { 
return t; }
   424 #if optional_HAVE( CONDITIONAL )   425     using std::conditional;
   428     template<         
typename T, 
typename F > 
struct conditional<false, T, F> { 
typedef F 
type; };
   429 #endif // optional_HAVE_CONDITIONAL   433 #if optional_CPP11_OR_GREATER   439 #if optional_CPP17_OR_GREATER   441 using std::is_swappable;
   442 using std::is_nothrow_swappable;
   444 #elif optional_CPP11_OR_GREATER   452     template< 
typename T, 
typename = decltype( swap( std::declval<T&>(), std::declval<T&>() ) ) >
   453     static std::true_type test( 
int  );
   456     static std::false_type test(...);
   459 struct is_nothrow_swappable
   463     template< 
typename T >
   464     static constexpr 
bool satisfies()
   466         return noexcept( 
swap( std::declval<T&>(), std::declval<T&>() ) );
   469     template< 
typename T >
   470     static auto test( 
int  ) -> std::integral_constant<bool, satisfies<T>()>{}
   473     static auto test(...) -> std::false_type;
   480 template< 
typename T >
   481 struct is_swappable : decltype( detail::is_swappable::test<T>(0) ){};
   483 template< 
typename T >
   484 struct is_nothrow_swappable : decltype( detail::is_nothrow_swappable::test<T>(0) ){};
   486 #endif // optional_CPP17_OR_GREATER   494 template< 
typename T >
   497     typedef typename std::remove_cv< typename std::remove_reference<T>::type >
::type type;
   502 #endif // optional_CPP11_OR_GREATER   506 template< 
typename T >
   513 #if optional_CPP11_OR_GREATER   514 enum class enabler{};
   521 template< 
typename Head, 
typename Tail >
   528 #if optional_CONFIG_MAX_ALIGN_HACK   532 #define optional_UNIQUE(  name )       optional_UNIQUE2( name, __LINE__ )   533 #define optional_UNIQUE2( name, line ) optional_UNIQUE3( name, line )   534 #define optional_UNIQUE3( name, line ) name ## line   536 #define optional_ALIGN_TYPE( type ) \   537     type optional_UNIQUE( _t ); struct_t< type > optional_UNIQUE( _st )   539 template< 
typename T >
   560 #ifdef HAVE_LONG_LONG   566     Unknown ( * optional_UNIQUE(_) )( Unknown );
   567     Unknown * Unknown::* optional_UNIQUE(_);
   568     Unknown ( Unknown::* optional_UNIQUE(_) )( Unknown );
   575 #undef optional_UNIQUE   576 #undef optional_UNIQUE2   577 #undef optional_UNIQUE3   579 #undef optional_ALIGN_TYPE   581 #elif defined( optional_CONFIG_ALIGN_AS ) // optional_CONFIG_MAX_ALIGN_HACK   585 #define optional_ALIGN_AS( unused ) \   586     optional_CONFIG_ALIGN_AS   588 #else // optional_CONFIG_MAX_ALIGN_HACK   592 #define optional_ALIGN_AS( to_align ) \   593     typename type_of_size< alignment_types, alignment_of< to_align >::value >::type   595 template< 
typename T >
   598 template< 
typename T >
   606 template< 
size_t A, 
size_t S >
   609     enum { value = A < S ? A : S };
   612 template< 
typename T >
   619 template< 
typename List, 
size_t N >
   623         N == 
sizeof( 
typename List::head ),
   634 template< 
typename T>
   637 #define optional_ALIGN_TYPE( type ) \   638     typelist< type , typelist< struct_t< type >   664     > > > > > > >    > > > > > > >
   665     > > > > > > >    > > > > > > >
   669 #undef optional_ALIGN_TYPE   671 #endif // optional_CONFIG_MAX_ALIGN_HACK   675 template< 
typename T >
   687         construct_value( v );
   692         ::new( value_ptr() ) value_type( v );
   695 #if optional_CPP11_OR_GREATER   702     void construct_value( value_type && v )
   704         ::new( value_ptr() ) value_type( 
std::move( v ) );
   707     template< 
class... Args >
   708     void emplace( Args&&... args )
   710         ::new( value_ptr() ) value_type( std::forward<Args>(args)... );
   713     template< 
class U, 
class... Args >
   714     void emplace( std::initializer_list<U> il, Args&&... args )
   716         ::new( value_ptr() ) value_type( il, std::forward<Args>(args)... );
   728         return as<value_type>();
   733         return as<value_type>();
   738         return * value_ptr();
   743         return * value_ptr();
   746 #if optional_CPP11_OR_GREATER   760 #if optional_CPP11_OR_GREATER   762     using aligned_storage_t = 
typename std::aligned_storage< sizeof(value_type), alignof(value_type) >::type;
   763     aligned_storage_t data;
   765 #elif optional_CONFIG_MAX_ALIGN_HACK   767     typedef struct { 
unsigned char data[ 
sizeof(value_type) ]; } aligned_storage_t;
   770     aligned_storage_t data;
   775     typedef struct { align_as_type data[ 1 + ( 
sizeof(value_type) - 1 ) / 
sizeof(align_as_type) ]; } aligned_storage_t;
   778 #   undef optional_ALIGN_AS   780 #endif // optional_CONFIG_MAX_ALIGN_HACK   792     template <
typename U>
   795         return reinterpret_cast<U*
>( ptr() );
   798     template <
typename U>
   801         return reinterpret_cast<U 
const *
>( ptr() );
   815 #if optional_HAVE( CONSTEXPR_11 )   824 #if ! optional_CONFIG_NO_EXCEPTIONS   826 class bad_optional_access : 
public std::logic_error
   829   explicit bad_optional_access()
   830   : logic_error( 
"bad optional access" ) {}
   833 #endif //optional_CONFIG_NO_EXCEPTIONS   837 template< 
typename T>
   843     typedef void (
optional::*safe_bool)() 
const;
   852     : has_value_( false )
   859     : has_value_( 
false )
   867             true || std::is_copy_constructible<T>::value
   871     : has_value_( other.has_value() )
   873         if ( other.has_value() )
   875             contained.construct_value( other.contained.value() );
   879 #if optional_CPP11_OR_GREATER   884             true || std::is_move_constructible<T>::value
   887     ) noexcept( std::is_nothrow_move_constructible<T>::value )
   888     : has_value_( other.has_value() )
   890         if ( other.has_value() )
   892             contained.construct_value( 
std::move( other.contained.value() ) );
   897     template< 
typename U >
   900             std::is_constructible<T, U const &>::value
   901             && !std::is_constructible<T, 
optional<U> &          >::value
   902             && !std::is_constructible<T, 
optional<U> &&         >::value
   903             && !std::is_constructible<T, 
optional<U> const &    >::value
   904             && !std::is_constructible<T, 
optional<U> const &&   >::value
   906             && !std::is_convertible<     
optional<U> &&      , T>::value
   907             && !std::is_convertible<     
optional<U> const & , T>::value
   908             && !std::is_convertible<     
optional<U> const &&, T>::value
   909             && !std::is_convertible<               U const & , T>::value 
   912     : has_value_( other.has_value() )
   914         if ( other.has_value() )
   916             contained.construct_value( T{ other.contained.value() } );
   919 #endif // optional_CPP11_OR_GREATER   922     template< 
typename U >
   927             std::is_constructible<T, U const &>::value
   928             && !std::is_constructible<T, 
optional<U> &          >::value
   929             && !std::is_constructible<T, 
optional<U> &&         >::value
   930             && !std::is_constructible<T, 
optional<U> const &    >::value
   931             && !std::is_constructible<T, 
optional<U> const &&   >::value
   933             && !std::is_convertible<     
optional<U> &&      , T>::value
   934             && !std::is_convertible<     
optional<U> const & , T>::value
   935             && !std::is_convertible<     
optional<U> const &&, T>::value
   936             &&  std::is_convertible<               U const & , T>::value 
   940     : has_value_( other.has_value() )
   942         if ( other.has_value() )
   944             contained.construct_value( other.contained.value() );
   948 #if optional_CPP11_OR_GREATER   951     template< 
typename U >
   954             std::is_constructible<T, U &&>::value
   955             && !std::is_constructible<T, 
optional<U> &          >::value
   956             && !std::is_constructible<T, 
optional<U> &&         >::value
   957             && !std::is_constructible<T, 
optional<U> const &    >::value
   958             && !std::is_constructible<T, 
optional<U> const &&   >::value
   960             && !std::is_convertible<     
optional<U> &&      , T>::value
   961             && !std::is_convertible<     
optional<U> const & , T>::value
   962             && !std::is_convertible<     
optional<U> const &&, T>::value
   963             && !std::is_convertible<                     U &&, T>::value 
   966     : has_value_( other.has_value() )
   968         if ( other.has_value() )
   970             contained.construct_value( T{ 
std::move( other.contained.value() ) } );
   975     template< 
typename U >
   979             std::is_constructible<T, U &&>::value
   980             && !std::is_constructible<T, 
optional<U> &          >::value
   981             && !std::is_constructible<T, 
optional<U> &&         >::value
   982             && !std::is_constructible<T, 
optional<U> const &    >::value
   983             && !std::is_constructible<T, 
optional<U> const &&   >::value
   985             && !std::is_convertible<     
optional<U> &&      , T>::value
   986             && !std::is_convertible<     
optional<U> const & , T>::value
   987             && !std::is_convertible<     
optional<U> const &&, T>::value
   988             &&  std::is_convertible<                     U &&, T>::value 
   991     : has_value_( other.has_value() )
   993         if ( other.has_value() )
   995             contained.construct_value( 
std::move( other.contained.value() ) );
  1000     template< 
typename... Args
  1001         optional_REQUIRES_T(
  1002             std::is_constructible<T, Args&&...>::value
  1006     : has_value_( 
true )
  1007     , contained( T( std::forward<Args>(args)...) )
  1011     template< 
typename U, 
typename... Args
  1012         optional_REQUIRES_T(
  1013             std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value
  1017     : has_value_( 
true )
  1018     , contained( T( il, std::forward<Args>(args)...) )
  1022     template< 
typename U = value_type >
  1024         optional_REQUIRES_A(
  1025             std::is_constructible<T, U&&>::value
  1027             && !std::is_same<
typename std20::remove_cvref<U>::type, 
optional<T>>::value
  1028             && !std::is_convertible<U&&, T>::value 
  1031     : has_value_( 
true )
  1032     , contained( T{ std::forward<U>( value ) } )
  1036     template< 
typename U = value_type >
  1039         optional_REQUIRES_A(
  1040             std::is_constructible<T, U&&>::value
  1042             && !std::is_same<
typename std20::remove_cvref<U>::type, 
optional<T>>::value
  1043             && std::is_convertible<U&&, T>::value 
  1046     : has_value_( 
true )
  1047     , contained( std::forward<U>( value ) )
  1050 #else // optional_CPP11_OR_GREATER  1054     : has_value_( true )
  1055     , contained( value )
  1058 #endif // optional_CPP11_OR_GREATER  1066             contained.destruct_value();
  1080 #if optional_CPP11_OR_GREATER  1082     optional_REQUIRES_R(
  1088     operator=( optional 
const & other )
  1090             std::is_nothrow_move_assignable<T>::value
  1091             && std::is_nothrow_move_constructible<T>::value
  1097         if      ( (has_value() == 
true ) && (other.
has_value() == 
false) ) { reset(); }
  1098         else if ( (has_value() == 
false) && (other.
has_value() == true ) ) { initialize( *other ); }
  1099         else if ( (has_value() == 
true ) && (other.
has_value() == true ) ) { contained.value() = *other; }
  1103 #if optional_CPP11_OR_GREATER  1107     optional_REQUIRES_R(
  1113     operator=( optional && other ) noexcept
  1115         if      ( (has_value() == 
true ) && (other.
has_value() == 
false) ) { reset(); }
  1116         else if ( (has_value() == 
false) && (other.
has_value() == true ) ) { initialize( 
std::move( *other ) ); }
  1117         else if ( (has_value() == 
true ) && (other.
has_value() == true ) ) { contained.value() = 
std::move( *other ); }
  1122     template< 
typename U = T >
  1124         optional_REQUIRES_R(
  1126             std::is_constructible<T , U>::value
  1127             && std::is_assignable<T&, U>::value
  1129             && !std::is_same<
typename std20::remove_cvref<U>::type, 
optional<T>>::value
  1130             && !(std::is_scalar<T>::value && std::is_same<T, 
typename std::decay<U>::type>::value)
  1132     operator=( U && value )
  1136             contained.value() = std::forward<U>( value );
  1140             initialize( T( std::forward<U>( value ) ) );
  1145 #else // optional_CPP11_OR_GREATER  1148     template< 
typename U  >
  1151         if ( has_value() ) contained.
value() = value;
  1152         else               initialize( T( value ) );
  1156 #endif // optional_CPP11_OR_GREATER  1159     template< 
typename U >
  1160 #if optional_CPP11_OR_GREATER  1162         optional_REQUIRES_R(
  1164             std::is_constructible<  T , U const &>::value
  1165             &&  std::is_assignable< T&, U const &>::value
  1166             && !std::is_constructible<T, 
optional<U> &          >::value
  1167             && !std::is_constructible<T, 
optional<U> &&         >::value
  1168             && !std::is_constructible<T, 
optional<U> const &    >::value
  1169             && !std::is_constructible<T, 
optional<U> const &&   >::value
  1170             && !std::is_convertible<     
optional<U> &       , T>::value
  1171             && !std::is_convertible<     
optional<U> &&      , T>::value
  1172             && !std::is_convertible<     
optional<U> const & , T>::value
  1173             && !std::is_convertible<     
optional<U> const &&, T>::value
  1174             && !std::is_assignable<  T&, 
optional<U> &          >::value
  1175             && !std::is_assignable<  T&, 
optional<U> &&         >::value
  1176             && !std::is_assignable<  T&, 
optional<U> const &    >::value
  1177             && !std::is_assignable<  T&, 
optional<U> const &&   >::value
  1181 #endif // optional_CPP11_OR_GREATER  1184         return *
this = optional( other );
  1187 #if optional_CPP11_OR_GREATER  1190     template< 
typename U >
  1192         optional_REQUIRES_R(
  1194             std::is_constructible<  T , U>::value
  1195             &&  std::is_assignable< T&, U>::value
  1196             && !std::is_constructible<T, 
optional<U> &          >::value
  1197             && !std::is_constructible<T, 
optional<U> &&         >::value
  1198             && !std::is_constructible<T, 
optional<U> const &    >::value
  1199             && !std::is_constructible<T, 
optional<U> const &&   >::value
  1200             && !std::is_convertible<     
optional<U> &       , T>::value
  1201             && !std::is_convertible<     
optional<U> &&      , T>::value
  1202             && !std::is_convertible<     
optional<U> const & , T>::value
  1203             && !std::is_convertible<     
optional<U> const &&, T>::value
  1204             && !std::is_assignable<  T&, 
optional<U> &          >::value
  1205             && !std::is_assignable<  T&, 
optional<U> &&         >::value
  1206             && !std::is_assignable<  T&, 
optional<U> const &    >::value
  1207             && !std::is_assignable<  T&, 
optional<U> const &&   >::value
  1211         return *
this = optional( 
std::move( other ) );
  1215     template< 
typename... Args
  1216         optional_REQUIRES_T(
  1217             std::is_constructible<T, Args&&...>::value
  1220     T& emplace( Args&&... args )
  1223         contained.emplace( std::forward<Args>(args)...  );
  1225         return contained.value();
  1229     template< 
typename U, 
typename... Args
  1230         optional_REQUIRES_T(
  1231             std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value
  1234     T& emplace( std::initializer_list<U> il, Args&&... args )
  1237         contained.emplace( il, std::forward<Args>(args)...  );
  1239         return contained.value();
  1242 #endif // optional_CPP11_OR_GREATER  1247 #if optional_CPP11_OR_GREATER  1249             std::is_nothrow_move_constructible<T>::value
  1250             && std17::is_nothrow_swappable<T>::value
  1255         if      ( (has_value() == 
true ) && (other.
has_value() == true ) ) { 
swap( **
this, *other ); }
  1256         else if ( (has_value() == 
false) && (other.
has_value() == true ) ) { initialize( 
std11::move(*other) ); other.
reset(); }
  1257         else if ( (has_value() == 
true ) && (other.
has_value() == 
false) ) { other.initialize( 
std11::move(**
this) ); reset(); }
  1264         return assert( has_value() ),
  1265             contained.value_ptr();
  1270         return assert( has_value() ),
  1271             contained.value_ptr();
  1276         return assert( has_value() ),
  1282         return assert( has_value() ),
  1286 #if optional_HAVE( REF_QUALIFIER )  &&  ( !optional_COMPILER_GNUC_VERSION || optional_COMPILER_GNUC_VERSION >= 490 )  1300 #if optional_CPP11_OR_GREATER  1308         return has_value() ? &optional::this_type_does_not_support_comparisons : 0;
  1321 #if optional_CONFIG_NO_EXCEPTIONS  1322         assert( has_value() );
  1324         if ( ! has_value() )
  1326             throw bad_optional_access();
  1329         return contained.value();
  1334 #if optional_CONFIG_NO_EXCEPTIONS  1335         assert( has_value() );
  1337         if ( ! has_value() )
  1339             throw bad_optional_access();
  1342         return contained.value();
  1345 #if optional_HAVE( REF_QUALIFIER )  &&  ( !optional_COMPILER_GNUC_VERSION || optional_COMPILER_GNUC_VERSION >= 490 )  1360 #if optional_CPP11_OR_GREATER  1362     template< 
typename U >
  1365         return has_value() ? contained.value() : 
static_cast<T
>(std::forward<U>( v ) );
  1368     template< 
typename U >
  1371         return has_value() ? 
std::move( contained.value() ) : static_cast<T>(std::forward<U>( v ) );
  1376     template< 
typename U >
  1379         return has_value() ? contained.value() : 
static_cast<value_type
>( v );
  1382 #endif // optional_CPP11_OR_GREATER  1390             contained.destruct_value();
  1397     void this_type_does_not_support_comparisons()
 const {}
  1399     template< 
typename V >
  1400     void initialize( V 
const & value )
  1402         assert( ! has_value()  );
  1403         contained.construct_value( value );
  1407 #if optional_CPP11_OR_GREATER  1408     template< 
typename V >
  1409     void initialize( V && value )
  1411         assert( ! has_value()  );
  1412         contained.construct_value( 
std::move( value ) );
  1426 template< 
typename T, 
typename U >
  1429     return bool(x) != bool(y) ? false : !bool( x ) ? true : *x == *y;
  1432 template< 
typename T, 
typename U >
  1438 template< 
typename T, 
typename U >
  1441     return (!y) ? false : (!x) ? 
true : *x < *y;
  1444 template< 
typename T, 
typename U >
  1450 template< 
typename T, 
typename U >
  1456 template< 
typename T, 
typename U >
  1464 template< 
typename T >
  1470 template< 
typename T >
  1476 template< 
typename T >
  1482 template< 
typename T >
  1488 template< 
typename T >
  1494 template< 
typename T >
  1500 template< 
typename T >
  1506 template< 
typename T >
  1512 template< 
typename T >
  1518 template< 
typename T >
  1524 template< 
typename T >
  1530 template< 
typename T >
  1538 template< 
typename T, 
typename U >
  1541     return bool(x) ? *x == v : 
false;
  1544 template< 
typename T, 
typename U >
  1547     return bool(x) ? v == *x : 
false;
  1550 template< 
typename T, 
typename U >
  1553     return bool(x) ? *x != v : 
true;
  1556 template< 
typename T, 
typename U >
  1559     return bool(x) ? v != *x : 
true;
  1562 template< 
typename T, 
typename U >
  1565     return bool(x) ? *x < v : 
true;
  1568 template< 
typename T, 
typename U >
  1571     return bool(x) ? v < *x : 
false;
  1574 template< 
typename T, 
typename U >
  1577     return bool(x) ? *x <= v : 
true;
  1580 template< 
typename T, 
typename U >
  1583     return bool(x) ? v <= *x : 
false;
  1586 template< 
typename T, 
typename U >
  1589     return bool(x) ? *x > v : 
false;
  1592 template< 
typename T, 
typename U >
  1595     return bool(x) ? v > *x : 
true;
  1598 template< 
typename T, 
typename U >
  1601     return bool(x) ? *x >= v : 
false;
  1604 template< 
typename T, 
typename U >
  1607     return bool(x) ? v >= *x : 
true;
  1612 template< 
typename T
  1613 #if optional_CPP11_OR_GREATER  1614     optional_REQUIRES_T(
  1615         std::is_move_constructible<T>::value
  1616         && std17::is_swappable<T>::value )
  1620 #if optional_CPP11_OR_GREATER  1621     noexcept( noexcept( x.
swap(y) ) )
  1627 #if optional_CPP11_OR_GREATER  1629 template< 
typename T >
  1635 template< 
typename T, 
typename...Args >
  1641 template< 
typename T, 
typename U, 
typename... Args >
  1649 template< 
typename T >
  1655 #endif // optional_CPP11_OR_GREATER  1662 using optional_lite::bad_optional_access;
  1668 #if optional_CPP11_OR_GREATER  1675 struct hash< nonstd::optional<T> >
  1680         return bool( v ) ? std::hash<T>{}( *v ) : 0;
  1686 #endif // optional_CPP11_OR_GREATER  1688 #if defined(__clang__)  1689 # pragma clang diagnostic pop  1690 #elif defined(__GNUC__)  1691 # pragma GCC   diagnostic pop  1692 #elif defined(_MSC_VER )  1693 # pragma warning( pop )  1696 #endif // optional_USES_STD_OPTIONAL  1698 #endif // NONSTD_OPTIONAL_LITE_HPP #define optional_nodiscard
bool operator>(U const &v, optional< T > const &x)
type_of_size< alignment_types, alignment_of< value_type >::value >::type align_as_type
#define nonstd_lite_in_place_t( T)
#define optional_noexcept
#define optional_ref_qual
value_type const  * value_ptr() const
value_type const  & value() const
void swap(optional< T > &x, optional< T > &y)
optional< T > make_optional(T const &value)
bool operator==(U const &v, optional< T > const &x)
optional(optional const &other)
typelist< char, typelist< struct_t< char >, typelist< short, typelist< struct_t< short >, typelist< int, typelist< struct_t< int >, typelist< long, typelist< struct_t< long >, typelist< float, typelist< struct_t< float >, typelist< double, typelist< struct_t< double >, typelist< long double, typelist< struct_t< long double >, typelist< char *, typelist< struct_t< char *>, typelist< short *, typelist< struct_t< short *>, typelist< int *, typelist< struct_t< int *>, typelist< long *, typelist< struct_t< long *>, typelist< float *, typelist< struct_t< float *>, typelist< double *, typelist< struct_t< double *>, typelist< long double *, typelist< struct_t< long double *>, typelist< Unknown(*)(Unknown), typelist< struct_t< Unknown(*)(Unknown) >, typelist< Unknown *Unknown::*, typelist< struct_t< Unknown *Unknown::*>, typelist< Unknown(Unknown::*)(Unknown), typelist< struct_t< Unknown(Unknown::*)(Unknown) >, nulltype > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > alignment_types
value_type value_or(U const &v) const
in_place_t in_place_index(detail::in_place_index_tag< K >=detail::in_place_index_tag< K >())
optional & operator=(nullopt_t)
optional(value_type const &value)
#define optional_is_default
void construct_value(value_type const &v)
optional & operator=(U const &value)
bool operator<(U const &v, optional< T > const &x)
optional & operator=(optional< U > const &other)
#define optional_CONFIG_ALIGN_AS_FALLBACK
#define optional_refref_qual
bool operator!=(U const &v, optional< T > const &x)
#define optional_CPP11_OR_GREATER
void swap(optional &other)
#define optional_ALIGN_TYPE(type)
optional(optional< U > const &other)
#define optional_constexpr14
optional & operator=(optional const &other)
#define nonstd_lite_in_place( T)
in_place_t in_place_type(detail::in_place_type_tag< T >=detail::in_place_type_tag< T >())
std11::conditional< N==sizeof(typename List::head), typename List::head, typename type_of_size< typename List::tail, N >::type >::type type
value_type const  & value() const
C++03 constructed union to hold value. 
bool operator>=(U const &v, optional< T > const &x)
#define optional_ALIGN_AS(to_align)
const nullopt_t nullopt((nullopt_t::init()))
bool operator<=(U const &v, optional< T > const &x)
#define optional_constexpr
in_place_t in_place(detail::in_place_type_tag< T >=detail::in_place_type_tag< T >())