From 53b95c386de3023c9b47dc4091a68ead21e6b5fb Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 14 Sep 2007 21:05:46 +0000 Subject: [PATCH] Finalizes the fix to Bug #1260, making vtable_base an actual POD type (oops) and playing more nicely with reinterpret_cast (thanks to Brad King for the fixes). [SVN r39285] --- include/boost/function/function_base.hpp | 1 - include/boost/function/function_template.hpp | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/boost/function/function_base.hpp b/include/boost/function/function_base.hpp index 525703f..6458765 100644 --- a/include/boost/function/function_base.hpp +++ b/include/boost/function/function_base.hpp @@ -478,7 +478,6 @@ namespace boost { */ struct vtable_base { - vtable_base() : manager(0) { } void (*manager)(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op); diff --git a/include/boost/function/function_template.hpp b/include/boost/function/function_template.hpp index d4a6ccd..ec52c92 100644 --- a/include/boost/function/function_template.hpp +++ b/include/boost/function/function_template.hpp @@ -434,8 +434,8 @@ namespace boost { void clear(function_buffer& functor) const { - if (manager) - manager(functor, functor, destroy_functor_tag); + if (base.manager) + base.manager(functor, functor, destroy_functor_tag); } private: @@ -538,9 +538,7 @@ namespace boost { } public: - void (*manager)(const function_buffer& in_buffer, - function_buffer& out_buffer, - functor_manager_operation_type op); + vtable_base base; invoker_type invoker; }; } // end namespace function @@ -780,10 +778,9 @@ namespace boost { typedef typename handler_type::manager_type manager_type; static const vtable_type stored_vtable = - { &manager_type::manage, &invoker_type::invoke }; + { { &manager_type::manage }, &invoker_type::invoke }; - if (stored_vtable.assign_to(f, functor)) - vtable = reinterpret_cast(&stored_vtable); + if (stored_vtable.assign_to(f, functor)) vtable = &stored_vtable.base; else vtable = 0; } };