diff --git a/SG14/inplace_function.h b/SG14/inplace_function.h index 0ccf26b0..59453966 100644 --- a/SG14/inplace_function.h +++ b/SG14/inplace_function.h @@ -225,7 +225,7 @@ class inplace_function typename C = std::decay_t, typename = std::enable_if_t< !inplace_function_detail::is_inplace_function::value - && inplace_function_detail::is_invocable_r::value + && inplace_function_detail::is_invocable_r::value > > inplace_function(T&& closure) diff --git a/SG14_test/inplace_function_test.cpp b/SG14_test/inplace_function_test.cpp index 42009876..5fd228be 100644 --- a/SG14_test/inplace_function_test.cpp +++ b/SG14_test/inplace_function_test.cpp @@ -447,6 +447,26 @@ static void test_is_convertible() static_assert(std::is_convertible>::value, ""); } +static void test_convertibility_with_qualified_call_operators() +{ + struct Callable { void operator()() {} }; + struct LvalueOnlyCallable { void operator()() & {} }; + struct RvalueOnlyCallable { void operator()() && {} }; + struct ConstCallable { void operator()() const {} }; + struct ConstOnlyCallable { void operator()() const {} void operator()() = delete; }; + struct NonconstOnlyCallable { void operator()() {} void operator()() const = delete; }; + struct LvalueConstCallable { void operator()() const & {} }; + struct NoexceptCallable { void operator()() noexcept {} }; + static_assert(std::is_convertible>::value, ""); + static_assert(std::is_convertible>::value, ""); + static_assert(!std::is_convertible>::value, ""); + static_assert(std::is_convertible>::value, ""); + static_assert(!std::is_convertible>::value, ""); + static_assert(std::is_convertible>::value, ""); + static_assert(std::is_convertible>::value, ""); + static_assert(std::is_convertible>::value, ""); +} + namespace { struct InstrumentedCopyConstructor { static int copies; @@ -673,6 +693,7 @@ void sg14_test::inplace_function_test() test_move_construction_is_noexcept(); test_move_construction_from_smaller_buffer_is_noexcept(); test_is_convertible(); + test_convertibility_with_qualified_call_operators(); test_return_by_move(); test_is_invocable(); test_overloading();