Ticket #13405: boost_container_move_fix.diff

File boost_container_move_fix.diff, 2.9 KB (added by Mikhail Kremniov <mkremniov@…>, 5 years ago)

Suggested fix

  • boost/container/detail/tree.hpp

     
    354354   typedef typename AllocHolder::intrusive_container  intrusive_container;
    355355   typedef typename AllocHolder::Node                 node_t;
    356356   typedef typename AllocHolder::NodePtr              node_ptr_type;
     357   typedef typename boost::container::container_detail::if_c<
     358      DoMove,
     359      node_t,
     360      const node_t>::type                             node_param_t;
    357361
    358362   public:
    359363   RecyclingCloner(AllocHolder &holder, intrusive_container &itree)
    360364      :  m_holder(holder), m_icont(itree)
    361365   {}
    362366
    363    BOOST_CONTAINER_FORCEINLINE static void do_assign(node_ptr_type &p, const node_t &other, bool_<true>)
    364    {  p->do_move_assign(const_cast<node_t &>(other).m_data);   }
     367   BOOST_CONTAINER_FORCEINLINE static void do_assign(node_ptr_type &p, node_t &other, bool_<true>)
     368   {  p->do_move_assign(other.m_data);   }
    365369
    366370   BOOST_CONTAINER_FORCEINLINE static void do_assign(node_ptr_type &p, const node_t &other, bool_<false>)
    367371   {  p->do_assign(other.m_data);   }
    368372
    369    node_ptr_type operator()(const node_t &other) const
     373   BOOST_CONTAINER_FORCEINLINE static node_ptr_type do_create_node(AllocHolder &holder, node_t &other, bool_<true>)
     374   {  return holder.create_node(::boost::move(other.m_data));   }
     375
     376   BOOST_CONTAINER_FORCEINLINE static node_ptr_type do_create_node(AllocHolder &holder, const node_t &other, bool_<false>)
     377   {  return holder.create_node(other.m_data);   }
     378
     379   node_ptr_type operator()(node_param_t &other) const
    370380   {
    371381      if(node_ptr_type p = m_icont.unlink_leftmost_without_rebalance()){
    372382         //First recycle a node (this can't throw)
     
    386396         BOOST_CATCH_END
    387397      }
    388398      else{
    389          return m_holder.create_node(other.m_data);
     399         return this->do_create_node(m_holder, other, bool_<DoMove>());
    390400      }
    391401   }
    392402
  • libs/container/test/map_test.cpp

     
    339339      test_move<map<recursive_map, recursive_map> >();
    340340      test_move<multimap<recursive_multimap, recursive_multimap> >();
    341341   }
     342   //Same, but with a move-only content.
     343   {
     344      test_move<map<test::movable_int, test::movable_int> >();
     345      test_move<multimap<test::movable_int, test::movable_int> >();
     346   }
    342347
    343348   //Test std::pair value type as tree has workarounds to make old std::pair
    344349   //implementations movable that can break things
  • libs/container/test/set_test.cpp

     
    335335      test_move<set<recursive_set> >();
    336336      test_move<multiset<recursive_multiset> >();
    337337   }
     338   //Same, but with a move-only content.
     339   {
     340      test_move<set<test::movable_int> >();
     341      test_move<multiset<test::movable_int> >();
     342   }
    338343   //Test std::pair value type as tree has workarounds to make old std::pair
    339344   //implementations movable that can break things
    340345   {