diff --git a/src/boost/function/function_base.hpp b/src/boost/function/function_base.hpp index c209a790..3e168015 100644 --- a/src/boost/function/function_base.hpp +++ b/src/boost/function/function_base.hpp @@ -41,7 +41,7 @@ # pragma warning( push ) # pragma warning( disable : 4793 ) // complaint about native code generation # pragma warning( disable : 4127 ) // "conditional expression is constant" -#endif +#endif // Define BOOST_FUNCTION_STD_NS to the namespace that contains type_info. #ifdef BOOST_NO_STD_TYPEINFO @@ -120,8 +120,11 @@ namespace network_boost { bool is_volatile_qualified; } obj_ref; - // To relax aliasing constraints - mutable char data; + // To relax aliasing constraints (HACK - I'm making data at + // least as big as the things above to avoid a placement-new + // error we're getting with gcc6. Not sure if that makes this + // comment now irrelevant) + mutable char data[sizeof(bound_memfunc_ptr_t)]; }; /** @@ -188,11 +191,11 @@ namespace network_boost { struct reference_manager { static inline void - manage(const function_buffer& in_buffer, function_buffer& out_buffer, + manage(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op) { switch (op) { - case clone_functor_tag: + case clone_functor_tag: out_buffer.obj_ref = in_buffer.obj_ref; return; @@ -207,13 +210,13 @@ namespace network_boost { case check_functor_type_tag: { - const detail::sp_typeinfo& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; // Check whether we have the same type. We can add // cv-qualifiers, but we can't take them away. if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(F)) - && (!in_buffer.obj_ref.is_const_qualified + && (!in_buffer.obj_ref.is_const_qualified || out_buffer.type.const_qualified) && (!in_buffer.obj_ref.is_volatile_qualified || out_buffer.type.volatile_qualified)) @@ -240,9 +243,9 @@ namespace network_boost { struct function_allows_small_object_optimization { BOOST_STATIC_CONSTANT - (bool, + (bool, value = ((sizeof(F) <= sizeof(function_buffer) && - (alignment_of::value + (alignment_of::value % alignment_of::value == 0)))); }; @@ -254,7 +257,7 @@ namespace network_boost { A(a) { } - + functor_wrapper(const functor_wrapper& f) : F(static_cast(f)), A(static_cast(f)) @@ -273,7 +276,7 @@ namespace network_boost { // Function pointers static inline void - manage_ptr(const function_buffer& in_buffer, function_buffer& out_buffer, + manage_ptr(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op) { if (op == clone_functor_tag) @@ -299,11 +302,11 @@ namespace network_boost { // Function objects that fit in the small-object buffer. static inline void - manage_small(const function_buffer& in_buffer, function_buffer& out_buffer, + manage_small(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op) { if (op == clone_functor_tag || op == move_functor_tag) { - const functor_type* in_functor = + const functor_type* in_functor = reinterpret_cast(&in_buffer.data); new (reinterpret_cast(&out_buffer.data)) functor_type(*in_functor); @@ -318,7 +321,7 @@ namespace network_boost { (void)f; // suppress warning about the value of f not being used (MSVC) f->~Functor(); } else if (op == check_functor_type_tag) { - const detail::sp_typeinfo& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(Functor))) out_buffer.obj_ptr = &in_buffer.data; @@ -327,7 +330,7 @@ namespace network_boost { } else /* op == get_functor_type_tag */ { out_buffer.type.type = &BOOST_SP_TYPEID(Functor); out_buffer.type.const_qualified = false; - out_buffer.type.volatile_qualified = false; + out_buffer.type.volatile_qualified = false; } } }; @@ -340,7 +343,7 @@ namespace network_boost { // Function pointers static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, function_ptr_tag) { functor_manager_common::manage_ptr(in_buffer,out_buffer,op); @@ -348,15 +351,15 @@ namespace network_boost { // Function objects that fit in the small-object buffer. static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, mpl::true_) { functor_manager_common::manage_small(in_buffer,out_buffer,op); } - + // Function objects that require heap allocation static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, mpl::false_) { if (op == clone_functor_tag) { @@ -396,7 +399,7 @@ namespace network_boost { // object can use the small-object optimization buffer or // whether we need to allocate it on the heap. static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, function_obj_tag) { manager(in_buffer, out_buffer, op, @@ -405,7 +408,7 @@ namespace network_boost { // For member pointers, we use the small-object optimization buffer. static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, member_ptr_tag) { manager(in_buffer, out_buffer, op, mpl::true_()); @@ -415,7 +418,7 @@ namespace network_boost { /* Dispatch to an appropriate manager based on whether we have a function pointer or a function object pointer. */ static inline void - manage(const function_buffer& in_buffer, function_buffer& out_buffer, + manage(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op) { typedef typename get_function_tag::type tag_type; @@ -441,7 +444,7 @@ namespace network_boost { // Function pointers static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, function_ptr_tag) { functor_manager_common::manage_ptr(in_buffer,out_buffer,op); @@ -449,15 +452,15 @@ namespace network_boost { // Function objects that fit in the small-object buffer. static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, mpl::true_) { functor_manager_common::manage_small(in_buffer,out_buffer,op); } - + // Function objects that require heap allocation static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, mpl::false_) { typedef functor_wrapper functor_wrapper_type; @@ -490,7 +493,7 @@ namespace network_boost { wrapper_allocator.deallocate(victim,1); out_buffer.obj_ptr = 0; } else if (op == check_functor_type_tag) { - const detail::sp_typeinfo& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(Functor))) out_buffer.obj_ptr = in_buffer.obj_ptr; @@ -507,7 +510,7 @@ namespace network_boost { // object can use the small-object optimization buffer or // whether we need to allocate it on the heap. static inline void - manager(const function_buffer& in_buffer, function_buffer& out_buffer, + manager(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op, function_obj_tag) { manager(in_buffer, out_buffer, op, @@ -518,7 +521,7 @@ namespace network_boost { /* Dispatch to an appropriate manager based on whether we have a function pointer or a function object pointer. */ static inline void - manage(const function_buffer& in_buffer, function_buffer& out_buffer, + manage(const function_buffer& in_buffer, function_buffer& out_buffer, functor_manager_operation_type op) { typedef typename get_function_tag::type tag_type; @@ -604,8 +607,8 @@ namespace network_boost { */ struct vtable_base { - void (*manager)(const function_buffer& in_buffer, - function_buffer& out_buffer, + void (*manager)(const function_buffer& in_buffer, + function_buffer& out_buffer, functor_manager_operation_type op); }; } // end namespace function @@ -645,7 +648,7 @@ class function_base type_result.type.type = &BOOST_SP_TYPEID(Functor); type_result.type.const_qualified = is_const::value; type_result.type.volatile_qualified = is_volatile::value; - get_vtable()->manager(functor, type_result, + get_vtable()->manager(functor, type_result, detail::function::check_functor_type_tag); return static_cast(type_result.obj_ptr); } @@ -659,7 +662,7 @@ class function_base type_result.type.type = &BOOST_SP_TYPEID(Functor); type_result.type.const_qualified = true; type_result.type.volatile_qualified = is_volatile::value; - get_vtable()->manager(functor, type_result, + get_vtable()->manager(functor, type_result, 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. @@ -887,6 +890,6 @@ namespace detail { #if defined(BOOST_MSVC) # pragma warning( pop ) -#endif +#endif #endif // BOOST_FUNCTION_BASE_HEADER