Skip to content

Commit

Permalink
Remove BOOST_NO_CXX11_ALLOCATOR workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jan 27, 2024
1 parent a9a0f90 commit f898d3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
15 changes: 1 addition & 14 deletions include/boost/function/function_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,9 @@ namespace boost {
functor_manager_operation_type op, false_type)
{
typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
#if defined(BOOST_NO_CXX11_ALLOCATOR)
typedef typename Allocator::template rebind<functor_wrapper_type>::other
wrapper_allocator_type;
typedef typename wrapper_allocator_type::pointer wrapper_allocator_pointer_type;
#else

using wrapper_allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<functor_wrapper_type>;
using wrapper_allocator_pointer_type = typename std::allocator_traits<wrapper_allocator_type>::pointer;
#endif

if (op == clone_functor_tag) {
// Clone the functor
Expand All @@ -430,11 +425,7 @@ namespace boost {
static_cast<const functor_wrapper_type*>(in_buffer.members.obj_ptr);
wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*f));
wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
#if defined(BOOST_NO_CXX11_ALLOCATOR)
wrapper_allocator.construct(copy, *f);
#else
std::allocator_traits<wrapper_allocator_type>::construct(wrapper_allocator, copy, *f);
#endif

// Get back to the original pointer type
functor_wrapper_type* new_f = static_cast<functor_wrapper_type*>(copy);
Expand All @@ -447,11 +438,7 @@ namespace boost {
functor_wrapper_type* victim =
static_cast<functor_wrapper_type*>(in_buffer.members.obj_ptr);
wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*victim));
#if defined(BOOST_NO_CXX11_ALLOCATOR)
wrapper_allocator.destroy(victim);
#else
std::allocator_traits<wrapper_allocator_type>::destroy(wrapper_allocator, victim);
#endif
wrapper_allocator.deallocate(victim,1);
out_buffer.members.obj_ptr = 0;
} else if (op == check_functor_type_tag) {
Expand Down
13 changes: 3 additions & 10 deletions include/boost/function/function_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,21 +552,14 @@ namespace boost {
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, false_type) const
{
typedef functor_wrapper<FunctionObj,Allocator> functor_wrapper_type;
#if defined(BOOST_NO_CXX11_ALLOCATOR)
typedef typename Allocator::template rebind<functor_wrapper_type>::other
wrapper_allocator_type;
typedef typename wrapper_allocator_type::pointer wrapper_allocator_pointer_type;
#else

using wrapper_allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<functor_wrapper_type>;
using wrapper_allocator_pointer_type = typename std::allocator_traits<wrapper_allocator_type>::pointer;
#endif

wrapper_allocator_type wrapper_allocator(a);
wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
#if defined(BOOST_NO_CXX11_ALLOCATOR)
wrapper_allocator.construct(copy, functor_wrapper_type(f,a));
#else
std::allocator_traits<wrapper_allocator_type>::construct(wrapper_allocator, copy, functor_wrapper_type(f,a));
#endif

functor_wrapper_type* new_f = static_cast<functor_wrapper_type*>(copy);
functor.members.obj_ptr = new_f;
}
Expand Down

0 comments on commit f898d3a

Please sign in to comment.