diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index 28e7ae9..b130993 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -49,17 +49,17 @@ struct move_insert_range_proxy typedef typename allocator_traits::size_type size_type; typedef typename allocator_traits::value_type value_type; - explicit move_insert_range_proxy(FwdIt first) + BOOST_CONTAINER_FORCEINLINE explicit move_insert_range_proxy(FwdIt first) : first_(first) {} - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->first_ = ::boost::container::uninitialized_move_alloc_n_source (a, this->first_, n, p); } - void copy_n_and_update(Allocator &, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n) { this->first_ = ::boost::container::move_n_source(this->first_, n, p); } @@ -74,16 +74,16 @@ struct insert_range_proxy typedef typename allocator_traits::size_type size_type; typedef typename allocator_traits::value_type value_type; - explicit insert_range_proxy(FwdIt first) + BOOST_CONTAINER_FORCEINLINE explicit insert_range_proxy(FwdIt first) : first_(first) {} - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->first_ = ::boost::container::uninitialized_copy_alloc_n_source(a, this->first_, n, p); } - void copy_n_and_update(Allocator &, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n) { this->first_ = ::boost::container::copy_n_source(this->first_, n, p); } @@ -98,14 +98,14 @@ struct insert_n_copies_proxy typedef typename allocator_traits::size_type size_type; typedef typename allocator_traits::value_type value_type; - explicit insert_n_copies_proxy(const value_type &v) + BOOST_CONTAINER_FORCEINLINE explicit insert_n_copies_proxy(const value_type &v) : v_(v) {} - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_fill_alloc_n(a, v_, n, p); } - void copy_n_and_update(Allocator &, Iterator p, size_type n) const + BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n) const { for (; 0 < n; --n, ++p){ *p = v_; @@ -122,7 +122,7 @@ struct insert_value_initialized_n_proxy typedef typename allocator_traits::size_type size_type; typedef typename allocator_traits::value_type value_type; - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_value_init_alloc_n(a, n, p); } void copy_n_and_update(Allocator &a, Iterator p, size_type n) const @@ -144,7 +144,7 @@ struct insert_default_initialized_n_proxy typedef typename allocator_traits::size_type size_type; typedef typename allocator_traits::value_type value_type; - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_default_init_alloc_n(a, n, p); } void copy_n_and_update(Allocator &a, Iterator p, size_type n) const @@ -168,17 +168,19 @@ struct insert_copy_proxy typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; - explicit insert_copy_proxy(const value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_copy_proxy(const value_type &v) : v_(v) {} - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), v_); } - void copy_n_and_update(Allocator &, Iterator p, size_type n) const + BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; *p = v_; @@ -195,6 +197,8 @@ struct insert_move_proxy typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; + static const bool single_value = true; + BOOST_CONTAINER_FORCEINLINE explicit insert_move_proxy(value_type &v) : v_(v) {} @@ -215,13 +219,13 @@ struct insert_move_proxy }; template -insert_move_proxy get_insert_value_proxy(BOOST_RV_REF(typename boost::container::iterator_traits::value_type) v) +BOOST_CONTAINER_FORCEINLINE insert_move_proxy get_insert_value_proxy(BOOST_RV_REF(typename boost::container::iterator_traits::value_type) v) { return insert_move_proxy(v); } template -insert_copy_proxy get_insert_value_proxy(const typename boost::container::iterator_traits::value_type &v) +BOOST_CONTAINER_FORCEINLINE insert_copy_proxy get_insert_value_proxy(const typename boost::container::iterator_traits::value_type &v) { return insert_copy_proxy(v); } @@ -243,19 +247,20 @@ struct insert_nonmovable_emplace_proxy typedef boost::container::allocator_traits alloc_traits; typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; - typedef typename build_number_seq::type index_tuple_t; - explicit insert_nonmovable_emplace_proxy(BOOST_FWD_REF(Args)... args) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_nonmovable_emplace_proxy(BOOST_FWD_REF(Args)... args) : args_(args...) {} - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->priv_uninitialized_copy_some_and_update(a, index_tuple_t(), p, n); } private: template - void priv_uninitialized_copy_some_and_update(Allocator &a, const index_tuple&, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void priv_uninitialized_copy_some_and_update(Allocator &a, const index_tuple&, Iterator p, size_type n) { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), ::boost::forward(get(this->args_))... ); @@ -275,23 +280,24 @@ struct insert_emplace_proxy typedef typename base_t::size_type size_type; typedef typename base_t::index_tuple_t index_tuple_t; - explicit insert_emplace_proxy(BOOST_FWD_REF(Args)... args) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy(BOOST_FWD_REF(Args)... args) : base_t(::boost::forward(args)...) {} - void copy_n_and_update(Allocator &a, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->priv_copy_some_and_update(a, index_tuple_t(), p, n); } private: template - void priv_copy_some_and_update(Allocator &a, const index_tuple&, Iterator p, size_type n) + BOOST_CONTAINER_FORCEINLINE void priv_copy_some_and_update(Allocator &a, const index_tuple&, Iterator p, size_type n) { BOOST_ASSERT(n ==1); (void)n; typename dtl::aligned_storage::value>::type v; value_type *vp = reinterpret_cast(v.data); - alloc_traits::construct(a, vp, - ::boost::forward(get(this->args_))...); + alloc_traits::construct(a, vp, ::boost::forward(get(this->args_))...); BOOST_TRY{ *p = ::boost::move(*vp); } @@ -309,7 +315,9 @@ template struct insert_emplace_proxy::value_type> : public insert_move_proxy { - explicit insert_emplace_proxy(typename boost::container::allocator_traits::value_type &&v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy(typename boost::container::allocator_traits::value_type &&v) : insert_move_proxy(v) {} }; @@ -323,7 +331,10 @@ struct insert_emplace_proxy : public insert_copy_proxy { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) + + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) : insert_copy_proxy(v) {} }; @@ -332,7 +343,9 @@ template struct insert_emplace_proxy::value_type &> : public insert_copy_proxy { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) : insert_copy_proxy(v) {} }; @@ -343,7 +356,9 @@ struct insert_emplace_proxy : public insert_copy_proxy { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) : insert_copy_proxy(v) {} }; @@ -366,16 +381,18 @@ struct insert_nonmovable_emplace_proxy##N\ typedef typename alloc_traits::size_type size_type;\ typedef typename alloc_traits::value_type value_type;\ \ - explicit insert_nonmovable_emplace_proxy##N(BOOST_MOVE_UREF##N)\ + static const bool single_value = true;\ + \ + BOOST_CONTAINER_FORCEINLINE explicit insert_nonmovable_emplace_proxy##N(BOOST_MOVE_UREF##N)\ BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N {}\ \ - void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)\ + BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)\ {\ BOOST_ASSERT(n == 1); (void)n;\ alloc_traits::construct(a, boost::movelib::iterator_to_raw_pointer(p) BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\ }\ \ - void copy_n_and_update(Allocator &, Iterator, size_type)\ + BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator, size_type)\ { BOOST_ASSERT(false); }\ \ protected:\ @@ -392,10 +409,12 @@ struct insert_emplace_proxy_arg##N\ typedef typename base_t::size_type size_type;\ typedef boost::container::allocator_traits alloc_traits;\ \ - explicit insert_emplace_proxy_arg##N(BOOST_MOVE_UREF##N)\ + static const bool single_value = true;\ + \ + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg##N(BOOST_MOVE_UREF##N)\ : base_t(BOOST_MOVE_FWD##N){}\ \ - void copy_n_and_update(Allocator &a, Iterator p, size_type n)\ + BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &a, Iterator p, size_type n)\ {\ BOOST_ASSERT(n == 1); (void)n;\ typename dtl::aligned_storage::value>::type v;\ @@ -424,7 +443,9 @@ template struct insert_emplace_proxy_arg1::value_type> > : public insert_move_proxy { - explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &v) : insert_move_proxy(v) {} }; @@ -433,7 +454,9 @@ template struct insert_emplace_proxy_arg1::value_type> : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) : insert_copy_proxy(v) {} }; @@ -445,7 +468,9 @@ template struct insert_emplace_proxy_arg1::value_type> : public insert_move_proxy { - explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &&v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &&v) : insert_move_proxy(v) {} }; @@ -459,7 +484,9 @@ struct insert_emplace_proxy_arg1 : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) : insert_copy_proxy(v) {} }; @@ -468,7 +495,9 @@ template struct insert_emplace_proxy_arg1::value_type &> : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) : insert_copy_proxy(v) {} }; @@ -479,7 +508,9 @@ struct insert_emplace_proxy_arg1 : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + static const bool single_value = true; + + BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) : insert_copy_proxy(v) {} }; @@ -490,6 +521,40 @@ struct insert_emplace_proxy_arg1 +struct has_single_value +{ + private: + struct two {char array_[2];}; + template struct wrapper; + template static two test(int, ...); + template static char test(int, const wrapper*); + public: + static const bool value = sizeof(test(0, 0)) == 1; + void dummy(){} +}; + +template::value> +struct is_single_value_proxy_impl +{ + static const bool value = InsertionProxy::single_value; +}; + +template +struct is_single_value_proxy_impl +{ + static const bool value = false; +}; + +template +struct is_single_value_proxy + : is_single_value_proxy_impl +{}; + +}}} //namespace boost { namespace container { namespace dtl { + #include #endif //#ifndef BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP