File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -585,6 +585,18 @@ T const & conditional_forward( T && t, std11::false_type )
585585 return t;
586586}
587587
588+ template < typename T >
589+ T && conditional_move( T && t, std11::true_type )
590+ {
591+ return std::move ( t );
592+ }
593+
594+ template < typename T >
595+ T const & conditional_move ( T && t, std11::false_type )
596+ {
597+ return t;
598+ }
599+
588600// template< typename FE, typename Fn >
589601// struct to_argument_type<EF,Fn>
590602// {
@@ -885,20 +897,25 @@ class unique_resource
885897 scope_noexcept_op (
886898 std11::is_nothrow_move_constructible<R1>::value && std11::is_nothrow_move_constructible<D>::value
887899 )
888- : resource( std::move( other.resource ) ) // conditional_move() if std::is_nothrow_move_constructible_v<RS> is true
889- , deleter( std::move( other.deleter ) ) // conditional_move() if std::is_nothrow_move_constructible_v<D> is true
900+ try
901+ : resource( conditional_move( std::move(other.resource), typename std11::bool_constant< std11::is_nothrow_move_assignable<R>::value >() ) )
902+ , deleter( conditional_move( std::move(other.deleter ), typename std11::bool_constant< std11::is_nothrow_move_constructible<D>::value >() ) )
890903 , execute_on_reset( std14::exchange( other.execute_on_reset, false ) )
904+ {}
905+ catch (...)
891906 {
892- other.release ();
907+ if ( other.execute_on_reset && std::is_nothrow_move_constructible<R>::value )
908+ {
909+ other.get_deleter ()(get ());
910+ other.release ();
911+ }
893912 }
894913
895914 ~unique_resource ()
896915 {
897916 reset ();
898917 }
899918
900- // TODO: operator=(unique_resource && other)
901-
902919private:
903920 // assign_rd( r, is_nothrow_move_assignable_v<R>, is_nothrow_move_assignable_v<D> ):
904921
You can’t perform that action at this time.
0 commit comments