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 )
585
585
return t;
586
586
}
587
587
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
+
588
600
// template< typename FE, typename Fn >
589
601
// struct to_argument_type<EF,Fn>
590
602
// {
@@ -885,20 +897,25 @@ class unique_resource
885
897
scope_noexcept_op (
886
898
std11::is_nothrow_move_constructible<R1>::value && std11::is_nothrow_move_constructible<D>::value
887
899
)
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 >() ) )
890
903
, execute_on_reset( std14::exchange( other.execute_on_reset, false ) )
904
+ {}
905
+ catch (...)
891
906
{
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
+ }
893
912
}
894
913
895
914
~unique_resource ()
896
915
{
897
916
reset ();
898
917
}
899
918
900
- // TODO: operator=(unique_resource && other)
901
-
902
919
private:
903
920
// assign_rd( r, is_nothrow_move_assignable_v<R>, is_nothrow_move_assignable_v<D> ):
904
921
You can’t perform that action at this time.
0 commit comments