diff --git a/include/boost/function/function_base.hpp b/include/boost/function/function_base.hpp index 6f3647b..23f0693 100644 --- a/include/boost/function/function_base.hpp +++ b/include/boost/function/function_base.hpp @@ -10,7 +10,7 @@ // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. - + // For more information, see http://www.boost.org #ifndef BOOST_FUNCTION_BASE_HEADER @@ -39,7 +39,7 @@ template > class function; template -inline void swap(function& f1, +inline void swap(function& f1, function& f2) { f1.swap(f2); @@ -53,38 +53,38 @@ namespace boost { namespace function { /** * A union of a function pointer and a void pointer. This is necessary - * because 5.2.10/6 allows reinterpret_cast<> to safely cast between + * because 5.2.10/6 allows reinterpret_cast<> to safely cast between * function pointer types and 5.2.9/10 allows static_cast<> to safely * cast between a void pointer and an object pointer. But it is not legal * to cast between a function pointer and a void* (in either direction), * so function requires a union of the two. */ - union any_pointer + union any_pointer { void* obj_ptr; const void* const_obj_ptr; void (*func_ptr)(); - char data[1]; + char data[1]; }; any_pointer make_any_pointer(void* o) { - any_pointer p; - p.obj_ptr = o; - return p; + any_pointer p; + p.obj_ptr = o; + return p; } any_pointer make_any_pointer(const void* o) { - any_pointer p; - p.const_obj_ptr = o; - return p; + any_pointer p; + p.const_obj_ptr = o; + return p; } any_pointer make_any_pointer(void (*f)()) { - any_pointer p; - p.obj_ptr = f; - return p; + any_pointer p; + p.func_ptr = f; + return p; } /** @@ -93,7 +93,7 @@ namespace boost { * anything. This helps compilers without partial specialization to * handle Boost.Function objects returning void. */ - struct unusable + struct unusable { unusable() {} template unusable(const T&) {} @@ -101,19 +101,19 @@ namespace boost { /* Determine the return type. This supports compilers that do not support * void returns or partial specialization by silently changing the return - * type to "unusable". + * type to "unusable". */ template struct function_return_type { typedef T type; }; - template<> - struct function_return_type + template<> + struct function_return_type { typedef unusable type; }; // The operation type to perform on the given functor/function pointer - enum functor_manager_operation_type { - clone_functor_tag, + enum functor_manager_operation_type { + clone_functor_tag, destroy_functor_tag }; @@ -147,7 +147,7 @@ namespace boost { // The trivial manager does nothing but return the same pointer (if we // are cloning) or return the null pointer (if we are deleting). - inline any_pointer trivial_manager(any_pointer f, + inline any_pointer trivial_manager(any_pointer f, functor_manager_operation_type op) { if (op == clone_functor_tag) @@ -158,7 +158,7 @@ namespace boost { /** * The functor_manager class contains a static function "manage" which - * can clone or destroy the given function/function object pointer. + * can clone or destroy the given function/function object pointer. */ template struct functor_manager @@ -168,7 +168,7 @@ namespace boost { // For function pointers, the manager is trivial static inline any_pointer - manager(any_pointer function_ptr, + manager(any_pointer function_ptr, functor_manager_operation_type op, function_ptr_tag) { @@ -178,15 +178,15 @@ namespace boost { return make_any_pointer(static_cast(0)); } - // For function object pointers, we clone the pointer to each + // For function object pointers, we clone the pointer to each // function has its own version. static inline any_pointer - manager(any_pointer function_obj_ptr, + manager(any_pointer function_obj_ptr, functor_manager_operation_type op, function_obj_tag) { #ifndef BOOST_NO_STD_ALLOCATOR - typedef typename Allocator::template rebind::other + typedef typename Allocator::template rebind::other allocator_type; typedef typename allocator_type::pointer pointer_type; #else @@ -198,7 +198,7 @@ namespace boost { # endif // BOOST_NO_STD_ALLOCATOR if (op == clone_functor_tag) { - functor_type* f = + functor_type* f = static_cast(function_obj_ptr.obj_ptr); // Clone the functor @@ -215,7 +215,7 @@ namespace boost { } else { /* Cast from the void pointer to the functor pointer type */ - functor_type* f = + functor_type* f = reinterpret_cast(function_obj_ptr.obj_ptr); # ifndef BOOST_NO_STD_ALLOCATOR @@ -250,27 +250,27 @@ namespace boost { * The function_base class contains the basic elements needed for the * function1, function2, function3, etc. classes. It is common to all * functions (and as such can be used to tell if we have one of the - * functionN objects). + * functionN objects). */ - class function_base + class function_base { public: - function_base() : manager(0) + function_base() : manager(0) { functor.obj_ptr = 0; } - + // Is this function empty? bool empty() const { return !manager; } - + public: // should be protected, but GCC 2.95.3 will fail to allow access detail::function::any_pointer (*manager)( - detail::function::any_pointer, + detail::function::any_pointer, detail::function::functor_manager_operation_type); detail::function::any_pointer functor; }; - /* Poison comparison between Boost.Function objects (because it is + /* Poison comparison between Boost.Function objects (because it is * meaningless). The comparisons would otherwise be allowed because of the * conversion required to allow syntax such as: * boost::function f; diff --git a/test/stateless_test.cpp b/test/stateless_test.cpp index 91a4b7d..365d847 100644 --- a/test/stateless_test.cpp +++ b/test/stateless_test.cpp @@ -40,7 +40,7 @@ namespace boost { int test_main(int, char*[]) { - boost::function f; + boost::function2 f; f = stateless_integer_add(); return 0;