diff --git a/include/boost/function/function_template.hpp b/include/boost/function/function_template.hpp index e02b9bd..6a99109 100644 --- a/include/boost/function/function_template.hpp +++ b/include/boost/function/function_template.hpp @@ -625,14 +625,10 @@ namespace boost { assign_to(const reference_wrapper& f, function_buffer& functor, function_obj_ref_tag) { - if (!boost::detail::function::has_empty_target(f.get_pointer())) { - functor.obj_ref.obj_ptr = (void *)f.get_pointer(); - functor.obj_ref.is_const_qualified = is_const::value; - functor.obj_ref.is_volatile_qualified = is_volatile::value; - return true; - } else { - return false; - } + functor.obj_ref.obj_ptr = (void *)f.get_pointer(); + functor.obj_ref.is_const_qualified = is_const::value; + functor.obj_ref.is_volatile_qualified = is_volatile::value; + return true; } template bool diff --git a/test/function_test.cpp b/test/function_test.cpp index 9870ac7..faf4bfb 100644 --- a/test/function_test.cpp +++ b/test/function_test.cpp @@ -629,6 +629,30 @@ test_ref() } } +static void dummy() {} + +static void test_empty_ref() +{ + boost::function f1; + boost::function f2(boost::ref(f1)); + + try { + f2(); + BOOST_ERROR("Exception didn't throw for reference to empty function."); + } + catch(runtime_error e) {} + + f1 = dummy; + + try { + f2(); + } + catch(runtime_error e) { + BOOST_ERROR("Error calling referenced function."); + } +} + + static void test_exception() { boost::function f; @@ -674,6 +698,7 @@ int test_main(int, char* []) test_emptiness(); test_member_functions(); test_ref(); + test_empty_ref(); test_exception(); test_implicit(); test_call();