示例#1
0
 void clear()
 {
     if ( has_value )
     {
         contained.destruct_value();
         contained.construct_error( std::exception_ptr() );
     }
     has_value = false;
 }
 void clear()
 {
     if ( has_value )
     {
         contained.destruct_value();
         contained.construct_error( error_type() );
     }
     has_value = false;
 }
示例#3
0
    void swap( expected & rhs )
    {
        using std::swap;

        if      ( has_value == true  && rhs.has_value == true  ) { swap( contained.value(), rhs.contained.value() ); }
        else if ( has_value == false && rhs.has_value == false ) { swap( contained.error(), rhs.contained.error() ); }
        else if ( has_value == false && rhs.has_value == true  ) { rhs.swap( *this ); }
        else if ( has_value == true  && rhs.has_value == false ) { error_type t = rhs.contained.error();
                                                                   rhs.contained.destruct_error();
                                                                   rhs.contained.construct_value( contained.value() );
                                                                   contained.construct_error( t );
                                                                   swap( has_value, rhs.has_value );
                                                                 }
    }
示例#4
0
 expected( expected const & rhs )
 : has_value( rhs.has_value )
 {
     if ( has_value ) contained.construct_value( rhs.contained.value() );
     else             contained.construct_error( rhs.contained.error() );
 }
示例#5
0
 expected( nullexp_t, error_type const & rhs )
 : has_value( false )
 {
     contained.construct_error( rhs );
 }
示例#6
0
 expected()
 : has_value( false )
 {
     contained.construct_error( std::exception_ptr() );
 }
 expected()
 : has_value( false )
 {
     contained.construct_error( error_type() );
 }