--- boost/container/detail/tree.hpp +++ boost/container/detail/tree.hpp @@ -354,19 +354,29 @@ typedef typename AllocHolder::intrusive_container intrusive_container; typedef typename AllocHolder::Node node_t; typedef typename AllocHolder::NodePtr node_ptr_type; + typedef typename boost::container::container_detail::if_c< + DoMove, + node_t, + const node_t>::type node_param_t; public: RecyclingCloner(AllocHolder &holder, intrusive_container &itree) : m_holder(holder), m_icont(itree) {} - BOOST_CONTAINER_FORCEINLINE static void do_assign(node_ptr_type &p, const node_t &other, bool_) - { p->do_move_assign(const_cast(other).m_data); } + BOOST_CONTAINER_FORCEINLINE static void do_assign(node_ptr_type &p, node_t &other, bool_) + { p->do_move_assign(other.m_data); } BOOST_CONTAINER_FORCEINLINE static void do_assign(node_ptr_type &p, const node_t &other, bool_) { p->do_assign(other.m_data); } - node_ptr_type operator()(const node_t &other) const + BOOST_CONTAINER_FORCEINLINE static node_ptr_type do_create_node(AllocHolder &holder, node_t &other, bool_) + { return holder.create_node(::boost::move(other.m_data)); } + + BOOST_CONTAINER_FORCEINLINE static node_ptr_type do_create_node(AllocHolder &holder, const node_t &other, bool_) + { return holder.create_node(other.m_data); } + + node_ptr_type operator()(node_param_t &other) const { if(node_ptr_type p = m_icont.unlink_leftmost_without_rebalance()){ //First recycle a node (this can't throw) @@ -386,7 +396,7 @@ BOOST_CATCH_END } else{ - return m_holder.create_node(other.m_data); + return this->do_create_node(m_holder, other, bool_()); } } --- libs/container/test/map_test.cpp +++ libs/container/test/map_test.cpp @@ -339,6 +339,11 @@ test_move >(); test_move >(); } + //Same, but with a move-only content. + { + test_move >(); + test_move >(); + } //Test std::pair value type as tree has workarounds to make old std::pair //implementations movable that can break things --- libs/container/test/set_test.cpp 2017-09-02 12:56:10.000000000 +0300 +++ libs/container/test/set_test.cpp 2018-01-16 16:41:47.618011594 +0200 @@ -335,6 +335,11 @@ test_move >(); test_move >(); } + //Same, but with a move-only content. + { + test_move >(); + test_move >(); + } //Test std::pair value type as tree has workarounds to make old std::pair //implementations movable that can break things {