From 2e19728cdb204aa2a77e8b93238a0524e6fa4c47 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 8 Jun 2010 23:55:25 +0000 Subject: [PATCH] Removed all but one old-style cast, breaking GCC 2.95.3; fixes #3410 [SVN r62614] --- include/boost/function/function_base.hpp | 12 +++++++----- include/boost/function/function_template.hpp | 12 ++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/boost/function/function_base.hpp b/include/boost/function/function_base.hpp index fe9bbbe..e092f01 100644 --- a/include/boost/function/function_base.hpp +++ b/include/boost/function/function_base.hpp @@ -315,7 +315,7 @@ namespace boost { if (op == clone_functor_tag || op == move_functor_tag) { const functor_type* in_functor = reinterpret_cast(&in_buffer.data); - new ((void*)&out_buffer.data) functor_type(*in_functor); + new (reinterpret_cast(&out_buffer.data)) functor_type(*in_functor); if (op == move_functor_tag) { reinterpret_cast(&in_buffer.data)->~Functor(); @@ -369,8 +369,10 @@ namespace boost { // Clone the functor // GCC 2.95.3 gets the CV qualifiers wrong here, so we // can't do the static_cast that we should do. + // jewillco: Changing this to static_cast because GCC 2.95.3 is + // obsolete. const functor_type* f = - (const functor_type*)(in_buffer.obj_ptr); + static_cast(in_buffer.obj_ptr); functor_type* new_f = new functor_type(*f); out_buffer.obj_ptr = new_f; } else if (op == move_functor_tag) { @@ -474,7 +476,7 @@ namespace boost { // GCC 2.95.3 gets the CV qualifiers wrong here, so we // can't do the static_cast that we should do. const functor_wrapper_type* f = - (const functor_wrapper_type*)(in_buffer.obj_ptr); + static_cast(in_buffer.obj_ptr); wrapper_allocator_type wrapper_allocator(static_cast(*f)); wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1); wrapper_allocator.construct(copy, *f); @@ -671,7 +673,7 @@ public: detail::function::check_functor_type_tag); // GCC 2.95.3 gets the CV qualifiers wrong here, so we // can't do the static_cast that we should do. - return (const Functor*)(type_result.obj_ptr); + return static_cast(type_result.obj_ptr); } template @@ -715,7 +717,7 @@ public: public: // should be protected, but GCC 2.95.3 will fail to allow access detail::function::vtable_base* get_vtable() const { return reinterpret_cast( - reinterpret_cast(vtable) & ~(std::size_t)0x01); + reinterpret_cast(vtable) & ~static_cast(0x01)); } bool has_trivial_copy_and_destroy() const { diff --git a/include/boost/function/function_template.hpp b/include/boost/function/function_template.hpp index 6a99109..9539e64 100644 --- a/include/boost/function/function_template.hpp +++ b/include/boost/function/function_template.hpp @@ -514,7 +514,7 @@ namespace boost { if (f) { // should be a reinterpret cast, but some compilers insist // on giving cv-qualifiers to free functions - functor.func_ptr = (void (*)())(f); + functor.func_ptr = reinterpret_cast(f); return true; } else { return false; @@ -563,7 +563,7 @@ namespace boost { void assign_functor(FunctionObj f, function_buffer& functor, mpl::true_) { - new ((void*)&functor.data) FunctionObj(f); + new (reinterpret_cast(&functor.data)) FunctionObj(f); } template void @@ -625,7 +625,7 @@ namespace boost { assign_to(const reference_wrapper& f, function_buffer& functor, function_obj_ref_tag) { - functor.obj_ref.obj_ptr = (void *)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; @@ -677,7 +677,7 @@ namespace boost { vtable_type* get_vtable() const { return reinterpret_cast( - reinterpret_cast(vtable) & ~(std::size_t)0x01); + reinterpret_cast(vtable) & ~static_cast(0x01)); } struct clear_type {}; @@ -917,7 +917,7 @@ namespace boost { if (boost::has_trivial_copy_constructor::value && boost::has_trivial_destructor::value && detail::function::function_allows_small_object_optimization::value) - value |= (std::size_t)0x01; + value |= static_cast(0x01); vtable = reinterpret_cast(value); } else vtable = 0; @@ -951,7 +951,7 @@ namespace boost { if (boost::has_trivial_copy_constructor::value && boost::has_trivial_destructor::value && detail::function::function_allows_small_object_optimization::value) - value |= (std::size_t)0x01; + value |= static_cast(0x01); vtable = reinterpret_cast(value); } else vtable = 0;