diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:45:20 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:46:37 +0900 |
commit | 733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /boost/container/detail | |
parent | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff) | |
download | boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.gz boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.bz2 boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.zip |
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/container/detail')
48 files changed, 1801 insertions, 1787 deletions
diff --git a/boost/container/detail/adaptive_node_pool.hpp b/boost/container/detail/adaptive_node_pool.hpp index 4e7375412b..4a1f07c4a8 100644 --- a/boost/container/detail/adaptive_node_pool.hpp +++ b/boost/container/detail/adaptive_node_pool.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_HPP #define BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_HPP -#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -19,13 +23,14 @@ #include <boost/container/detail/workaround.hpp> #include <boost/intrusive/set.hpp> -#include <boost/aligned_storage.hpp> #include <boost/container/detail/alloc_lib_auto_link.hpp> #include <boost/container/detail/multiallocation_chain.hpp> #include <boost/container/detail/pool_common_alloc.hpp> #include <boost/container/detail/mutex.hpp> #include <boost/container/detail/adaptive_node_pool_impl.hpp> #include <boost/container/detail/multiallocation_chain.hpp> +#include <boost/container/detail/type_traits.hpp> + #include <cstddef> #include <cmath> #include <cassert> diff --git a/boost/container/detail/adaptive_node_pool_impl.hpp b/boost/container/detail/adaptive_node_pool_impl.hpp index dc1a7f102e..24c81dda3b 100644 --- a/boost/container/detail/adaptive_node_pool_impl.hpp +++ b/boost/container/detail/adaptive_node_pool_impl.hpp @@ -11,24 +11,34 @@ #ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP #define BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> +// container #include <boost/container/container_fwd.hpp> -#include <boost/container/detail/utilities.hpp> +#include <boost/container/throw_exception.hpp> +// container/detail +#include <boost/container/detail/pool_common.hpp> +#include <boost/container/detail/iterator.hpp> +#include <boost/container/detail/iterator_to_raw_pointer.hpp> +#include <boost/container/detail/math_functions.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/to_raw_pointer.hpp> +#include <boost/container/detail/type_traits.hpp> +// intrusive #include <boost/intrusive/pointer_traits.hpp> #include <boost/intrusive/set.hpp> #include <boost/intrusive/list.hpp> #include <boost/intrusive/slist.hpp> -#include <boost/container/detail/type_traits.hpp> -#include <boost/container/detail/math_functions.hpp> -#include <boost/container/detail/mpl.hpp> -#include <boost/container/detail/pool_common.hpp> -#include <boost/container/throw_exception.hpp> +// other #include <boost/assert.hpp> #include <boost/core/no_exceptions_support.hpp> #include <cstddef> @@ -482,7 +492,7 @@ class private_adaptive_node_pool_impl free_nodes_iterator itf(nodes.begin()), itbf(itbb); size_type splice_node_count = size_type(-1); while(itf != ite){ - void *pElem = container_detail::to_raw_pointer(container_detail::iterator_to_pointer(itf)); + void *pElem = container_detail::to_raw_pointer(container_detail::iterator_to_raw_pointer(itf)); block_info_t &block_info = *this->priv_block_from_node(pElem); BOOST_ASSERT(block_info.free_nodes.size() < m_real_num_node); ++splice_node_count; diff --git a/boost/container/detail/addressof.hpp b/boost/container/detail/addressof.hpp new file mode 100644 index 0000000000..cc582c439d --- /dev/null +++ b/boost/container/detail/addressof.hpp @@ -0,0 +1,41 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_DETAIL_ADDRESSOF_HPP +#define BOOST_CONTAINER_DETAIL_ADDRESSOF_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include <cstddef> + +namespace boost { +namespace container { +namespace container_detail { + +template <typename T> +inline T* addressof(T& obj) +{ + return static_cast<T*>( + static_cast<void*>( + const_cast<char*>( + &reinterpret_cast<const char&>(obj) + ))); +} + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ADDRESSOF_HPP diff --git a/boost/container/detail/advanced_insert_int.hpp b/boost/container/detail/advanced_insert_int.hpp index a35279dcf7..56df588706 100644 --- a/boost/container/detail/advanced_insert_int.hpp +++ b/boost/container/detail/advanced_insert_int.hpp @@ -11,44 +11,55 @@ #ifndef BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP #define BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> +// container #include <boost/container/allocator_traits.hpp> +// container/detail +#include <boost/container/detail/copy_move_algo.hpp> #include <boost/container/detail/destroyers.hpp> -#include <boost/aligned_storage.hpp> -#include <boost/move/utility_core.hpp> #include <boost/container/detail/mpl.hpp> -#include <boost/container/detail/utilities.hpp> #include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/iterator.hpp> #include <boost/container/detail/iterators.hpp> -#include <iterator> //std::iterator_traits +#include <boost/container/detail/iterator_to_raw_pointer.hpp> +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include <boost/move/detail/fwd_macros.hpp> +#endif +// move +#include <boost/move/utility_core.hpp> +// other #include <boost/assert.hpp> #include <boost/core/no_exceptions_support.hpp> namespace boost { namespace container { namespace container_detail { -template<class A, class FwdIt, class Iterator> +template<class Allocator, class FwdIt, class Iterator> struct move_insert_range_proxy { - typedef typename allocator_traits<A>::size_type size_type; - typedef typename allocator_traits<A>::value_type value_type; + typedef typename allocator_traits<Allocator>::size_type size_type; + typedef typename allocator_traits<Allocator>::value_type value_type; explicit move_insert_range_proxy(FwdIt first) : first_(first) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) + 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(A &, Iterator p, size_type n) + void copy_n_and_update(Allocator &, Iterator p, size_type n) { this->first_ = ::boost::container::move_n_source(this->first_, n, p); } @@ -57,22 +68,22 @@ struct move_insert_range_proxy }; -template<class A, class FwdIt, class Iterator> +template<class Allocator, class FwdIt, class Iterator> struct insert_range_proxy { - typedef typename allocator_traits<A>::size_type size_type; - typedef typename allocator_traits<A>::value_type value_type; + typedef typename allocator_traits<Allocator>::size_type size_type; + typedef typename allocator_traits<Allocator>::value_type value_type; explicit insert_range_proxy(FwdIt first) : first_(first) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) + 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(A &, Iterator p, size_type n) + void copy_n_and_update(Allocator &, Iterator p, size_type n) { this->first_ = ::boost::container::copy_n_source(this->first_, n, p); } @@ -81,20 +92,20 @@ struct insert_range_proxy }; -template<class A, class Iterator> +template<class Allocator, class Iterator> struct insert_n_copies_proxy { - typedef typename allocator_traits<A>::size_type size_type; - typedef typename allocator_traits<A>::value_type value_type; + typedef typename allocator_traits<Allocator>::size_type size_type; + typedef typename allocator_traits<Allocator>::value_type value_type; explicit insert_n_copies_proxy(const value_type &v) : v_(v) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + 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(A &, Iterator p, size_type n) const + void copy_n_and_update(Allocator &, Iterator p, size_type n) const { for (; 0 < n; --n, ++p){ *p = v_; @@ -104,38 +115,38 @@ struct insert_n_copies_proxy const value_type &v_; }; -template<class A, class Iterator> +template<class Allocator, class Iterator> struct insert_value_initialized_n_proxy { - typedef ::boost::container::allocator_traits<A> alloc_traits; - typedef typename allocator_traits<A>::size_type size_type; - typedef typename allocator_traits<A>::value_type value_type; + typedef ::boost::container::allocator_traits<Allocator> alloc_traits; + typedef typename allocator_traits<Allocator>::size_type size_type; + typedef typename allocator_traits<Allocator>::value_type value_type; - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + 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(A &, Iterator, size_type) const + void copy_n_and_update(Allocator &, Iterator, size_type) const { BOOST_ASSERT(false); } }; -template<class A, class Iterator> +template<class Allocator, class Iterator> struct insert_default_initialized_n_proxy { - typedef ::boost::container::allocator_traits<A> alloc_traits; - typedef typename allocator_traits<A>::size_type size_type; - typedef typename allocator_traits<A>::value_type value_type; + typedef ::boost::container::allocator_traits<Allocator> alloc_traits; + typedef typename allocator_traits<Allocator>::size_type size_type; + typedef typename allocator_traits<Allocator>::value_type value_type; - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + 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(A &, Iterator, size_type) const + void copy_n_and_update(Allocator &, Iterator, size_type) const { BOOST_ASSERT(false); } }; -template<class A, class Iterator> +template<class Allocator, class Iterator> struct insert_copy_proxy { - typedef boost::container::allocator_traits<A> alloc_traits; + typedef boost::container::allocator_traits<Allocator> alloc_traits; typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; @@ -143,13 +154,13 @@ struct insert_copy_proxy : v_(v) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, iterator_to_raw_pointer(p), v_); } - void copy_n_and_update(A &, Iterator p, size_type n) const + void copy_n_and_update(Allocator &, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; *p =v_; @@ -159,10 +170,10 @@ struct insert_copy_proxy }; -template<class A, class Iterator> +template<class Allocator, class Iterator> struct insert_move_proxy { - typedef boost::container::allocator_traits<A> alloc_traits; + typedef boost::container::allocator_traits<Allocator> alloc_traits; typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; @@ -170,13 +181,13 @@ struct insert_move_proxy : v_(v) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, iterator_to_raw_pointer(p), ::boost::move(v_) ); } - void copy_n_and_update(A &, Iterator p, size_type n) const + void copy_n_and_update(Allocator &, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; *p = ::boost::move(v_); @@ -185,50 +196,48 @@ struct insert_move_proxy value_type &v_; }; -template<class It, class A> -insert_move_proxy<A, It> get_insert_value_proxy(BOOST_RV_REF(typename std::iterator_traits<It>::value_type) v) +template<class It, class Allocator> +insert_move_proxy<Allocator, It> get_insert_value_proxy(BOOST_RV_REF(typename boost::container::iterator_traits<It>::value_type) v) { - return insert_move_proxy<A, It>(v); + return insert_move_proxy<Allocator, It>(v); } -template<class It, class A> -insert_copy_proxy<A, It> get_insert_value_proxy(const typename std::iterator_traits<It>::value_type &v) +template<class It, class Allocator> +insert_copy_proxy<Allocator, It> get_insert_value_proxy(const typename boost::container::iterator_traits<It>::value_type &v) { - return insert_copy_proxy<A, It>(v); + return insert_copy_proxy<Allocator, It>(v); } }}} //namespace boost { namespace container { namespace container_detail { -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include <boost/container/detail/variadic_templates_tools.hpp> #include <boost/move/utility_core.hpp> -#include <typeinfo> -//#include <iostream> //For debugging purposes namespace boost { namespace container { namespace container_detail { -template<class A, class Iterator, class ...Args> -struct insert_non_movable_emplace_proxy +template<class Allocator, class Iterator, class ...Args> +struct insert_nonmovable_emplace_proxy { - typedef boost::container::allocator_traits<A> alloc_traits; + typedef boost::container::allocator_traits<Allocator> alloc_traits; typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; typedef typename build_number_seq<sizeof...(Args)>::type index_tuple_t; - explicit insert_non_movable_emplace_proxy(Args&&... args) + explicit insert_nonmovable_emplace_proxy(BOOST_FWD_REF(Args)... args) : args_(args...) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) + 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<int ...IdxPack> - void priv_uninitialized_copy_some_and_update(A &a, const index_tuple<IdxPack...>&, Iterator p, size_type n) + void priv_uninitialized_copy_some_and_update(Allocator &a, const index_tuple<IdxPack...>&, Iterator p, size_type n) { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, iterator_to_raw_pointer(p), ::boost::forward<Args>(get<IdxPack>(this->args_))... ); @@ -238,30 +247,30 @@ struct insert_non_movable_emplace_proxy tuple<Args&...> args_; }; -template<class A, class Iterator, class ...Args> +template<class Allocator, class Iterator, class ...Args> struct insert_emplace_proxy - : public insert_non_movable_emplace_proxy<A, Iterator, Args...> + : public insert_nonmovable_emplace_proxy<Allocator, Iterator, Args...> { - typedef insert_non_movable_emplace_proxy<A, Iterator, Args...> base_t; - typedef boost::container::allocator_traits<A> alloc_traits; + typedef insert_nonmovable_emplace_proxy<Allocator, Iterator, Args...> base_t; + typedef boost::container::allocator_traits<Allocator> alloc_traits; typedef typename base_t::value_type value_type; typedef typename base_t::size_type size_type; typedef typename base_t::index_tuple_t index_tuple_t; - explicit insert_emplace_proxy(Args&&... args) + explicit insert_emplace_proxy(BOOST_FWD_REF(Args)... args) : base_t(::boost::forward<Args>(args)...) {} - void copy_n_and_update(A &a, Iterator p, size_type n) + 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<int ...IdxPack> - void priv_copy_some_and_update(A &a, const index_tuple<IdxPack...>&, Iterator p, size_type n) + void priv_copy_some_and_update(Allocator &a, const index_tuple<IdxPack...>&, Iterator p, size_type n) { BOOST_ASSERT(n ==1); (void)n; - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; value_type *vp = static_cast<value_type *>(static_cast<void *>(&v)); alloc_traits::construct(a, vp, ::boost::forward<Args>(get<IdxPack>(this->args_))...); @@ -278,191 +287,182 @@ struct insert_emplace_proxy }; //Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type -template<class A, class Iterator> -struct insert_emplace_proxy<A, Iterator, typename boost::container::allocator_traits<A>::value_type> - : public insert_move_proxy<A, Iterator> +template<class Allocator, class Iterator> +struct insert_emplace_proxy<Allocator, Iterator, typename boost::container::allocator_traits<Allocator>::value_type> + : public insert_move_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy(typename boost::container::allocator_traits<A>::value_type &&v) - : insert_move_proxy<A, Iterator>(v) + explicit insert_emplace_proxy(typename boost::container::allocator_traits<Allocator>::value_type &&v) + : insert_move_proxy<Allocator, Iterator>(v) {} }; //We use "add_const" here as adding "const" only confuses MSVC12(and maybe later) provoking -//compiler error C2752 (“more than one partial specialization matches”). +//compiler error C2752 ("more than one partial specialization matches"). //Any problem is solvable with an extra layer of indirection? ;-) -template<class A, class Iterator> -struct insert_emplace_proxy<A, Iterator - , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<A>::value_type>::type +template<class Allocator, class Iterator> +struct insert_emplace_proxy<Allocator, Iterator + , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<Allocator>::value_type>::type > - : public insert_copy_proxy<A, Iterator> + : public insert_copy_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits<A>::value_type &v) - : insert_copy_proxy<A, Iterator>(v) + explicit insert_emplace_proxy(const typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_copy_proxy<Allocator, Iterator>(v) {} }; -template<class A, class Iterator> -struct insert_emplace_proxy<A, Iterator, typename boost::container::allocator_traits<A>::value_type &> - : public insert_copy_proxy<A, Iterator> +template<class Allocator, class Iterator> +struct insert_emplace_proxy<Allocator, Iterator, typename boost::container::allocator_traits<Allocator>::value_type &> + : public insert_copy_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits<A>::value_type &v) - : insert_copy_proxy<A, Iterator>(v) + explicit insert_emplace_proxy(const typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_copy_proxy<Allocator, Iterator>(v) {} }; -template<class A, class Iterator> -struct insert_emplace_proxy<A, Iterator - , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<A>::value_type>::type & +template<class Allocator, class Iterator> +struct insert_emplace_proxy<Allocator, Iterator + , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<Allocator>::value_type>::type & > - : public insert_copy_proxy<A, Iterator> + : public insert_copy_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits<A>::value_type &v) - : insert_copy_proxy<A, Iterator>(v) + explicit insert_emplace_proxy(const typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_copy_proxy<Allocator, Iterator>(v) {} }; }}} //namespace boost { namespace container { namespace container_detail { -#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#include <boost/container/detail/preprocessor.hpp> #include <boost/container/detail/value_init.hpp> namespace boost { namespace container { namespace container_detail { -#define BOOST_PP_LOCAL_MACRO(N) \ -template<class A, class Iterator BOOST_PP_ENUM_TRAILING_PARAMS(N, class P) > \ -struct BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ -{ \ - typedef boost::container::allocator_traits<A> alloc_traits; \ - typedef typename alloc_traits::size_type size_type; \ - typedef typename alloc_traits::value_type value_type; \ - \ - explicit BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ - ( BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - BOOST_PP_EXPR_IF(N, :) BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_INIT, _) \ - {} \ - \ - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) \ - { \ - BOOST_ASSERT(n == 1); (void)n; \ - alloc_traits::construct \ - ( a, iterator_to_raw_pointer(p) \ - BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \ - ); \ - } \ - \ - void copy_n_and_update(A &, Iterator, size_type) \ - { BOOST_ASSERT(false); } \ - \ - protected: \ - BOOST_PP_REPEAT(N, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \ -}; \ - \ -template<class A, class Iterator BOOST_PP_ENUM_TRAILING_PARAMS(N, class P) > \ -struct BOOST_PP_CAT(insert_emplace_proxy_arg, N) \ - : BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ - < A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(N, P) > \ -{ \ - typedef BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ - <A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(N, P) > base_t; \ - typedef typename base_t::value_type value_type; \ - typedef typename base_t::size_type size_type; \ - typedef boost::container::allocator_traits<A> alloc_traits; \ - \ - explicit BOOST_PP_CAT(insert_emplace_proxy_arg, N) \ - ( BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - : base_t(BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ) \ - {} \ - \ - void copy_n_and_update(A &a, Iterator p, size_type n) \ - { \ - BOOST_ASSERT(n == 1); (void)n; \ - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \ - value_type *vp = static_cast<value_type *>(static_cast<void *>(&v)); \ - alloc_traits::construct(a, vp \ - BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)); \ - BOOST_TRY{ \ - *p = ::boost::move(*vp); \ - } \ - BOOST_CATCH(...){ \ - alloc_traits::destroy(a, vp); \ - BOOST_RETHROW \ - } \ - BOOST_CATCH_END \ - alloc_traits::destroy(a, vp); \ - } \ -}; \ -//! -#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) -#include BOOST_PP_LOCAL_ITERATE() +#define BOOST_CONTAINER_ADVANCED_INSERT_INT_CODE(N) \ +template< class Allocator, class Iterator BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ +struct insert_nonmovable_emplace_proxy##N\ +{\ + typedef boost::container::allocator_traits<Allocator> alloc_traits;\ + 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)\ + BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N {}\ + \ + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)\ + {\ + BOOST_ASSERT(n == 1); (void)n;\ + alloc_traits::construct(a, iterator_to_raw_pointer(p) BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\ + }\ + \ + void copy_n_and_update(Allocator &, Iterator, size_type)\ + { BOOST_ASSERT(false); }\ + \ + protected:\ + BOOST_MOVE_MREF##N\ +};\ +\ +template< class Allocator, class Iterator BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ +struct insert_emplace_proxy_arg##N\ + : insert_nonmovable_emplace_proxy##N< Allocator, Iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N >\ +{\ + typedef insert_nonmovable_emplace_proxy##N\ + < Allocator, Iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N > base_t;\ + typedef typename base_t::value_type value_type;\ + typedef typename base_t::size_type size_type;\ + typedef boost::container::allocator_traits<Allocator> alloc_traits;\ + \ + 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_ASSERT(n == 1); (void)n;\ + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\ + BOOST_ASSERT((((size_type)(&v)) % alignment_of<value_type>::value) == 0);\ + value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));\ + alloc_traits::construct(a, vp BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\ + BOOST_TRY{\ + *p = ::boost::move(*vp);\ + }\ + BOOST_CATCH(...){\ + alloc_traits::destroy(a, vp);\ + BOOST_RETHROW\ + }\ + BOOST_CATCH_END\ + alloc_traits::destroy(a, vp);\ + }\ +};\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ADVANCED_INSERT_INT_CODE) +#undef BOOST_CONTAINER_ADVANCED_INSERT_INT_CODE #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) //Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type -template<class A, class Iterator> -struct insert_emplace_proxy_arg1<A, Iterator, ::boost::rv<typename boost::container::allocator_traits<A>::value_type> > - : public insert_move_proxy<A, Iterator> +template<class Allocator, class Iterator> +struct insert_emplace_proxy_arg1<Allocator, Iterator, ::boost::rv<typename boost::container::allocator_traits<Allocator>::value_type> > + : public insert_move_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits<A>::value_type &v) - : insert_move_proxy<A, Iterator>(v) + explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_move_proxy<Allocator, Iterator>(v) {} }; -template<class A, class Iterator> -struct insert_emplace_proxy_arg1<A, Iterator, typename boost::container::allocator_traits<A>::value_type> - : public insert_copy_proxy<A, Iterator> +template<class Allocator, class Iterator> +struct insert_emplace_proxy_arg1<Allocator, Iterator, typename boost::container::allocator_traits<Allocator>::value_type> + : public insert_copy_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<A>::value_type &v) - : insert_copy_proxy<A, Iterator>(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_copy_proxy<Allocator, Iterator>(v) {} }; #else //e.g. MSVC10 & MSVC11 //Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type -template<class A, class Iterator> -struct insert_emplace_proxy_arg1<A, Iterator, typename boost::container::allocator_traits<A>::value_type> - : public insert_move_proxy<A, Iterator> +template<class Allocator, class Iterator> +struct insert_emplace_proxy_arg1<Allocator, Iterator, typename boost::container::allocator_traits<Allocator>::value_type> + : public insert_move_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits<A>::value_type &&v) - : insert_move_proxy<A, Iterator>(v) + explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits<Allocator>::value_type &&v) + : insert_move_proxy<Allocator, Iterator>(v) {} }; //We use "add_const" here as adding "const" only confuses MSVC10&11 provoking -//compiler error C2752 (“more than one partial specialization matches”). +//compiler error C2752 ("more than one partial specialization matches"). //Any problem is solvable with an extra layer of indirection? ;-) -template<class A, class Iterator> -struct insert_emplace_proxy_arg1<A, Iterator - , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<A>::value_type>::type +template<class Allocator, class Iterator> +struct insert_emplace_proxy_arg1<Allocator, Iterator + , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<Allocator>::value_type>::type > - : public insert_copy_proxy<A, Iterator> + : public insert_copy_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<A>::value_type &v) - : insert_copy_proxy<A, Iterator>(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_copy_proxy<Allocator, Iterator>(v) {} }; -template<class A, class Iterator> -struct insert_emplace_proxy_arg1<A, Iterator, typename boost::container::allocator_traits<A>::value_type &> - : public insert_copy_proxy<A, Iterator> +template<class Allocator, class Iterator> +struct insert_emplace_proxy_arg1<Allocator, Iterator, typename boost::container::allocator_traits<Allocator>::value_type &> + : public insert_copy_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<A>::value_type &v) - : insert_copy_proxy<A, Iterator>(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_copy_proxy<Allocator, Iterator>(v) {} }; -template<class A, class Iterator> -struct insert_emplace_proxy_arg1<A, Iterator - , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<A>::value_type>::type & +template<class Allocator, class Iterator> +struct insert_emplace_proxy_arg1<Allocator, Iterator + , typename boost::container::container_detail::add_const<typename boost::container::allocator_traits<Allocator>::value_type>::type & > - : public insert_copy_proxy<A, Iterator> + : public insert_copy_proxy<Allocator, Iterator> { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<A>::value_type &v) - : insert_copy_proxy<A, Iterator>(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits<Allocator>::value_type &v) + : insert_copy_proxy<Allocator, Iterator>(v) {} }; @@ -470,7 +470,7 @@ struct insert_emplace_proxy_arg1<A, Iterator }}} //namespace boost { namespace container { namespace container_detail { -#endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include <boost/container/detail/config_end.hpp> diff --git a/boost/container/detail/algorithm.hpp b/boost/container/detail/algorithm.hpp new file mode 100644 index 0000000000..67e7876345 --- /dev/null +++ b/boost/container/detail/algorithm.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP +#define BOOST_CONTAINER_DETAIL_ALGORITHM_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include <boost/intrusive/detail/algorithm.hpp> + +namespace boost { +namespace container { + +using boost::intrusive::algo_equal; +using boost::intrusive::algo_lexicographical_compare; + +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP diff --git a/boost/container/detail/algorithms.hpp b/boost/container/detail/algorithms.hpp deleted file mode 100644 index af15f65737..0000000000 --- a/boost/container/detail/algorithms.hpp +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/container for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP -#define BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include <boost/container/detail/config_begin.hpp> -#include <boost/container/detail/workaround.hpp> -#include <boost/container/allocator_traits.hpp> -#include <boost/container/detail/iterators.hpp> - -namespace boost { -namespace container { - -template<class A, class T, class InpIt> -inline void construct_in_place(A &a, T* dest, InpIt source) -{ boost::container::allocator_traits<A>::construct(a, dest, *source); } - -template<class A, class T, class U, class D> -inline void construct_in_place(A &a, T *dest, value_init_construct_iterator<U, D>) -{ - boost::container::allocator_traits<A>::construct(a, dest); -} - -template <class T, class Difference> -class default_init_construct_iterator; - -template<class A, class T, class U, class D> -inline void construct_in_place(A &a, T *dest, default_init_construct_iterator<U, D>) -{ - boost::container::allocator_traits<A>::construct(a, dest, default_init); -} - -template <class T, class EmplaceFunctor, class Difference> -class emplace_iterator; - -template<class A, class T, class U, class EF, class D> -inline void construct_in_place(A &a, T *dest, emplace_iterator<U, EF, D> ei) -{ - ei.construct_in_place(a, dest); -} - -} //namespace container { -} //namespace boost { - -#include <boost/container/detail/config_end.hpp> - -#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP - diff --git a/boost/container/detail/alloc_helpers.hpp b/boost/container/detail/alloc_helpers.hpp new file mode 100644 index 0000000000..656e0c2a5e --- /dev/null +++ b/boost/container/detail/alloc_helpers.hpp @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_DETAIL_ALLOC_TRAITS_HPP +#define BOOST_CONTAINER_DETAIL_ALLOC_TRAITS_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +// move +#include <boost/move/adl_move_swap.hpp> +#include <boost/move/utility_core.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +template<class AllocatorType> +inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) + BOOST_NOEXCEPT_OR_NOTHROW +{} + +template<class AllocatorType> +inline void swap_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) +{ boost::adl_move_swap(l, r); } + +template<class AllocatorType> +inline void assign_alloc(AllocatorType &, const AllocatorType &, container_detail::false_type) + BOOST_NOEXCEPT_OR_NOTHROW +{} + +template<class AllocatorType> +inline void assign_alloc(AllocatorType &l, const AllocatorType &r, container_detail::true_type) +{ l = r; } + +template<class AllocatorType> +inline void move_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) + BOOST_NOEXCEPT_OR_NOTHROW +{} + +template<class AllocatorType> +inline void move_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) +{ l = ::boost::move(r); } + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ALLOC_TRAITS_HPP diff --git a/boost/container/detail/alloc_lib_auto_link.hpp b/boost/container/detail/alloc_lib_auto_link.hpp index e0a01b6086..aea99a65c3 100644 --- a/boost/container/detail/alloc_lib_auto_link.hpp +++ b/boost/container/detail/alloc_lib_auto_link.hpp @@ -10,7 +10,11 @@ #ifndef BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP #define BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/allocation_type.hpp b/boost/container/detail/allocation_type.hpp index 65d543ad50..1e8aa67310 100644 --- a/boost/container/detail/allocation_type.hpp +++ b/boost/container/detail/allocation_type.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_ALLOCATION_TYPE_HPP #define BOOST_CONTAINER_ALLOCATION_TYPE_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -36,7 +40,7 @@ enum allocation_type_v try_shrink_in_place_v = 0x40 }; -typedef int allocation_type; +typedef unsigned int allocation_type; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED static const allocation_type allocate_new = (allocation_type)allocate_new_v; static const allocation_type expand_fwd = (allocation_type)expand_fwd_v; diff --git a/boost/container/detail/allocator_version_traits.hpp b/boost/container/detail/allocator_version_traits.hpp index 18bb2ac613..62492da091 100644 --- a/boost/container/detail/allocator_version_traits.hpp +++ b/boost/container/detail/allocator_version_traits.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP #define BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -25,7 +29,6 @@ #include <boost/container/detail/allocation_type.hpp> //allocation_type #include <boost/container/detail/mpl.hpp> //integral_constant #include <boost/intrusive/pointer_traits.hpp> //pointer_traits -#include <utility> //pair #include <boost/core/no_exceptions_support.hpp> //BOOST_TRY namespace boost { @@ -56,14 +59,9 @@ struct allocator_version_traits static void deallocate_individual(Allocator &a, multiallocation_chain &holder) { a.deallocate_individual(holder); } - static std::pair<pointer, bool> - allocation_command(Allocator &a, allocation_type command, - size_type limit_size, size_type preferred_size, - size_type &received_size, const pointer &reuse) - { - return a.allocation_command - (command, limit_size, preferred_size, received_size, reuse); - } + static pointer allocation_command(Allocator &a, allocation_type command, + size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse) + { return a.allocation_command(command, limit_size, prefer_in_recvd_out_size, reuse); } }; template<class Allocator> @@ -132,21 +130,16 @@ struct allocator_version_traits<Allocator, 1> rollback.release(); } - static std::pair<pointer, bool> - allocation_command(Allocator &a, allocation_type command, - size_type, size_type preferred_size, - size_type &received_size, const pointer &) + static pointer allocation_command(Allocator &a, allocation_type command, + size_type, size_type &prefer_in_recvd_out_size, pointer &reuse) { - std::pair<pointer, bool> ret(pointer(), false); - if(!(command & allocate_new)){ - if(!(command & nothrow_allocation)){ - throw_logic_error("version 1 allocator without allocate_new flag"); - } + pointer ret = pointer(); + if(BOOST_UNLIKELY(!(command & allocate_new) && !(command & nothrow_allocation))){ + throw_logic_error("version 1 allocator without allocate_new flag"); } else{ - received_size = preferred_size; BOOST_TRY{ - ret.first = a.allocate(received_size); + ret = a.allocate(prefer_in_recvd_out_size); } BOOST_CATCH(...){ if(!(command & nothrow_allocation)){ @@ -154,6 +147,7 @@ struct allocator_version_traits<Allocator, 1> } } BOOST_CATCH_END + reuse = pointer(); } return ret; } diff --git a/boost/container/detail/auto_link.hpp b/boost/container/detail/auto_link.hpp index 2e4733363d..da078e8342 100644 --- a/boost/container/detail/auto_link.hpp +++ b/boost/container/detail/auto_link.hpp @@ -10,7 +10,11 @@ #ifndef BOOST_CONTAINER_DETAIL_AUTO_LINK_HPP_INCLUDED #define BOOST_CONTAINER_DETAIL_AUTO_LINK_HPP_INCLUDED -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/compare_functors.hpp b/boost/container/detail/compare_functors.hpp new file mode 100644 index 0000000000..4220d50996 --- /dev/null +++ b/boost/container/detail/compare_functors.hpp @@ -0,0 +1,74 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP +#define BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +namespace boost { +namespace container { + +template<class Allocator> +class equal_to_value +{ + typedef typename Allocator::value_type value_type; + const value_type &t_; + + public: + explicit equal_to_value(const value_type &t) + : t_(t) + {} + + bool operator()(const value_type &t)const + { return t_ == t; } +}; + +template<class Node, class Pred> +struct value_to_node_compare + : Pred +{ + typedef Pred predicate_type; + typedef Node node_type; + + value_to_node_compare() + : Pred() + {} + + explicit value_to_node_compare(Pred pred) + : Pred(pred) + {} + + bool operator()(const Node &a, const Node &b) const + { return static_cast<const Pred&>(*this)(a.m_data, b.m_data); } + + bool operator()(const Node &a) const + { return static_cast<const Pred&>(*this)(a.m_data); } + + bool operator()(const Node &a, const Node &b) + { return static_cast<Pred&>(*this)(a.m_data, b.m_data); } + + bool operator()(const Node &a) + { return static_cast<Pred&>(*this)(a.m_data); } + + predicate_type & predicate() { return static_cast<predicate_type&>(*this); } + const predicate_type & predicate() const { return static_cast<predicate_type&>(*this); } +}; + +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP diff --git a/boost/container/detail/config_begin.hpp b/boost/container/detail/config_begin.hpp index ca9dd59682..3f509e320b 100644 --- a/boost/container/detail/config_begin.hpp +++ b/boost/container/detail/config_begin.hpp @@ -17,32 +17,34 @@ #ifdef BOOST_MSVC #pragma warning (push) - #pragma warning (disable : 4702) // unreachable code - #pragma warning (disable : 4706) // assignment within conditional expression #pragma warning (disable : 4127) // conditional expression is constant #pragma warning (disable : 4146) // unary minus operator applied to unsigned type, result still unsigned - #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4197) // top-level volatile in cast is ignored #pragma warning (disable : 4244) // possible loss of data #pragma warning (disable : 4251) // "identifier" : class "type" needs to have dll-interface to be used by clients of class "type2" #pragma warning (disable : 4267) // conversion from "X" to "Y", possible loss of data #pragma warning (disable : 4275) // non DLL-interface classkey "identifier" used as base for DLL-interface classkey "identifier" + #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4324) // structure was padded due to __declspec(align( + #pragma warning (disable : 4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized #pragma warning (disable : 4355) // "this" : used in base member initializer list #pragma warning (disable : 4503) // "identifier" : decorated name length exceeded, name was truncated + #pragma warning (disable : 4510) // default constructor could not be generated #pragma warning (disable : 4511) // copy constructor could not be generated #pragma warning (disable : 4512) // assignment operator could not be generated #pragma warning (disable : 4514) // unreferenced inline removed #pragma warning (disable : 4521) // Disable "multiple copy constructors specified" #pragma warning (disable : 4522) // "class" : multiple assignment operators specified + #pragma warning (disable : 4541) // 'typeid' used on polymorphic type '' with /GR-; unpredictable behavior may result + #pragma warning (disable : 4584) // X is already a base-class of Y + #pragma warning (disable : 4610) // struct can never be instantiated - user defined constructor required + #pragma warning (disable : 4671) // the copy constructor is inaccessible + #pragma warning (disable : 4673) // throwing '' the following types will not be considered at the catch site #pragma warning (disable : 4675) // "method" should be declared "static" and have exactly one parameter + #pragma warning (disable : 4702) // unreachable code + #pragma warning (disable : 4706) // assignment within conditional expression #pragma warning (disable : 4710) // function not inlined #pragma warning (disable : 4711) // function selected for automatic inline expansion #pragma warning (disable : 4786) // identifier truncated in debug info #pragma warning (disable : 4996) // "function": was declared deprecated - #pragma warning (disable : 4197) // top-level volatile in cast is ignored - #pragma warning (disable : 4541) // 'typeid' used on polymorphic type 'boost::exception' - // with /GR-; unpredictable behavior may result - #pragma warning (disable : 4673) // throwing '' the following types will not be considered at the catch site - #pragma warning (disable : 4671) // the copy constructor is inaccessible - #pragma warning (disable : 4584) // X is already a base-class of Y - #pragma warning (disable : 4510) // default constructor could not be generated #endif //BOOST_MSVC diff --git a/boost/container/detail/construct_in_place.hpp b/boost/container/detail/construct_in_place.hpp new file mode 100644 index 0000000000..6cb339519c --- /dev/null +++ b/boost/container/detail/construct_in_place.hpp @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP +#define BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include <boost/container/allocator_traits.hpp> +#include <boost/container/detail/iterators.hpp> + +namespace boost { +namespace container { + +template<class Allocator, class T, class InpIt> +inline void construct_in_place(Allocator &a, T* dest, InpIt source) +{ boost::container::allocator_traits<Allocator>::construct(a, dest, *source); } + +template<class Allocator, class T, class U, class D> +inline void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U, D>) +{ + boost::container::allocator_traits<Allocator>::construct(a, dest); +} + +template <class T, class Difference> +class default_init_construct_iterator; + +template<class Allocator, class T, class U, class D> +inline void construct_in_place(Allocator &a, T *dest, default_init_construct_iterator<U, D>) +{ + boost::container::allocator_traits<Allocator>::construct(a, dest, default_init); +} + +template <class T, class EmplaceFunctor, class Difference> +class emplace_iterator; + +template<class Allocator, class T, class U, class EF, class D> +inline void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF, D> ei) +{ + ei.construct_in_place(a, dest); +} + +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP + diff --git a/boost/container/detail/utilities.hpp b/boost/container/detail/copy_move_algo.hpp index 25f035df50..79cbde80a9 100644 --- a/boost/container/detail/utilities.hpp +++ b/boost/container/detail/copy_move_algo.hpp @@ -7,225 +7,37 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP #define BOOST_CONTAINER_DETAIL_UTILITIES_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif -#include <boost/container/detail/config_begin.hpp> -#include <boost/container/detail/workaround.hpp> - -#include <cstdio> -#include <cstring> //for ::memmove / ::memcpy -#include <boost/type_traits/is_pointer.hpp> -#include <boost/type_traits/is_enum.hpp> -#include <boost/type_traits/is_class.hpp> -#include <boost/type_traits/is_integral.hpp> -#include <boost/type_traits/is_floating_point.hpp> -#include <boost/type_traits/is_copy_constructible.hpp> -#include <boost/type_traits/has_trivial_destructor.hpp> -#include <boost/type_traits/has_trivial_copy.hpp> -#include <boost/type_traits/has_trivial_assign.hpp> -#include <boost/type_traits/is_pod.hpp> -#include <boost/move/core.hpp> -#include <boost/move/utility_core.hpp> -#include <boost/move/iterator.hpp> -#include <boost/assert.hpp> -#include <boost/container/throw_exception.hpp> +// container +#include <boost/container/allocator_traits.hpp> +// container/detail +#include <boost/container/detail/iterator.hpp> +#include <boost/container/detail/iterator_to_raw_pointer.hpp> #include <boost/container/detail/mpl.hpp> #include <boost/container/detail/type_traits.hpp> -#include <boost/container/allocator_traits.hpp> +// move +#include <boost/move/adl_move_swap.hpp> +#include <boost/move/iterator.hpp> +#include <boost/move/utility_core.hpp> +// other #include <boost/core/no_exceptions_support.hpp> -#include <boost/container/detail/memory_util.hpp> -#include <boost/intrusive/pointer_traits.hpp> -#include <boost/aligned_storage.hpp> -#include <iterator> -#include <utility> //std::distance +// std +#include <cstring> //for emmove/memcpy namespace boost { namespace container { - -////////////////////////////////////////////////////////////////////////////// -// -// swap -// -////////////////////////////////////////////////////////////////////////////// - -namespace container_swap { - -template<class T, bool IsClass = boost::is_class<T>::value > -struct has_member_swap -{ - static const bool value = boost::container::container_detail:: - has_member_function_callable_with_swap<T, T &>::value; -}; - -template<class T> -struct has_member_swap<T, false> -{ - static const bool value = false; -}; - -} //namespace container_swap { - -template<class T> inline -typename container_detail::enable_if_c - <container_swap::has_member_swap<T>::value, void>::type -swap_dispatch(T &left, T &right) //swap using member swap -{ - left.swap(right); // may throw -} - -template<class T> inline -typename container_detail::enable_if_c - <!container_swap::has_member_swap<T>::value/* && boost::has_move_emulation_enabled<T>::value*/, void>::type - swap_dispatch(T &left, T &right) -{ - T temp(boost::move(left)); // may throw - left = boost::move(right); // may throw - right = boost::move(temp); // may throw -} -/* -template<class T> inline -typename container_detail::enable_if_c - <!container_swap::has_member_swap<T>::value && !boost::has_move_emulation_enabled<T>::value, void>::type - swap_dispatch(T &left, T &right) -{ - using std::swap; - swap(left, right); // may throw -} -*/ namespace container_detail { -template <typename T> -inline T* addressof(T& obj) -{ - return static_cast<T*>( - static_cast<void*>( - const_cast<char*>( - &reinterpret_cast<const char&>(obj) - ))); -} - -template<class T> -const T &max_value(const T &a, const T &b) -{ return a > b ? a : b; } - -template<class T> -const T &min_value(const T &a, const T &b) -{ return a < b ? a : b; } - -enum NextCapacityOption { NextCapacityDouble, NextCapacity60Percent }; - -template<class SizeType, NextCapacityOption Option> -struct next_capacity_calculator; - -template<class SizeType> -struct next_capacity_calculator<SizeType, NextCapacityDouble> -{ - static SizeType get(const SizeType max_size - ,const SizeType capacity - ,const SizeType n) - { - const SizeType remaining = max_size - capacity; - if ( remaining < n ) - boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); - const SizeType additional = max_value(n, capacity); - return ( remaining < additional ) ? max_size : ( capacity + additional ); - } -}; - - -template<class SizeType> -struct next_capacity_calculator<SizeType, NextCapacity60Percent> -{ - static SizeType get(const SizeType max_size - ,const SizeType capacity - ,const SizeType n) - { - const SizeType remaining = max_size - capacity; - if ( remaining < n ) - boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); - const SizeType m3 = max_size/3; - - if (capacity < m3) - return capacity + max_value(3*(capacity+1)/5, n); - - if (capacity < m3*2) - return capacity + max_value((capacity+1)/2, n); - return max_size; - } -}; - -template <class T> -inline T* to_raw_pointer(T* p) -{ return p; } - -template <class Pointer> -inline typename boost::intrusive::pointer_traits<Pointer>::element_type* - to_raw_pointer(const Pointer &p) -{ return boost::container::container_detail::to_raw_pointer(p.operator->()); } - -template <class T> -inline T* iterator_to_pointer(T* i) -{ return i; } - -template <class Iterator> -inline typename std::iterator_traits<Iterator>::pointer - iterator_to_pointer(const Iterator &i) -{ return i.operator->(); } - -template <class Iterator> -inline - typename boost::intrusive::pointer_traits - <typename std::iterator_traits<Iterator>::pointer>::element_type* - iterator_to_raw_pointer(const Iterator &i) -{ return (to_raw_pointer)((iterator_to_pointer)(i)); } - - -template<class AllocatorType> -inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) - BOOST_CONTAINER_NOEXCEPT -{} - -template<class AllocatorType> -inline void swap_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) -{ boost::container::swap_dispatch(l, r); } - -template<class AllocatorType> -inline void assign_alloc(AllocatorType &, const AllocatorType &, container_detail::false_type) - BOOST_CONTAINER_NOEXCEPT -{} - -template<class AllocatorType> -inline void assign_alloc(AllocatorType &l, const AllocatorType &r, container_detail::true_type) -{ l = r; } - -template<class AllocatorType> -inline void move_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) - BOOST_CONTAINER_NOEXCEPT -{} - -template<class AllocatorType> -inline void move_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) -{ l = ::boost::move(r); } - -//Rounds "orig_size" by excess to round_to bytes -template<class SizeType> -inline SizeType get_rounded_size(SizeType orig_size, SizeType round_to) -{ - return ((orig_size-1)/round_to+1)*round_to; -} - -template <std::size_t OrigSize, std::size_t RoundTo> -struct ct_rounded_size -{ - enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo }; -}; - template<class I> struct are_elements_contiguous { @@ -243,6 +55,15 @@ struct are_elements_contiguous<T*> }; ///////////////////////// +// move iterators +///////////////////////// + +template<class It> +struct are_elements_contiguous< ::boost::move_iterator<It> > + : are_elements_contiguous<It> +{}; + +///////////////////////// // predeclarations ///////////////////////// @@ -304,8 +125,8 @@ template <typename I, typename O> struct are_contiguous_and_same { static const bool is_same_io = - is_same< typename remove_const< typename ::std::iterator_traits<I>::value_type >::type - , typename ::std::iterator_traits<O>::value_type + is_same< typename remove_const< typename ::boost::container::iterator_traits<I>::value_type >::type + , typename ::boost::container::iterator_traits<O>::value_type >::value; static const bool value = is_same_io && are_elements_contiguous<I>::value && @@ -316,112 +137,125 @@ template <typename I, typename O> struct is_memtransfer_copy_assignable { static const bool value = are_contiguous_and_same<I, O>::value && - boost::has_trivial_assign< typename ::std::iterator_traits<I>::value_type >::value; + container_detail::is_trivially_copy_assignable< typename ::boost::container::iterator_traits<I>::value_type >::value; }; template <typename I, typename O> struct is_memtransfer_copy_constructible { static const bool value = are_contiguous_and_same<I, O>::value && - boost::has_trivial_copy< typename ::std::iterator_traits<I>::value_type >::value; + container_detail::is_trivially_copy_constructible< typename ::boost::container::iterator_traits<I>::value_type >::value; }; template <typename I, typename O, typename R> struct enable_if_memtransfer_copy_constructible - : public enable_if_c<container_detail::is_memtransfer_copy_constructible<I, O>::value, R> + : enable_if_c<container_detail::is_memtransfer_copy_constructible<I, O>::value, R> {}; template <typename I, typename O, typename R> struct disable_if_memtransfer_copy_constructible - : public enable_if_c<!container_detail::is_memtransfer_copy_constructible<I, O>::value, R> + : enable_if_c<!container_detail::is_memtransfer_copy_constructible<I, O>::value, R> {}; template <typename I, typename O, typename R> struct enable_if_memtransfer_copy_assignable - : public enable_if_c<container_detail::is_memtransfer_copy_assignable<I, O>::value, R> + : enable_if_c<container_detail::is_memtransfer_copy_assignable<I, O>::value, R> {}; template <typename I, typename O, typename R> struct disable_if_memtransfer_copy_assignable - : public enable_if_c<!container_detail::is_memtransfer_copy_assignable<I, O>::value, R> + : enable_if_c<!container_detail::is_memtransfer_copy_assignable<I, O>::value, R> {}; template <typename I, // I models InputIterator typename F> // F models ForwardIterator -inline F memmove(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT +inline F memmove(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits<I>::value_type value_type; - typename std::iterator_traits<I>::difference_type n = std::distance(f, l); - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(r, n); + typedef typename boost::container::iterator_traits<I>::value_type value_type; + typename boost::container::iterator_traits<I>::difference_type n = boost::container::iterator_distance(f, l); + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(r, n); return r; } template <typename I, // I models InputIterator typename F> // F models ForwardIterator -F memmove_n(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +F memmove_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits<I>::value_type value_type; - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(r, n); + typedef typename boost::container::iterator_traits<I>::value_type value_type; + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(r, n); return r; } template <typename I, // I models InputIterator typename F> // F models ForwardIterator -I memmove_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +I memmove_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits<I>::value_type value_type; - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(f, n); + typedef typename boost::container::iterator_traits<I>::value_type value_type; + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(f, n); return f; } template <typename I, // I models InputIterator typename F> // F models ForwardIterator -I memmove_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT +I memmove_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits<I>::value_type value_type; - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(f, n); - std::advance(r, n); + typedef typename boost::container::iterator_traits<I>::value_type value_type; + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(f, n); + boost::container::iterator_advance(r, n); return f; } template <typename O> struct is_memzero_initializable { - typedef typename ::std::iterator_traits<O>::value_type value_type; + typedef typename ::boost::container::iterator_traits<O>::value_type value_type; static const bool value = are_elements_contiguous<O>::value && - ( ::boost::is_integral<value_type>::value || ::boost::is_enum<value_type>::value + ( container_detail::is_integral<value_type>::value || container_detail::is_enum<value_type>::value #if defined(BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL) - || ::boost::is_pointer<value_type>::value + || container_detail::is_pointer<value_type>::value #endif #if defined(BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO) - || ::boost::is_floating_point<value_type>::value + || container_detail::is_floating_point<value_type>::value #endif #if defined(BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO) && defined(BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL) - || ::boost::is_pod<value_type>::value + || container_detail::is_pod<value_type>::value #endif ); }; template <typename O, typename R> struct enable_if_memzero_initializable - : public enable_if_c<container_detail::is_memzero_initializable<O>::value, R> + : enable_if_c<container_detail::is_memzero_initializable<O>::value, R> {}; template <typename O, typename R> struct disable_if_memzero_initializable - : public enable_if_c<!container_detail::is_memzero_initializable<O>::value, R> + : enable_if_c<!container_detail::is_memzero_initializable<O>::value, R> {}; -} //namespace container_detail { +template <typename I, typename R> +struct enable_if_trivially_destructible + : enable_if_c < false/*container_detail::is_trivially_destructible + <typename boost::container::iterator_traits<I>::value_type>::value*/ + , R> +{}; +template <typename I, typename R> +struct disable_if_trivially_destructible + : enable_if_c <true/*!container_detail::is_trivially_destructible + <typename boost::container::iterator_traits<I>::value_type>::value*/ + , R> +{}; + +} //namespace container_detail { ////////////////////////////////////////////////////////////////////////////// // @@ -438,22 +272,22 @@ struct disable_if_memzero_initializable //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_move_alloc(A &a, I f, I l, F r) + uninitialized_move_alloc(Allocator &a, I f, I l, F r) { F back = r; BOOST_TRY{ while (f != l) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -462,11 +296,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F } template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_move_alloc(A &, I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_move_alloc(Allocator &, I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -483,22 +317,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r) + uninitialized_move_alloc_n(Allocator &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -507,11 +341,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F } template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_move_alloc_n(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_move_alloc_n(Allocator &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -528,22 +362,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, //! //! <b>Returns</b>: f (after incremented) template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, I>::type - uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r) + uninitialized_move_alloc_n_source(Allocator &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -552,11 +386,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F } template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, I>::type - uninitialized_move_alloc_n_source(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_move_alloc_n_source(Allocator &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -573,22 +407,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_copy_alloc(A &a, I f, I l, F r) + uninitialized_copy_alloc(Allocator &a, I f, I l, F r) { F back = r; BOOST_TRY{ while (f != l) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), *f); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), *f); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -597,11 +431,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F } template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_copy_alloc(A &, I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_copy_alloc(Allocator &, I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -618,22 +452,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r) + uninitialized_copy_alloc_n(Allocator &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), *f); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), *f); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -642,11 +476,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F } template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, F>::type - uninitialized_copy_alloc_n(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_copy_alloc_n(Allocator &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -663,22 +497,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, //! //! <b>Returns</b>: f (after incremented) template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, I>::type - uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r) + uninitialized_copy_alloc_n_source(Allocator &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), *f); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), *f); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -687,11 +521,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F } template - <typename A, + <typename Allocator, typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, I>::type - uninitialized_copy_alloc_n_source(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_copy_alloc_n_source(Allocator &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -708,21 +542,21 @@ inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename F> // F models ForwardIterator inline typename container_detail::disable_if_memzero_initializable<F, F>::type - uninitialized_value_init_alloc_n(A &a, typename allocator_traits<A>::difference_type n, F r) + uninitialized_value_init_alloc_n(Allocator &a, typename allocator_traits<Allocator>::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r)); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r)); ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -731,14 +565,14 @@ inline typename container_detail::disable_if_memzero_initializable<F, F>::type } template - <typename A, + <typename Allocator, typename F> // F models ForwardIterator inline typename container_detail::enable_if_memzero_initializable<F, F>::type - uninitialized_value_init_alloc_n(A &, typename allocator_traits<A>::difference_type n, F r) + uninitialized_value_init_alloc_n(Allocator &, typename allocator_traits<Allocator>::difference_type n, F r) { - typedef typename std::iterator_traits<F>::value_type value_type; - ::memset((void*)container_detail::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n); - std::advance(r, n); + typedef typename boost::container::iterator_traits<F>::value_type value_type; + std::memset((void*)container_detail::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n); + boost::container::iterator_advance(r, n); return r; } @@ -756,20 +590,20 @@ inline typename container_detail::enable_if_memzero_initializable<F, F>::type //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename F> // F models ForwardIterator -inline F uninitialized_default_init_alloc_n(A &a, typename allocator_traits<A>::difference_type n, F r) +inline F uninitialized_default_init_alloc_n(Allocator &a, typename allocator_traits<Allocator>::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), default_init); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), default_init); ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -791,21 +625,21 @@ inline F uninitialized_default_init_alloc_n(A &a, typename allocator_traits<A>:: //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename F, // F models ForwardIterator typename T> -inline void uninitialized_fill_alloc(A &a, F f, F l, const T &t) +inline void uninitialized_fill_alloc(Allocator &a, F f, F l, const T &t) { F back = f; BOOST_TRY{ while (f != l) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(f), t); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(f), t); ++f; } } BOOST_CATCH(...){ for (; back != l; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -827,21 +661,21 @@ inline void uninitialized_fill_alloc(A &a, F f, F l, const T &t) //! //! <b>Returns</b>: r template - <typename A, + <typename Allocator, typename T, typename F> // F models ForwardIterator -inline F uninitialized_fill_alloc_n(A &a, const T &v, typename allocator_traits<A>::difference_type n, F r) +inline F uninitialized_fill_alloc_n(Allocator &a, const T &v, typename allocator_traits<Allocator>::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits<A>::construct(a, container_detail::iterator_to_raw_pointer(r), v); + allocator_traits<Allocator>::construct(a, container_detail::iterator_to_raw_pointer(r), v); ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -872,7 +706,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, F>::type - copy(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + copy(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -885,7 +719,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, F>::type - copy_n(I f, typename std::iterator_traits<I>::difference_type n, F r) + copy_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { while (n--) { *r = *f; @@ -898,7 +732,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, F>::type - copy_n(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + copy_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -911,7 +745,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type - copy_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) + copy_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { while (n--) { *r = *f; @@ -924,7 +758,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type - copy_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + copy_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -937,7 +771,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type - copy_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) + copy_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) { while (n--) { *r = *f; @@ -950,7 +784,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type - copy_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT + copy_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source_dest(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -976,7 +810,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, F>::type - move(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + move(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -989,7 +823,7 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, F>::type - move_n(I f, typename std::iterator_traits<I>::difference_type n, F r) + move_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { while (n--) { *r = ::boost::move(*f); @@ -1002,12 +836,45 @@ template <typename I, // I models InputIterator typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, F>::type - move_n(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + move_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // -// move_n_source +// move_backward +// +////////////////////////////////////////////////////////////////////////////// + +template +<typename I, // I models BidirectionalIterator +typename F> // F models ForwardIterator +inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, F>::type + move_backward(I f, I l, F r) +{ + while (f != l) { + --l; --r; + *r = ::boost::move(*l); + } + return r; +} + +template +<typename I, // I models InputIterator +typename F> // F models ForwardIterator +inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, F>::type + move_backward(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW +{ + typedef typename boost::container::iterator_traits<I>::value_type value_type; + const typename boost::container::iterator_traits<I>::difference_type n = boost::container::iterator_distance(f, l); + r -= n; + std::memmove((container_detail::iterator_to_raw_pointer)(r), (container_detail::iterator_to_raw_pointer)(f), sizeof(value_type)*n); + return r; +} + +////////////////////////////////////////////////////////////////////////////// +// +// move_n_source_dest // ////////////////////////////////////////////////////////////////////////////// @@ -1015,7 +882,7 @@ template <typename I // I models InputIterator ,typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type - move_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) + move_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) { while (n--) { *r = ::boost::move(*f); @@ -1028,12 +895,12 @@ template <typename I // I models InputIterator ,typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type - move_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT -{ return container_detail::memmove_n_source(f, n, r); } + move_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) BOOST_NOEXCEPT_OR_NOTHROW +{ return container_detail::memmove_n_source_dest(f, n, r); } ////////////////////////////////////////////////////////////////////////////// // -// move_n_source_dest +// move_n_source // ////////////////////////////////////////////////////////////////////////////// @@ -1041,7 +908,7 @@ template <typename I // I models InputIterator ,typename F> // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type - move_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) + move_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) { while (n--) { *r = ::boost::move(*f); @@ -1054,33 +921,34 @@ template <typename I // I models InputIterator ,typename F> // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type - move_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT -{ return container_detail::memmove_n_source_dest(f, n, r); } + move_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW +{ return container_detail::memmove_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// // -// destroy_n +// destroy_alloc_n // ////////////////////////////////////////////////////////////////////////////// template - <typename A - ,typename I> // I models InputIterator -inline void destroy_alloc_n(A &a, I f, typename std::iterator_traits<I>::difference_type n - ,typename boost::container::container_detail::enable_if_c - < !boost::has_trivial_destructor<typename std::iterator_traits<I>::value_type>::value >::type* = 0) + <typename Allocator + ,typename I // I models InputIterator + ,typename U> // U models unsigned integral constant +inline typename container_detail::disable_if_trivially_destructible<I, void>::type + destroy_alloc_n(Allocator &a, I f, U n) { while(n--){ - allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(f++)); + allocator_traits<Allocator>::destroy(a, container_detail::iterator_to_raw_pointer(f)); + ++f; } } template - <typename A - ,typename I> // I models InputIterator -inline void destroy_alloc_n(A &, I, typename std::iterator_traits<I>::difference_type - ,typename boost::container::container_detail::enable_if_c - < boost::has_trivial_destructor<typename std::iterator_traits<I>::value_type>::value >::type* = 0) + <typename Allocator + ,typename I // I models InputIterator + ,typename U> // U models unsigned integral constant +inline typename container_detail::enable_if_trivially_destructible<I, void>::type + destroy_alloc_n(Allocator &, I, U) {} ////////////////////////////////////////////////////////////////////////////// @@ -1091,17 +959,17 @@ inline void destroy_alloc_n(A &, I, typename std::iterator_traits<I>::difference template <std::size_t MaxTmpBytes - ,typename A + ,typename Allocator ,typename F // F models ForwardIterator ,typename G // G models ForwardIterator > inline typename container_detail::disable_if_memtransfer_copy_assignable<F, G, void>::type - deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits<A>::size_type n_i - , G large_range_f, typename allocator_traits<A>::size_type n_j) + deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i + , G large_range_f, typename allocator_traits<Allocator>::size_type n_j) { - typename allocator_traits<A>::size_type n = 0; + typename allocator_traits<Allocator>::size_type n = 0; for (; n != n_i ; ++short_range_f, ++large_range_f, ++n){ - boost::container::swap_dispatch(*short_range_f, *large_range_f); + boost::adl_move_swap(*short_range_f, *large_range_f); } boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); @@ -1111,18 +979,18 @@ static const std::size_t DeepSwapAllocNMaxStorage = std::size_t(1) << std::size_ template <std::size_t MaxTmpBytes - ,typename A + ,typename Allocator ,typename F // F models ForwardIterator ,typename G // G models ForwardIterator > inline typename container_detail::enable_if_c < container_detail::is_memtransfer_copy_assignable<F, G>::value && (MaxTmpBytes <= DeepSwapAllocNMaxStorage) && false , void>::type - deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits<A>::size_type n_i - , G large_range_f, typename allocator_traits<A>::size_type n_j) + deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i + , G large_range_f, typename allocator_traits<Allocator>::size_type n_j) { - typedef typename allocator_traits<A>::value_type value_type; - typedef typename boost::aligned_storage + typedef typename allocator_traits<Allocator>::value_type value_type; + typedef typename container_detail::aligned_storage <MaxTmpBytes, container_detail::alignment_of<value_type>::value>::type storage_type; storage_type storage; @@ -1130,29 +998,29 @@ inline typename container_detail::enable_if_c void *const large_ptr = static_cast<void*>(container_detail::iterator_to_raw_pointer(large_range_f)); void *const short_ptr = static_cast<void*>(container_detail::iterator_to_raw_pointer(short_range_f)); void *const stora_ptr = static_cast<void*>(container_detail::iterator_to_raw_pointer(storage)); - ::memcpy(stora_ptr, large_ptr, n_i_bytes); - ::memcpy(large_ptr, short_ptr, n_i_bytes); - ::memcpy(short_ptr, stora_ptr, n_i_bytes); - std::advance(large_range_f, n_i); - std::advance(short_range_f, n_i); + std::memcpy(stora_ptr, large_ptr, n_i_bytes); + std::memcpy(large_ptr, short_ptr, n_i_bytes); + std::memcpy(short_ptr, stora_ptr, n_i_bytes); + boost::container::iterator_advance(large_range_f, n_i); + boost::container::iterator_advance(short_range_f, n_i); boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); } template <std::size_t MaxTmpBytes - ,typename A + ,typename Allocator ,typename F // F models ForwardIterator ,typename G // G models ForwardIterator > inline typename container_detail::enable_if_c < container_detail::is_memtransfer_copy_assignable<F, G>::value && true//(MaxTmpBytes > DeepSwapAllocNMaxStorage) , void>::type - deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits<A>::size_type n_i - , G large_range_f, typename allocator_traits<A>::size_type n_j) + deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i + , G large_range_f, typename allocator_traits<Allocator>::size_type n_j) { - typedef typename allocator_traits<A>::value_type value_type; - typedef typename boost::aligned_storage + typedef typename allocator_traits<Allocator>::value_type value_type; + typedef typename container_detail::aligned_storage <DeepSwapAllocNMaxStorage, container_detail::alignment_of<value_type>::value>::type storage_type; storage_type storage; const std::size_t sizeof_storage = sizeof(storage); @@ -1173,39 +1041,39 @@ inline typename container_detail::enable_if_c case 4: break; case 0: do{ - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; BOOST_CONTAINER_FALLTHOUGH case 3: - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; BOOST_CONTAINER_FALLTHOUGH case 2: - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; BOOST_CONTAINER_FALLTHOUGH case 1: - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; } while(--n); } - ::memcpy(stora_ptr, large_ptr, szt_rem); - ::memcpy(large_ptr, short_ptr, szt_rem); - ::memcpy(short_ptr, stora_ptr, szt_rem); - std::advance(large_range_f, n_i); - std::advance(short_range_f, n_i); + std::memcpy(stora_ptr, large_ptr, szt_rem); + std::memcpy(large_ptr, short_ptr, szt_rem); + std::memcpy(short_ptr, stora_ptr, szt_rem); + boost::container::iterator_advance(large_range_f, n_i); + boost::container::iterator_advance(short_range_f, n_i); boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); } @@ -1218,12 +1086,12 @@ inline typename container_detail::enable_if_c ////////////////////////////////////////////////////////////////////////////// template - <typename A + <typename Allocator ,typename I // F models InputIterator ,typename O // G models OutputIterator > -void copy_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits<A>::size_type n_i - , O out_start, typename allocator_traits<A>::size_type n_o ) +void copy_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits<Allocator>::size_type n_i + , O out_start, typename allocator_traits<Allocator>::size_type n_o ) { if (n_o < n_i){ inp_start = boost::container::copy_n_source_dest(inp_start, n_o, out_start); // may throw @@ -1242,12 +1110,12 @@ void copy_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits<A>: ////////////////////////////////////////////////////////////////////////////// template - <typename A + <typename Allocator ,typename I // F models InputIterator ,typename O // G models OutputIterator > -void move_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits<A>::size_type n_i - , O out_start, typename allocator_traits<A>::size_type n_o ) +void move_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits<Allocator>::size_type n_i + , O out_start, typename allocator_traits<Allocator>::size_type n_o ) { if (n_o < n_i){ inp_start = boost::container::move_n_source_dest(inp_start, n_o, out_start); // may throw @@ -1262,6 +1130,4 @@ void move_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits<A>: } //namespace container { } //namespace boost { -#include <boost/container/detail/config_end.hpp> - #endif //#ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP diff --git a/boost/container/detail/destroyers.hpp b/boost/container/detail/destroyers.hpp index ea9b617437..52b44c0363 100644 --- a/boost/container/detail/destroyers.hpp +++ b/boost/container/detail/destroyers.hpp @@ -13,16 +13,20 @@ #ifndef BOOST_CONTAINER_DESTROYERS_HPP #define BOOST_CONTAINER_DESTROYERS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> -#include <boost/container/detail/version_type.hpp> -#include <boost/container/detail/utilities.hpp> #include <boost/container/allocator_traits.hpp> +#include <boost/container/detail/to_raw_pointer.hpp> +#include <boost/container/detail/version_type.hpp> namespace boost { namespace container { @@ -30,22 +34,20 @@ namespace container_detail { //!A deleter for scoped_ptr that deallocates the memory //!allocated for an object using a STL allocator. -template <class A> +template <class Allocator> struct scoped_deallocator { - typedef allocator_traits<A> allocator_traits_type; + typedef allocator_traits<Allocator> allocator_traits_type; typedef typename allocator_traits_type::pointer pointer; typedef container_detail::integral_constant<unsigned, boost::container::container_detail:: - version<A>::value> alloc_version; - typedef container_detail::integral_constant<unsigned, 1> allocator_v1; - typedef container_detail::integral_constant<unsigned, 2> allocator_v2; + version<Allocator>::value> alloc_version; private: - void priv_deallocate(allocator_v1) + void priv_deallocate(version_1) { m_alloc.deallocate(m_ptr, 1); } - void priv_deallocate(allocator_v2) + void priv_deallocate(version_2) { m_alloc.deallocate_one(m_ptr); } BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator) @@ -53,9 +55,9 @@ struct scoped_deallocator public: pointer m_ptr; - A& m_alloc; + Allocator& m_alloc; - scoped_deallocator(pointer p, A& a) + scoped_deallocator(pointer p, Allocator& a) : m_ptr(p), m_alloc(a) {} @@ -143,8 +145,6 @@ struct scoped_destroy_deallocator typedef container_detail::integral_constant<unsigned, boost::container::container_detail:: version<Allocator>::value> alloc_version; - typedef container_detail::integral_constant<unsigned, 1> allocator_v1; - typedef container_detail::integral_constant<unsigned, 2> allocator_v2; scoped_destroy_deallocator(pointer p, Allocator& a) : m_ptr(p), m_alloc(a) {} @@ -162,10 +162,10 @@ struct scoped_destroy_deallocator private: - void priv_deallocate(const pointer &p, allocator_v1) + void priv_deallocate(const pointer &p, version_1) { AllocTraits::deallocate(m_alloc, p, 1); } - void priv_deallocate(const pointer &p, allocator_v2) + void priv_deallocate(const pointer &p, version_2) { m_alloc.deallocate_one(p); } pointer m_ptr; @@ -239,13 +239,13 @@ struct null_scoped_destructor_n {} }; -template<class A> +template<class Allocator> class scoped_destructor { - typedef boost::container::allocator_traits<A> AllocTraits; + typedef boost::container::allocator_traits<Allocator> AllocTraits; public: - typedef typename A::value_type value_type; - scoped_destructor(A &a, value_type *pv) + typedef typename Allocator::value_type value_type; + scoped_destructor(Allocator &a, value_type *pv) : pv_(pv), a_(a) {} @@ -266,17 +266,17 @@ class scoped_destructor private: value_type *pv_; - A &a_; + Allocator &a_; }; -template<class A> +template<class Allocator> class value_destructor { - typedef boost::container::allocator_traits<A> AllocTraits; + typedef boost::container::allocator_traits<Allocator> AllocTraits; public: - typedef typename A::value_type value_type; - value_destructor(A &a, value_type &rv) + typedef typename Allocator::value_type value_type; + value_destructor(Allocator &a, value_type &rv) : rv_(rv), a_(a) {} @@ -287,7 +287,7 @@ class value_destructor private: value_type &rv_; - A &a_; + Allocator &a_; }; template <class Allocator> @@ -299,21 +299,19 @@ class allocator_destroyer typedef container_detail::integral_constant<unsigned, boost::container::container_detail:: version<Allocator>::value> alloc_version; - typedef container_detail::integral_constant<unsigned, 1> allocator_v1; - typedef container_detail::integral_constant<unsigned, 2> allocator_v2; private: Allocator & a_; private: - void priv_deallocate(const pointer &p, allocator_v1) + void priv_deallocate(const pointer &p, version_1) { AllocTraits::deallocate(a_,p, 1); } - void priv_deallocate(const pointer &p, allocator_v2) + void priv_deallocate(const pointer &p, version_2) { a_.deallocate_one(p); } public: - allocator_destroyer(Allocator &a) + explicit allocator_destroyer(Allocator &a) : a_(a) {} @@ -324,41 +322,41 @@ class allocator_destroyer } }; -template <class A> +template <class Allocator> class allocator_destroyer_and_chain_builder { - typedef allocator_traits<A> allocator_traits_type; + typedef allocator_traits<Allocator> allocator_traits_type; typedef typename allocator_traits_type::value_type value_type; - typedef typename A::multiallocation_chain multiallocation_chain; + typedef typename Allocator::multiallocation_chain multiallocation_chain; - A & a_; + Allocator & a_; multiallocation_chain &c_; public: - allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c) + allocator_destroyer_and_chain_builder(Allocator &a, multiallocation_chain &c) : a_(a), c_(c) {} - void operator()(const typename A::pointer &p) + void operator()(const typename Allocator::pointer &p) { - allocator_traits<A>::destroy(a_, container_detail::to_raw_pointer(p)); + allocator_traits<Allocator>::destroy(a_, container_detail::to_raw_pointer(p)); c_.push_back(p); } }; -template <class A> +template <class Allocator> class allocator_multialloc_chain_node_deallocator { - typedef allocator_traits<A> allocator_traits_type; + typedef allocator_traits<Allocator> allocator_traits_type; typedef typename allocator_traits_type::value_type value_type; - typedef typename A::multiallocation_chain multiallocation_chain; - typedef allocator_destroyer_and_chain_builder<A> chain_builder; + typedef typename Allocator::multiallocation_chain multiallocation_chain; + typedef allocator_destroyer_and_chain_builder<Allocator> chain_builder; - A & a_; + Allocator & a_; multiallocation_chain c_; public: - allocator_multialloc_chain_node_deallocator(A &a) + allocator_multialloc_chain_node_deallocator(Allocator &a) : a_(a), c_() {} diff --git a/boost/container/detail/flat_tree.hpp b/boost/container/detail/flat_tree.hpp index a6f7568b43..a94043c6bd 100644 --- a/boost/container/detail/flat_tree.hpp +++ b/boost/container/detail/flat_tree.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_FLAT_TREE_HPP #define BOOST_CONTAINER_FLAT_TREE_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -20,29 +24,29 @@ #include <boost/container/container_fwd.hpp> -#include <algorithm> -#include <functional> -#include <utility> - -#include <boost/type_traits/has_trivial_destructor.hpp> #include <boost/move/utility_core.hpp> -#include <boost/container/detail/utilities.hpp> #include <boost/container/detail/pair.hpp> #include <boost/container/vector.hpp> #include <boost/container/detail/value_init.hpp> #include <boost/container/detail/destroyers.hpp> +#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare +#include <boost/container/detail/iterator.hpp> #include <boost/container/allocator_traits.hpp> #ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER #include <boost/intrusive/pointer_traits.hpp> #endif -#include <boost/aligned_storage.hpp> +#include <boost/container/detail/type_traits.hpp> #include <boost/move/make_unique.hpp> +#include <boost/move/adl_move_swap.hpp> +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include <boost/move/detail/fwd_macros.hpp> +#endif -namespace boost { +#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair +namespace boost { namespace container { - namespace container_detail { template<class Compare, class Value, class KeyOfValue> @@ -78,30 +82,29 @@ template<class Pointer> struct get_flat_tree_iterators { #ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER - typedef Pointer iterator; + typedef Pointer iterator; typedef typename boost::intrusive:: - pointer_traits<Pointer>::element_type iterator_element_type; + pointer_traits<Pointer>::element_type iterator_element_type; typedef typename boost::intrusive:: pointer_traits<Pointer>:: template - rebind_pointer<const iterator_element_type>::type const_iterator; + rebind_pointer<const iterator_element_type>::type const_iterator; #else //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER typedef typename boost::container::container_detail:: - vec_iterator<Pointer, false> iterator; + vec_iterator<Pointer, false> iterator; typedef typename boost::container::container_detail:: - vec_iterator<Pointer, true > const_iterator; + vec_iterator<Pointer, true > const_iterator; #endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER - typedef boost::container::container_detail:: - reverse_iterator<iterator> reverse_iterator; - typedef boost::container::container_detail:: - reverse_iterator<const_iterator> const_reverse_iterator; + typedef boost::container::reverse_iterator<iterator> reverse_iterator; + typedef boost::container::reverse_iterator<const_iterator> const_reverse_iterator; }; template <class Key, class Value, class KeyOfValue, - class Compare, class A> + class Compare, class Allocator> class flat_tree { - typedef boost::container::vector<Value, A> vector_t; - typedef A allocator_t; + typedef boost::container::vector<Value, Allocator> vector_t; + typedef Allocator allocator_t; + typedef allocator_traits<Allocator> allocator_traits_type; public: typedef flat_tree_value_compare<Compare, Value, KeyOfValue> value_compare; @@ -126,11 +129,11 @@ class flat_tree : value_compare(boost::move(static_cast<value_compare&>(d))), m_vect(boost::move(d.m_vect)) {} - Data(const Data &d, const A &a) + Data(const Data &d, const Allocator &a) : value_compare(static_cast<const value_compare&>(d)), m_vect(d.m_vect, a) {} - Data(BOOST_RV_REF(Data) d, const A &a) + Data(BOOST_RV_REF(Data) d, const Allocator &a) : value_compare(boost::move(static_cast<value_compare&>(d))), m_vect(boost::move(d.m_vect), a) {} @@ -163,7 +166,7 @@ class flat_tree void swap(Data &d) { value_compare& mycomp = *this, & othercomp = d; - boost::container::swap_dispatch(mycomp, othercomp); + boost::adl_move_swap(mycomp, othercomp); this->m_vect.swap(d.m_vect); } @@ -265,8 +268,10 @@ class flat_tree flat_tree& operator=(BOOST_COPY_ASSIGN_REF(flat_tree) x) { m_data = x.m_data; return *this; } - flat_tree& operator=(BOOST_RV_REF(flat_tree) mx) - { m_data = boost::move(mx.m_data); return *this; } + flat_tree& operator=(BOOST_RV_REF(flat_tree) x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_move_assignable<Compare>::value ) + { m_data = boost::move(x.m_data); return *this; } public: // accessors: @@ -331,6 +336,8 @@ class flat_tree { return this->m_data.m_vect.max_size(); } void swap(flat_tree& other) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_swappable<Compare>::value ) { this->m_data.swap(other.m_data); } public: @@ -428,7 +435,7 @@ class flat_tree #endif ) { - const size_type len = static_cast<size_type>(std::distance(first, last)); + const size_type len = static_cast<size_type>(boost::container::iterator_distance(first, last)); this->reserve(this->size()+len); this->priv_insert_equal_loop(first, last); } @@ -455,7 +462,7 @@ class flat_tree #endif ) { - const size_type len = static_cast<size_type>(std::distance(first, last)); + const size_type len = static_cast<size_type>(boost::container::iterator_distance(first, last)); this->reserve(this->size()+len); this->priv_insert_equal_loop_ordered(first, last); } @@ -499,12 +506,12 @@ class flat_tree ) { this->priv_insert_ordered_range(true, first, last); } - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template <class... Args> - std::pair<iterator, bool> emplace_unique(Args&&... args) + std::pair<iterator, bool> emplace_unique(BOOST_FWD_REF(Args)... args) { - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); @@ -513,9 +520,9 @@ class flat_tree } template <class... Args> - iterator emplace_hint_unique(const_iterator hint, Args&&... args) + iterator emplace_hint_unique(const_iterator hint, BOOST_FWD_REF(Args)... args) { - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); @@ -524,9 +531,9 @@ class flat_tree } template <class... Args> - iterator emplace_equal(Args&&... args) + iterator emplace_equal(BOOST_FWD_REF(Args)... args) { - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); @@ -535,9 +542,9 @@ class flat_tree } template <class... Args> - iterator emplace_hint_equal(const_iterator hint, Args&&... args) + iterator emplace_hint_equal(const_iterator hint, BOOST_FWD_REF(Args)... args) { - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); @@ -545,64 +552,57 @@ class flat_tree return this->insert_equal(hint, ::boost::move(val)); } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - #define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - std::pair<iterator, bool> \ - emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \ - value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor<stored_allocator_type> d(a, val); \ - return this->insert_unique(::boost::move(val)); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_hint_unique(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \ - value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor<stored_allocator_type> d(a, val); \ - return this->insert_unique(hint, ::boost::move(val)); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \ - value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor<stored_allocator_type> d(a, val); \ - return this->insert_equal(::boost::move(val)); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_hint_equal(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \ - value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor<stored_allocator_type> d(a, val); \ - return this->insert_equal(hint, ::boost::move(val)); \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + #define BOOST_CONTAINER_FLAT_TREE_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + std::pair<iterator, bool> emplace_unique(BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\ + value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor<stored_allocator_type> d(a, val);\ + return this->insert_unique(::boost::move(val));\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint_unique(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\ + value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor<stored_allocator_type> d(a, val);\ + return this->insert_unique(hint, ::boost::move(val));\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_equal(BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\ + value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor<stored_allocator_type> d(a, val);\ + return this->insert_equal(::boost::move(val));\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint_equal(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage <sizeof(value_type), alignment_of<value_type>::value>::type v;\ + value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor<stored_allocator_type> d(a, val);\ + return this->insert_equal(hint, ::boost::move(val));\ + }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_TREE_EMPLACE_CODE) + #undef BOOST_CONTAINER_FLAT_TREE_EMPLACE_CODE + + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) iterator erase(const_iterator position) { return this->m_data.m_vect.erase(position); } @@ -632,6 +632,18 @@ class flat_tree void shrink_to_fit() { this->m_data.m_vect.shrink_to_fit(); } + iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.nth(n); } + + const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.nth(n); } + + size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.index_of(p); } + + size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.index_of(p); } + // set operations: iterator find(const key_type& k) { @@ -694,13 +706,12 @@ class flat_tree friend bool operator==(const flat_tree& x, const flat_tree& y) { - return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); + return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } friend bool operator<(const flat_tree& x, const flat_tree& y) { - return std::lexicographical_compare(x.begin(), x.end(), - y.begin(), y.end()); + return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } friend bool operator!=(const flat_tree& x, const flat_tree& y) @@ -936,7 +947,7 @@ class flat_tree template <class BidirIt> void priv_insert_ordered_range(const bool unique_values, BidirIt first, BidirIt last) { - size_type len = static_cast<size_type>(std::distance(first, last)); + size_type len = static_cast<size_type>(boost::container::iterator_distance(first, last)); //Prereserve all memory so that iterators are not invalidated this->reserve(this->size()+len); //Auxiliary data for insertion positions. @@ -955,10 +966,10 @@ class flat_tree size_type unique_burst = 0u; size_type checked = 0; for(; checked != burst; ++checked){ - //Get the insertion position for each key, use std::iterator_traits<BidirIt>::value_type + //Get the insertion position for each key, use iterator_traits<BidirIt>::value_type //because it can be different from container::value_type - //(e.g. conversion between std::pair<A, B> -> boost::container::pair<A, B> - const typename std::iterator_traits<BidirIt>::value_type & val = *first; + //(e.g. conversion between std::pair<T1, T2> -> boost::container::pair<T1, T2> + const typename boost::container::iterator_traits<BidirIt>::value_type & val = *first; pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, ce, KeyOfValue()(val)); //Check if already present if (pos != ce){ @@ -984,7 +995,11 @@ class flat_tree while(len--){ BidirIt next(first); ++next; - if(next == last || val_cmp(*first, *next)){ + //Use iterator_traits<BidirIt>::value_type + //because it can be different from container::value_type + //(e.g. conversion between std::pair<T1, T2> -> boost::container::pair<T1, T2> + const typename boost::container::iterator_traits<BidirIt>::value_type & val = *first; + if (next == last || val_cmp(val, *next)){ const bool room = this->m_data.m_vect.stable_emplace_back(*first); (void)room; BOOST_ASSERT(room); @@ -994,7 +1009,7 @@ class flat_tree BOOST_ASSERT(first == last); } else{ - BOOST_ASSERT(size_type(std::distance(first, last)) == len); + BOOST_ASSERT(size_type(boost::container::iterator_distance(first, last)) == len); if(len) this->m_data.m_vect.insert(this->m_data.m_vect.cend(), len, first, last); } @@ -1004,16 +1019,18 @@ class flat_tree } //namespace container_detail { } //namespace container { -/* + //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations -template <class K, class V, class KOV, -class C, class A> -struct has_trivial_destructor_after_move<boost::container::container_detail::flat_tree<K, V, KOV, C, A> > +template <class Key, class T, class KeyOfValue, +class Compare, class Allocator> +struct has_trivial_destructor_after_move<boost::container::container_detail::flat_tree<Key, T, KeyOfValue, Compare, Allocator> > { - static const bool value = has_trivial_destructor_after_move<A>::value && has_trivial_destructor_after_move<C>::value; + typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value && + ::boost::has_trivial_destructor_after_move<pointer>::value; }; -*/ + } //namespace boost { #include <boost/container/detail/config_end.hpp> diff --git a/boost/container/detail/function_detector.hpp b/boost/container/detail/function_detector.hpp index 242eb41352..00caced5ba 100644 --- a/boost/container/detail/function_detector.hpp +++ b/boost/container/detail/function_detector.hpp @@ -22,7 +22,11 @@ #ifndef BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP #define BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/hash_table.hpp b/boost/container/detail/hash_table.hpp index da7bb536e4..4bc5c901de 100644 --- a/boost/container/detail/hash_table.hpp +++ b/boost/container/detail/hash_table.hpp @@ -1,6 +1,6 @@ /* template <class Value, unsigned int Options = 0, class Hash = hash<Value>, class Pred = equal_to<Value>, - class Alloc = allocator<Value> > + class Allocator = allocator<Value> > class hash_set { public: @@ -9,7 +9,7 @@ public: typedef key_type value_type; typedef Hash hasher; typedef Pred key_equal; - typedef Alloc allocator_type; + typedef Allocator allocator_type; typedef value_type& reference; typedef const value_type& const_reference; typedef typename allocator_traits<allocator_type>::pointer pointer; @@ -71,9 +71,9 @@ public: const_iterator cend() const noexcept; template <class... Args> - pair<iterator, bool> emplace(Args&&... args); + pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args); template <class... Args> - iterator emplace_hint(const_iterator position, Args&&... args); + iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); pair<iterator, bool> insert(const value_type& obj); pair<iterator, bool> insert(value_type&& obj); iterator insert(const_iterator hint, const value_type& obj); @@ -124,7 +124,7 @@ public: }; template <class Key, class T, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>, - class Alloc = allocator<pair<const Key, T> > > + class Allocator = allocator<pair<const Key, T> > > class hash_map { public: @@ -133,7 +133,7 @@ public: typedef T mapped_type; typedef Hash hasher; typedef Pred key_equal; - typedef Alloc allocator_type; + typedef Allocator allocator_type; typedef pair<const key_type, mapped_type> value_type; typedef value_type& reference; typedef const value_type& const_reference; @@ -196,9 +196,9 @@ public: const_iterator cend() const noexcept; template <class... Args> - pair<iterator, bool> emplace(Args&&... args); + pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args); template <class... Args> - iterator emplace_hint(const_iterator position, Args&&... args); + iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); pair<iterator, bool> insert(const value_type& obj); template <class P> pair<iterator, bool> insert(P&& obj); @@ -259,7 +259,7 @@ public: */ template <class Key, class Value, class KeyOfValue, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>, - class Alloc = allocator<Value> > + class Allocator = allocator<Value> > class hash_table { public: @@ -268,7 +268,7 @@ public: typedef key_type value_type; typedef Hash hasher; typedef Pred key_equal; - typedef Alloc allocator_type; + typedef Allocator allocator_type; typedef value_type& reference; typedef const value_type& const_reference; typedef typename allocator_traits<allocator_type>::pointer pointer; @@ -330,9 +330,9 @@ public: const_iterator cend() const noexcept; template <class... Args> - pair<iterator, bool> emplace(Args&&... args); + pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args); template <class... Args> - iterator emplace_hint(const_iterator position, Args&&... args); + iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); pair<iterator, bool> insert(const value_type& obj); pair<iterator, bool> insert(value_type&& obj); iterator insert(const_iterator hint, const value_type& obj); diff --git a/boost/container/detail/iterator.hpp b/boost/container/detail/iterator.hpp new file mode 100644 index 0000000000..ceb224f3ad --- /dev/null +++ b/boost/container/detail/iterator.hpp @@ -0,0 +1,39 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_ITERATOR_HPP +#define BOOST_CONTAINER_DETAIL_ITERATOR_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include <boost/intrusive/detail/iterator.hpp> + +namespace boost { +namespace container { + +using ::boost::intrusive::iterator_traits; +using ::boost::intrusive::iterator_distance; +using ::boost::intrusive::iterator_advance; +using ::boost::intrusive::iterator; +using ::boost::intrusive::iterator_enable_if_tag; +using ::boost::intrusive::iterator_disable_if_tag; + +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP diff --git a/boost/container/detail/iterator_to_raw_pointer.hpp b/boost/container/detail/iterator_to_raw_pointer.hpp new file mode 100644 index 0000000000..83736d8bb1 --- /dev/null +++ b/boost/container/detail/iterator_to_raw_pointer.hpp @@ -0,0 +1,58 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_DETAIL_ITERATOR_TO_RAW_POINTER_HPP +#define BOOST_CONTAINER_DETAIL_ITERATOR_TO_RAW_POINTER_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include <boost/container/detail/iterator.hpp> +#include <boost/container/detail/to_raw_pointer.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +template <class T> +inline T* iterator_to_pointer(T* i) +{ return i; } + +template <class Iterator> +inline typename boost::container::iterator_traits<Iterator>::pointer + iterator_to_pointer(const Iterator &i) +{ return i.operator->(); } + +template <class Iterator> +struct iterator_to_element_ptr +{ + typedef typename boost::container::iterator_traits<Iterator>::pointer pointer; + typedef typename boost::intrusive::pointer_traits<pointer>::element_type element_type; + typedef element_type* type; +}; + +template <class Iterator> +inline typename iterator_to_element_ptr<Iterator>::type + iterator_to_raw_pointer(const Iterator &i) +{ + return ::boost::intrusive::detail::to_raw_pointer + ( ::boost::container::container_detail::iterator_to_pointer(i) ); +} + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATOR_TO_RAW_POINTER_HPP diff --git a/boost/container/detail/iterators.hpp b/boost/container/detail/iterators.hpp index 0dabd3c73e..1f80d3e122 100644 --- a/boost/container/detail/iterators.hpp +++ b/boost/container/detail/iterators.hpp @@ -14,7 +14,11 @@ #ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP #define BOOST_CONTAINER_DETAIL_ITERATORS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -26,20 +30,19 @@ #include <boost/move/utility_core.hpp> #include <boost/intrusive/detail/reverse_iterator.hpp> -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING -#include <boost/container/detail/variadic_templates_tools.hpp> +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include <boost/move/detail/fwd_macros.hpp> #else -#include <boost/container/detail/preprocessor.hpp> +#include <boost/container/detail/variadic_templates_tools.hpp> #endif - -#include <iterator> +#include <boost/container/detail/iterator.hpp> namespace boost { namespace container { template <class T, class Difference = std::ptrdiff_t> class constant_iterator - : public std::iterator + : public ::boost::container::iterator <std::random_access_iterator_tag, T, Difference, const T*, const T &> { typedef constant_iterator<T, Difference> this_type; @@ -150,7 +153,7 @@ class constant_iterator template <class T, class Difference> class value_init_construct_iterator - : public std::iterator + : public ::boost::container::iterator <std::random_access_iterator_tag, T, Difference, const T*, const T &> { typedef value_init_construct_iterator<T, Difference> this_type; @@ -261,7 +264,7 @@ class value_init_construct_iterator template <class T, class Difference> class default_init_construct_iterator - : public std::iterator + : public ::boost::container::iterator <std::random_access_iterator_tag, T, Difference, const T*, const T &> { typedef default_init_construct_iterator<T, Difference> this_type; @@ -373,7 +376,7 @@ class default_init_construct_iterator template <class T, class Difference = std::ptrdiff_t> class repeat_iterator - : public std::iterator + : public ::boost::container::iterator <std::random_access_iterator_tag, T, Difference> { typedef repeat_iterator<T, Difference> this_type; @@ -483,7 +486,7 @@ class repeat_iterator template <class T, class EmplaceFunctor, class Difference /*= std::ptrdiff_t*/> class emplace_iterator - : public std::iterator + : public ::boost::container::iterator <std::random_access_iterator_tag, T, Difference, const T*, const T &> { typedef emplace_iterator this_type; @@ -564,8 +567,8 @@ class emplace_iterator //const T& operator[](difference_type) const; //const T* operator->() const; - template<class A> - void construct_in_place(A &a, T* ptr) + template<class Allocator> + void construct_in_place(Allocator &a, T* ptr) { (*m_pe)(a, ptr); } private: @@ -597,54 +600,49 @@ class emplace_iterator { return difference_type(m_num - other.m_num); } }; -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class ...Args> struct emplace_functor { typedef typename container_detail::build_number_seq<sizeof...(Args)>::type index_tuple_t; - emplace_functor(Args&&... args) + emplace_functor(BOOST_FWD_REF(Args)... args) : args_(args...) {} - template<class A, class T> - void operator()(A &a, T *ptr) + template<class Allocator, class T> + void operator()(Allocator &a, T *ptr) { emplace_functor::inplace_impl(a, ptr, index_tuple_t()); } - template<class A, class T, int ...IdxPack> - void inplace_impl(A &a, T* ptr, const container_detail::index_tuple<IdxPack...>&) + template<class Allocator, class T, int ...IdxPack> + void inplace_impl(Allocator &a, T* ptr, const container_detail::index_tuple<IdxPack...>&) { - allocator_traits<A>::construct + allocator_traits<Allocator>::construct (a, ptr, ::boost::forward<Args>(container_detail::get<IdxPack>(args_))...); } container_detail::tuple<Args&...> args_; }; -#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING - -#define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template <) \ - BOOST_PP_ENUM_PARAMS(n, class P) \ - BOOST_PP_EXPR_IF(n, >) \ - struct BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \ - { \ - BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \ - ( BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - BOOST_PP_EXPR_IF(n, :) BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_INIT, _){} \ - \ - template<class A, class T> \ - void operator()(A &a, T *ptr) \ - { \ - allocator_traits<A>::construct \ - (a, ptr BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) ); \ - } \ - BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \ - }; \ - //! -#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) -#include BOOST_PP_LOCAL_ITERATE() +#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +#define BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE(N) \ +BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ +struct emplace_functor##N\ +{\ + explicit emplace_functor##N( BOOST_MOVE_UREF##N )\ + BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N{}\ + \ + template<class Allocator, class T>\ + void operator()(Allocator &a, T *ptr)\ + { allocator_traits<Allocator>::construct(a, ptr BOOST_MOVE_I##N BOOST_MOVE_MFWD##N); }\ + \ + BOOST_MOVE_MREF##N\ +};\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE) +#undef BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE #endif @@ -709,8 +707,8 @@ struct iiterator_types { typedef typename IIterator::value_type it_value_type; typedef typename iiterator_node_value_type<it_value_type>::type value_type; - typedef typename std::iterator_traits<IIterator>::pointer it_pointer; - typedef typename std::iterator_traits<IIterator>::difference_type difference_type; + typedef typename boost::container::iterator_traits<IIterator>::pointer it_pointer; + typedef typename boost::container::iterator_traits<IIterator>::difference_type difference_type; typedef typename ::boost::intrusive::pointer_traits<it_pointer>:: template rebind_pointer<value_type>::type pointer; typedef typename ::boost::intrusive::pointer_traits<it_pointer>:: @@ -723,9 +721,9 @@ struct iiterator_types }; template<class IIterator, bool IsConst> -struct std_iterator +struct iterator_types { - typedef typename std::iterator + typedef typename ::boost::container::iterator < typename iiterator_types<IIterator>::iterator_category , typename iiterator_types<IIterator>::value_type , typename iiterator_types<IIterator>::difference_type @@ -734,9 +732,9 @@ struct std_iterator }; template<class IIterator> -struct std_iterator<IIterator, false> +struct iterator_types<IIterator, false> { - typedef typename std::iterator + typedef typename ::boost::container::iterator < typename iiterator_types<IIterator>::iterator_category , typename iiterator_types<IIterator>::value_type , typename iiterator_types<IIterator>::difference_type @@ -745,9 +743,9 @@ struct std_iterator<IIterator, false> }; template<class IIterator, bool IsConst> -class iterator +class iterator_from_iiterator { - typedef typename std_iterator<IIterator, IsConst>::type types_t; + typedef typename iterator_types<IIterator, IsConst>::type types_t; public: typedef typename types_t::pointer pointer; @@ -756,63 +754,64 @@ class iterator typedef typename types_t::iterator_category iterator_category; typedef typename types_t::value_type value_type; - iterator() + iterator_from_iiterator() {} - explicit iterator(IIterator iit) BOOST_CONTAINER_NOEXCEPT + explicit iterator_from_iiterator(IIterator iit) BOOST_NOEXCEPT_OR_NOTHROW : m_iit(iit) {} - iterator(iterator<IIterator, false> const& other) BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator(iterator_from_iiterator<IIterator, false> const& other) BOOST_NOEXCEPT_OR_NOTHROW : m_iit(other.get()) {} - iterator& operator++() BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator& operator++() BOOST_NOEXCEPT_OR_NOTHROW { ++this->m_iit; return *this; } - iterator operator++(int) BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator operator++(int) BOOST_NOEXCEPT_OR_NOTHROW { - iterator result (*this); + iterator_from_iiterator result (*this); ++this->m_iit; return result; } - iterator& operator--() BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator& operator--() BOOST_NOEXCEPT_OR_NOTHROW { - //If the iterator is not a bidirectional iterator, operator-- should not exist - BOOST_STATIC_ASSERT((is_bidirectional_iterator<iterator>::value)); + //If the iterator_from_iiterator is not a bidirectional iterator, operator-- should not exist + BOOST_STATIC_ASSERT((is_bidirectional_iterator<iterator_from_iiterator>::value)); --this->m_iit; return *this; } - iterator operator--(int) BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator operator--(int) BOOST_NOEXCEPT_OR_NOTHROW { - iterator result (*this); + iterator_from_iiterator result (*this); --this->m_iit; return result; } - friend bool operator== (const iterator& l, const iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator== (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_iit == r.m_iit; } - friend bool operator!= (const iterator& l, const iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator!= (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return !(l == r); } - reference operator*() const BOOST_CONTAINER_NOEXCEPT + reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW { return (*this->m_iit).get_data(); } - pointer operator->() const BOOST_CONTAINER_NOEXCEPT + pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW { return ::boost::intrusive::pointer_traits<pointer>::pointer_to(this->operator*()); } - const IIterator &get() const BOOST_CONTAINER_NOEXCEPT + const IIterator &get() const BOOST_NOEXCEPT_OR_NOTHROW { return this->m_iit; } private: IIterator m_iit; }; -using ::boost::intrusive::detail::reverse_iterator; - } //namespace container_detail { + +using ::boost::intrusive::reverse_iterator; + } //namespace container { } //namespace boost { diff --git a/boost/container/detail/math_functions.hpp b/boost/container/detail/math_functions.hpp index 6853b9c59f..e499f633ec 100644 --- a/boost/container/detail/math_functions.hpp +++ b/boost/container/detail/math_functions.hpp @@ -16,7 +16,11 @@ #ifndef BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP #define BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/memory_util.hpp b/boost/container/detail/memory_util.hpp deleted file mode 100644 index 7f055cb55b..0000000000 --- a/boost/container/detail/memory_util.hpp +++ /dev/null @@ -1,90 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/container for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP -#define BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include <boost/container/detail/config_begin.hpp> -#include <boost/container/detail/workaround.hpp> - -#include <boost/container/detail/preprocessor.hpp> -#include <boost/intrusive/detail/mpl.hpp> -#include <boost/intrusive/detail/has_member_function_callable_with.hpp> - - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (2, 2, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME max_size -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME select_on_container_copy_construction -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#ifdef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_SINGLE_ITERATION -# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) -#else -# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS+1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) -#endif -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME swap -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) -#include BOOST_PP_ITERATE() - -namespace boost { -namespace container { -namespace container_detail { - -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(void_pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_void_pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_compare) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(wrapped_value_compare) - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include <boost/container/detail/config_end.hpp> - -#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP) diff --git a/boost/container/detail/min_max.hpp b/boost/container/detail/min_max.hpp new file mode 100644 index 0000000000..7486db7d05 --- /dev/null +++ b/boost/container/detail/min_max.hpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_DETAIL_MIN_MAX_HPP +#define BOOST_CONTAINER_DETAIL_MIN_MAX_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +namespace boost { +namespace container { +namespace container_detail { + +template<class T> +const T &max_value(const T &a, const T &b) +{ return a > b ? a : b; } + +template<class T> +const T &min_value(const T &a, const T &b) +{ return a < b ? a : b; } + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_MIN_MAX_HPP diff --git a/boost/container/detail/minimal_char_traits_header.hpp b/boost/container/detail/minimal_char_traits_header.hpp new file mode 100644 index 0000000000..a92a31a2b4 --- /dev/null +++ b/boost/container/detail/minimal_char_traits_header.hpp @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_DETAIL_MINIMAL_CHAR_TRAITS_HEADER_HPP +#define BOOST_CONTAINER_DETAIL_MINIMAL_CHAR_TRAITS_HEADER_HPP +# +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif +# +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif +# +#//Try to avoid including <string>, as it's quite big +#if defined(_MSC_VER) && defined(BOOST_DINKUMWARE_STDLIB) + #include <iosfwd> //Dinkum libraries for MSVC define std::char_traits there +#elif defined(BOOST_GNU_STDLIB) + #include <bits/char_traits.h> +#else + #include <string> //Fallback +#endif + +#endif //BOOST_CONTAINER_DETAIL_MINIMAL_CHAR_TRAITS_HEADER_HPP diff --git a/boost/container/detail/mpl.hpp b/boost/container/detail/mpl.hpp index ceac52a371..74b618f8c6 100644 --- a/boost/container/detail/mpl.hpp +++ b/boost/container/detail/mpl.hpp @@ -13,7 +13,11 @@ #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP #define BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -40,6 +44,13 @@ struct bool_ : integral_constant<bool, C_> operator bool() const { return bool_::value; } }; +template< unsigned V_ > +struct unsigned_ : integral_constant<unsigned, V_> +{ + static const unsigned value = V_; + operator unsigned() const { return unsigned_::value; } +}; + typedef bool_<true> true_; typedef bool_<false> false_; @@ -169,6 +180,12 @@ struct ls_zeros<1> static const std::size_t value = 0; }; +template <std::size_t OrigSize, std::size_t RoundTo> +struct ct_rounded_size +{ + static const std::size_t value = ((OrigSize-1)/RoundTo+1)*RoundTo; +}; + template <typename T> struct unvoid { typedef T type; }; template <> struct unvoid<void> { struct type { }; }; template <> struct unvoid<const void> { struct type { }; }; diff --git a/boost/container/detail/multiallocation_chain.hpp b/boost/container/detail/multiallocation_chain.hpp index 96f6202671..32f87c8ae9 100644 --- a/boost/container/detail/multiallocation_chain.hpp +++ b/boost/container/detail/multiallocation_chain.hpp @@ -11,20 +11,26 @@ #ifndef BOOST_CONTAINER_DETAIL_MULTIALLOCATION_CHAIN_HPP #define BOOST_CONTAINER_DETAIL_MULTIALLOCATION_CHAIN_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> - +// container #include <boost/container/container_fwd.hpp> -#include <boost/container/detail/utilities.hpp> -#include <boost/container/detail/type_traits.hpp> +// container/detail +#include <boost/container/detail/to_raw_pointer.hpp> #include <boost/container/detail/transform_iterator.hpp> +#include <boost/container/detail/type_traits.hpp> +// intrusive #include <boost/intrusive/slist.hpp> #include <boost/intrusive/pointer_traits.hpp> -#include <boost/type_traits/make_unsigned.hpp> +// move #include <boost/move/utility_core.hpp> namespace boost { @@ -47,7 +53,7 @@ class basic_multiallocation_chain typedef bi::slist< node , bi::linear<true> , bi::cache_last<true> - , bi::size_type<typename boost::make_unsigned<difference_type>::type> + , bi::size_type<typename boost::container::container_detail::make_unsigned<difference_type>::type> > slist_impl_t; slist_impl_t slist_impl_; diff --git a/boost/container/detail/mutex.hpp b/boost/container/detail/mutex.hpp index c53afa1f42..f8efa7fe6b 100644 --- a/boost/container/detail/mutex.hpp +++ b/boost/container/detail/mutex.hpp @@ -19,7 +19,11 @@ #ifndef BOOST_CONTAINER_MUTEX_HPP #define BOOST_CONTAINER_MUTEX_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -162,7 +166,7 @@ #define BOOST_CONTAINER_TRY_LOCK(sl) !BOOST_CONTAINER_CAS_LOCK(sl) #define BOOST_CONTAINER_RELEASE_LOCK(sl) BOOST_CONTAINER_CLEAR_LOCK(sl) #define BOOST_CONTAINER_ACQUIRE_LOCK(sl) (BOOST_CONTAINER_CAS_LOCK(sl)? boost_interprocess_spin_acquire_lock(sl) : 0) - #define BOOST_CONTAINER_INITIAL_LOCK(sl) (*sl = 0) + #define BOOST_MOVE_INITIAL_LOCK(sl) (*sl = 0) #define BOOST_CONTAINER_DESTROY_LOCK(sl) (0) #elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_WIN32 // @@ -199,7 +203,7 @@ namespace container_detail { void operator=(const spin_mutex &); public: - spin_mutex() { BOOST_CONTAINER_INITIAL_LOCK(&sl); } + spin_mutex() { BOOST_MOVE_INITIAL_LOCK(&sl); } void lock() { BOOST_CONTAINER_ACQUIRE_LOCK(&sl); } void unlock() { BOOST_CONTAINER_RELEASE_LOCK(&sl); } diff --git a/boost/container/detail/next_capacity.hpp b/boost/container/detail/next_capacity.hpp new file mode 100644 index 0000000000..3bc98a3c91 --- /dev/null +++ b/boost/container/detail/next_capacity.hpp @@ -0,0 +1,75 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP +#define BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +// container +#include <boost/container/throw_exception.hpp> +// container/detail +#include <boost/container/detail/min_max.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +enum NextCapacityOption { NextCapacityDouble, NextCapacity60Percent }; + +template<class SizeType, NextCapacityOption Option> +struct next_capacity_calculator; + +template<class SizeType> +struct next_capacity_calculator<SizeType, NextCapacityDouble> +{ + static SizeType get(const SizeType max_size + ,const SizeType capacity + ,const SizeType n) + { + const SizeType remaining = max_size - capacity; + if ( remaining < n ) + boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); + const SizeType additional = max_value(n, capacity); + return ( remaining < additional ) ? max_size : ( capacity + additional ); + } +}; + +template<class SizeType> +struct next_capacity_calculator<SizeType, NextCapacity60Percent> +{ + static SizeType get(const SizeType max_size + ,const SizeType capacity + ,const SizeType n) + { + const SizeType remaining = max_size - capacity; + if ( remaining < n ) + boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); + const SizeType m3 = max_size/3; + + if (capacity < m3) + return capacity + max_value(3*(capacity+1)/5, n); + + if (capacity < m3*2) + return capacity + max_value((capacity+1)/2, n); + return max_size; + } +}; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP diff --git a/boost/container/detail/node_alloc_holder.hpp b/boost/container/detail/node_alloc_holder.hpp index 250c559765..98c8e62baa 100644 --- a/boost/container/detail/node_alloc_holder.hpp +++ b/boost/container/detail/node_alloc_holder.hpp @@ -11,82 +11,63 @@ #ifndef BOOST_CONTAINER_DETAIL_NODE_ALLOC_HPP_ #define BOOST_CONTAINER_DETAIL_NODE_ALLOC_HPP_ -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> -#include <utility> -#include <functional> - -#include <boost/move/utility_core.hpp> -#include <boost/intrusive/options.hpp> - -#include <boost/container/detail/version_type.hpp> -#include <boost/container/detail/type_traits.hpp> -#include <boost/container/detail/utilities.hpp> +// container #include <boost/container/allocator_traits.hpp> +// container/detail +#include <boost/container/detail/addressof.hpp> +#include <boost/container/detail/alloc_helpers.hpp> #include <boost/container/detail/allocator_version_traits.hpp> -#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/construct_in_place.hpp> #include <boost/container/detail/destroyers.hpp> -#include <boost/container/detail/memory_util.hpp> +#include <boost/container/detail/iterator_to_raw_pointer.hpp> +#include <boost/container/detail/mpl.hpp> #include <boost/container/detail/placement_new.hpp> -#include <boost/core/no_exceptions_support.hpp> - -#ifndef BOOST_CONTAINER_PERFECT_FORWARDING -#include <boost/container/detail/preprocessor.hpp> +#include <boost/container/detail/to_raw_pointer.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/version_type.hpp> +// intrusive +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/options.hpp> +// move +#include <boost/move/utility_core.hpp> +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include <boost/move/detail/fwd_macros.hpp> #endif - -#include <boost/container/detail/algorithms.hpp> - +// other +#include <boost/core/no_exceptions_support.hpp> namespace boost { namespace container { namespace container_detail { -template<class ValueCompare, class Node> -struct node_compare - : private ValueCompare -{ - typedef ValueCompare wrapped_value_compare; - typedef typename wrapped_value_compare::key_type key_type; - typedef typename wrapped_value_compare::value_type value_type; - typedef typename wrapped_value_compare::key_of_value key_of_value; - - explicit node_compare(const wrapped_value_compare &pred) - : wrapped_value_compare(pred) - {} - - node_compare() - : wrapped_value_compare() - {} - - wrapped_value_compare &value_comp() - { return static_cast<wrapped_value_compare &>(*this); } +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_compare) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(predicate_type) - wrapped_value_compare &value_comp() const - { return static_cast<const wrapped_value_compare &>(*this); } - - bool operator()(const Node &a, const Node &b) const - { return wrapped_value_compare::operator()(a.get_data(), b.get_data()); } -}; - -template<class A, class ICont> +template<class Allocator, class ICont> struct node_alloc_holder { //If the intrusive container is an associative container, obtain the predicate, which will //be of type node_compare<>. If not an associative container value_compare will be a "nat" type. typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, ICont, value_compare, container_detail::nat) intrusive_value_compare; - //In that case obtain the value predicate from the node predicate via wrapped_value_compare + //In that case obtain the value predicate from the node predicate via predicate_type //if intrusive_value_compare is node_compare<>, nat otherwise - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, ICont, - wrapped_value_compare, container_detail::nat) value_compare; + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, intrusive_value_compare, + predicate_type, container_detail::nat) value_compare; - typedef allocator_traits<A> allocator_traits_type; + typedef allocator_traits<Allocator> allocator_traits_type; typedef typename allocator_traits_type::value_type value_type; typedef ICont intrusive_container; typedef typename ICont::value_type Node; @@ -94,13 +75,11 @@ struct node_alloc_holder portable_rebind_alloc<Node>::type NodeAlloc; typedef allocator_traits<NodeAlloc> node_allocator_traits_type; typedef container_detail::allocator_version_traits<NodeAlloc> node_allocator_version_traits_type; - typedef A ValAlloc; + typedef Allocator ValAlloc; typedef typename node_allocator_traits_type::pointer NodePtr; typedef container_detail::scoped_deallocator<NodeAlloc> Deallocator; typedef typename node_allocator_traits_type::size_type size_type; typedef typename node_allocator_traits_type::difference_type difference_type; - typedef container_detail::integral_constant<unsigned, 1> allocator_v1; - typedef container_detail::integral_constant<unsigned, 2> allocator_v2; typedef container_detail::integral_constant<unsigned, boost::container::container_detail:: version<NodeAlloc>::value> alloc_version; @@ -133,11 +112,11 @@ struct node_alloc_holder { this->icont().swap(x.icont()); } //Constructors for associative containers - explicit node_alloc_holder(const ValAlloc &a, const value_compare &c) + explicit node_alloc_holder(const value_compare &c, const ValAlloc &a) : members_(a, c) {} - explicit node_alloc_holder(const node_alloc_holder &x, const value_compare &c) + explicit node_alloc_holder(const value_compare &c, const node_alloc_holder &x) : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc()), c) {} @@ -176,7 +155,7 @@ struct node_alloc_holder void deallocate_one(const NodePtr &p) { AllocVersionTraits::deallocate_one(this->node_alloc(), p); } - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class ...Args> NodePtr create_node(Args &&...args) @@ -193,28 +172,90 @@ struct node_alloc_holder return (p); } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - #define BOOST_PP_LOCAL_MACRO(n) \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - NodePtr create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - NodePtr p = this->allocate_one(); \ - Deallocator node_deallocator(p, this->node_alloc()); \ - allocator_traits<NodeAlloc>::construct \ - (this->node_alloc(), container_detail::addressof(p->m_data) \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - node_deallocator.release(); \ - typedef typename Node::hook_type hook_type; \ - ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; \ - return (p); \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + NodePtr create_node() + { + NodePtr p = this->allocate_one(); + Deallocator node_deallocator(p, this->node_alloc()); + allocator_traits<NodeAlloc>::construct + (this->node_alloc(), container_detail::addressof(p->m_data)); + node_deallocator.release(); + typedef typename Node::hook_type hook_type; + ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; + return (p); + } + + template<BOOST_MOVE_CLASS1> + NodePtr create_node(BOOST_MOVE_UREF1) + { + NodePtr p = this->allocate_one(); + Deallocator node_deallocator(p, this->node_alloc()); + allocator_traits<NodeAlloc>::construct + (this->node_alloc(), container_detail::addressof(p->m_data) + , BOOST_MOVE_FWD1); + node_deallocator.release(); + typedef typename Node::hook_type hook_type; + ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; + return (p); + } + + template<BOOST_MOVE_CLASS2> + NodePtr create_node(BOOST_MOVE_UREF2) + { + NodePtr p = this->allocate_one(); + Deallocator node_deallocator(p, this->node_alloc()); + allocator_traits<NodeAlloc>::construct + (this->node_alloc(), container_detail::addressof(p->m_data) + , BOOST_MOVE_FWD2); + node_deallocator.release(); + typedef typename Node::hook_type hook_type; + ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; + return (p); + } + + template<BOOST_MOVE_CLASS3> + NodePtr create_node(BOOST_MOVE_UREF3) + { + NodePtr p = this->allocate_one(); + Deallocator node_deallocator(p, this->node_alloc()); + allocator_traits<NodeAlloc>::construct + (this->node_alloc(), container_detail::addressof(p->m_data) + , BOOST_MOVE_FWD3); + node_deallocator.release(); + typedef typename Node::hook_type hook_type; + ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; + return (p); + } + + template<BOOST_MOVE_CLASS4> + NodePtr create_node(BOOST_MOVE_UREF4) + { + NodePtr p = this->allocate_one(); + Deallocator node_deallocator(p, this->node_alloc()); + allocator_traits<NodeAlloc>::construct + (this->node_alloc(), container_detail::addressof(p->m_data) + , BOOST_MOVE_FWD4); + node_deallocator.release(); + typedef typename Node::hook_type hook_type; + ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; + return (p); + } + + template<BOOST_MOVE_CLASS5> + NodePtr create_node(BOOST_MOVE_UREF5) + { + NodePtr p = this->allocate_one(); + Deallocator node_deallocator(p, this->node_alloc()); + allocator_traits<NodeAlloc>::construct + (this->node_alloc(), container_detail::addressof(p->m_data) + , BOOST_MOVE_FWD5); + node_deallocator.release(); + typedef typename Node::hook_type hook_type; + ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; + return (p); + } + + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class It> NodePtr create_node_from_it(const It &it) @@ -261,7 +302,7 @@ struct node_alloc_holder Deallocator node_deallocator(NodePtr(), nalloc); container_detail::scoped_destructor<NodeAlloc> sdestructor(nalloc, 0); while(n--){ - p = container_detail::to_raw_pointer(iterator_to_pointer(itbeg)); + p = container_detail::iterator_to_raw_pointer(itbeg); node_deallocator.set(p); ++itbeg; //This can throw @@ -288,10 +329,10 @@ struct node_alloc_holder } } - void clear(allocator_v1) + void clear(version_1) { this->icont().clear_and_dispose(Destroyer(this->node_alloc())); } - void clear(allocator_v2) + void clear(version_2) { typename NodeAlloc::multiallocation_chain chain; allocator_destroyer_and_chain_builder<NodeAlloc> builder(this->node_alloc(), chain); @@ -301,10 +342,10 @@ struct node_alloc_holder this->node_alloc().deallocate_individual(chain); } - icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v1) + icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, version_1) { return this->icont().erase_and_dispose(first, last, Destroyer(this->node_alloc())); } - icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v2) + icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, version_2) { typedef typename NodeAlloc::multiallocation_chain multiallocation_chain; NodeAlloc & nalloc = this->node_alloc(); @@ -316,11 +357,11 @@ struct node_alloc_holder } template<class Key, class Comparator> - size_type erase_key(const Key& k, const Comparator &comp, allocator_v1) + size_type erase_key(const Key& k, const Comparator &comp, version_1) { return this->icont().erase_and_dispose(k, comp, Destroyer(this->node_alloc())); } template<class Key, class Comparator> - size_type erase_key(const Key& k, const Comparator &comp, allocator_v2) + size_type erase_key(const Key& k, const Comparator &comp, version_2) { allocator_multialloc_chain_node_deallocator<NodeAlloc> chain_holder(this->node_alloc()); return this->icont().erase_and_dispose(k, comp, chain_holder.get_chain_builder()); @@ -329,7 +370,7 @@ struct node_alloc_holder protected: struct cloner { - cloner(node_alloc_holder &holder) + explicit cloner(node_alloc_holder &holder) : m_holder(holder) {} @@ -339,6 +380,18 @@ struct node_alloc_holder node_alloc_holder &m_holder; }; + struct move_cloner + { + move_cloner(node_alloc_holder &holder) + : m_holder(holder) + {} + + NodePtr operator()(Node &other) + { return m_holder.create_node(::boost::move(other.get_data())); } + + node_alloc_holder &m_holder; + }; + struct members_holder : public NodeAlloc { diff --git a/boost/container/detail/node_pool.hpp b/boost/container/detail/node_pool.hpp index 60d826675a..00e35dfa8d 100644 --- a/boost/container/detail/node_pool.hpp +++ b/boost/container/detail/node_pool.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_NODE_POOL_HPP #define BOOST_CONTAINER_DETAIL_NODE_POOL_HPP -#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -22,11 +26,8 @@ #include <boost/container/detail/pool_common_alloc.hpp> #include <boost/container/detail/node_pool_impl.hpp> #include <boost/container/detail/mutex.hpp> -#include <boost/intrusive/slist.hpp> #include <boost/move/utility_core.hpp> #include <cstddef> -#include <functional> //std::unary_function -#include <algorithm> //std::swap #include <cassert> namespace boost { diff --git a/boost/container/detail/node_pool_impl.hpp b/boost/container/detail/node_pool_impl.hpp index 2450e5103e..4febf19e90 100644 --- a/boost/container/detail/node_pool_impl.hpp +++ b/boost/container/detail/node_pool_impl.hpp @@ -7,26 +7,31 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_DETAIL_NODE_POOL_IMPL_HPP #define BOOST_CONTAINER_DETAIL_NODE_POOL_IMPL_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> - #include <boost/container/container_fwd.hpp> -#include <boost/container/detail/utilities.hpp> -#include <boost/intrusive/pointer_traits.hpp> -#include <boost/intrusive/set.hpp> -#include <boost/intrusive/slist.hpp> -#include <boost/container/detail/type_traits.hpp> + #include <boost/container/detail/math_functions.hpp> #include <boost/container/detail/mpl.hpp> #include <boost/container/detail/pool_common.hpp> +#include <boost/container/detail/to_raw_pointer.hpp> +#include <boost/container/detail/type_traits.hpp> + +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/set.hpp> +#include <boost/intrusive/slist.hpp> + #include <boost/core/no_exceptions_support.hpp> #include <boost/assert.hpp> #include <cstddef> @@ -57,6 +62,10 @@ class private_node_pool_impl < node_t, bi::base_hook<slist_hook_t> , bi::linear<true> , bi::constant_time_size<false> >::type blockslist_t; + + static size_type get_rounded_size(size_type orig_size, size_type round_to) + { return ((orig_size-1)/round_to+1)*round_to; } + public: //!Segment manager typedef @@ -145,7 +154,7 @@ class private_node_pool_impl nodelist_iterator backup_list_last = backup_list.before_begin(); //Execute the algorithm and get an iterator to the last value - size_type blocksize = get_rounded_size + size_type blocksize = (get_rounded_size) (m_real_node_size*m_nodes_per_block, (size_type) alignment_of<node_t>::value); while(it != itend){ @@ -205,7 +214,7 @@ class private_node_pool_impl { //check for memory leaks BOOST_ASSERT(m_allocated==0); - size_type blocksize = get_rounded_size + size_type blocksize = (get_rounded_size) (m_real_node_size*m_nodes_per_block, (size_type)alignment_of<node_t>::value); //We iterate though the NodeBlock list to free the memory @@ -298,7 +307,7 @@ class private_node_pool_impl { BOOST_ASSERT(num_blocks > 0); size_type blocksize = - get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of<node_t>::value); + (get_rounded_size)(m_real_node_size*m_nodes_per_block, (size_type)alignment_of<node_t>::value); BOOST_TRY{ for(size_type i = 0; i != num_blocks; ++i){ diff --git a/boost/container/detail/pair.hpp b/boost/container/detail/pair.hpp index b7ad84c80e..6d31d3b796 100644 --- a/boost/container/detail/pair.hpp +++ b/boost/container/detail/pair.hpp @@ -13,7 +13,11 @@ #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_HPP #define BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -24,17 +28,11 @@ #include <boost/container/detail/type_traits.hpp> #include <boost/container/detail/mpl.hpp> #include <boost/container/detail/type_traits.hpp> +#include <boost/move/adl_move_swap.hpp> //swap -#include <utility> //std::pair -#include <algorithm> //std::swap - +#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair #include <boost/move/utility_core.hpp> - -#ifndef BOOST_CONTAINER_PERFECT_FORWARDING -#include <boost/container/detail/preprocessor.hpp> -#endif - namespace boost { namespace container { namespace container_detail { @@ -166,37 +164,7 @@ struct pair //template <class... Args1, class... Args2> // pair(piecewise_construct_t, tuple<Args1...> first_args, // tuple<Args2...> second_args); -/* - //Variadic versions - template<class U> - pair(BOOST_CONTAINER_PP_PARAM(U, u), typename container_detail::disable_if - < container_detail::is_pair< typename container_detail::remove_ref_const<U>::type >, pair_nat>::type* = 0) - : first(::boost::forward<U>(u)) - , second() - {} - - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING - template<class U, class V, class ...Args> - pair(U &&u, V &&v) - : first(::boost::forward<U>(u)) - , second(::boost::forward<V>(v), ::boost::forward<Args>(args)...) - {} - - #else - - #define BOOST_PP_LOCAL_MACRO(n) \ - template<class U, BOOST_PP_ENUM_PARAMS(n, class P)> \ - pair(BOOST_CONTAINER_PP_PARAM(U, u) \ - ,BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - : first(::boost::forward<U>(u)) \ - , second(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \ - {} \ - //! - #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - #endif -*/ //pair copy assignment pair& operator=(BOOST_COPY_ASSIGN_REF(pair) p) { @@ -272,9 +240,8 @@ struct pair //swap void swap(pair& p) { - using std::swap; - swap(this->first, p.first); - swap(this->second, p.second); + ::boost::adl_move_swap(this->first, p.first); + ::boost::adl_move_swap(this->second, p.second); } }; @@ -309,10 +276,7 @@ inline pair<T1, T2> make_pair(T1 x, T2 y) template <class T1, class T2> inline void swap(pair<T1, T2>& x, pair<T1, T2>& y) -{ - swap(x.first, y.first); - swap(x.second, y.second); -} +{ x.swap(y); } } //namespace container_detail { } //namespace container { diff --git a/boost/container/detail/placement_new.hpp b/boost/container/detail/placement_new.hpp index 2489d8a45e..c50981f685 100644 --- a/boost/container/detail/placement_new.hpp +++ b/boost/container/detail/placement_new.hpp @@ -1,6 +1,8 @@ +#ifndef BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP +#define BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP /////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -8,10 +10,11 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP -#define BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif -#if defined(_MSC_VER) +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/pool_common.hpp b/boost/container/detail/pool_common.hpp index 11fb6c2e50..61d0612ed1 100644 --- a/boost/container/detail/pool_common.hpp +++ b/boost/container/detail/pool_common.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_POOL_COMMON_HPP #define BOOST_CONTAINER_DETAIL_POOL_COMMON_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/pool_common_alloc.hpp b/boost/container/detail/pool_common_alloc.hpp index dfae7efd13..72e9c8d278 100644 --- a/boost/container/detail/pool_common_alloc.hpp +++ b/boost/container/detail/pool_common_alloc.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP #define BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/preprocessor.hpp b/boost/container/detail/preprocessor.hpp deleted file mode 100644 index 838eff2ca1..0000000000 --- a/boost/container/detail/preprocessor.hpp +++ /dev/null @@ -1,228 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2008-2013. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/container for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP -#define BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include <boost/container/detail/config_begin.hpp> -#include <boost/container/detail/workaround.hpp> -#include <boost/move/utility_core.hpp> - -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING -//#error "This file is not needed when perfect forwarding is available" -#endif //BOOST_CONTAINER_PERFECT_FORWARDING - -#include <boost/preprocessor/iteration/local.hpp> -#include <boost/preprocessor/punctuation/paren_if.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> -#include <boost/preprocessor/control/expr_if.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_trailing_params.hpp> -#include <boost/preprocessor/repetition/enum_trailing.hpp> -#include <boost/preprocessor/repetition/repeat.hpp> -#include <boost/preprocessor/arithmetic/sub.hpp> -#include <boost/preprocessor/arithmetic/add.hpp> -#include <boost/preprocessor/iteration/iterate.hpp> - -#define BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS 10 - -//Note: -//We define template parameters as const references to -//be able to bind temporaries. After that we will un-const them. -//This cast is ugly but it is necessary until "perfect forwarding" -//is achieved in C++0x. Meanwhile, if we want to be able to -//bind rvalues with non-const references, we have to be ugly -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \ - BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \ - //! -#else - #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \ - const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#define BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q(z, n, Data) \ -const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \ -//! - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - #define BOOST_CONTAINER_PP_PARAM(U, u) \ - U && u \ - //! -#else - #define BOOST_CONTAINER_PP_PARAM(U, u) \ - const U & u \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - - #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \ - BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \ - //! - -#else //BOOST_NO_CXX11_RVALUE_REFERENCES - - #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \ - BOOST_PP_CAT(m_p, n) (const_cast<BOOST_PP_CAT(P, n) &>(BOOST_PP_CAT(p, n))) \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - - #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - - namespace boost { - namespace container { - namespace container_detail { - template<class T> - struct ref_holder; - - template<class T> - struct ref_holder<T &> - { - explicit ref_holder(T &t) - : t_(t) - {} - T &t_; - T & get() { return t_; } - }; - - template<class T> - struct ref_holder<const T> - { - explicit ref_holder(const T &t) - : t_(t) - {} - const T &t_; - const T & get() { return t_; } - }; - - template<class T> - struct ref_holder<const T &&> - { - explicit ref_holder(const T &t) - : t_(t) - {} - const T &t_; - const T & get() { return t_; } - }; - - template<class T> - struct ref_holder - { - explicit ref_holder(T &&t) - : t_(t) - {} - T &t_; - T && get() { return ::boost::move(t_); } - }; - - template<class T> - struct ref_holder<T &&> - { - explicit ref_holder(T &&t) - : t_(t) - {} - T &t_; - T && get() { return ::boost::move(t_); } - }; - - } //namespace container_detail { - } //namespace container { - } //namespace boost { - - #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \ - ::boost::container::container_detail::ref_holder<BOOST_PP_CAT(P, n)> BOOST_PP_CAT(m_p, n); \ - //! - - #else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG - - #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \ - BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \ - //! - - #endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - -#else //BOOST_NO_CXX11_RVALUE_REFERENCES - - #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \ - BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - - #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \ - //! - -#else //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - - #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \ - ::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \ - //! - -#endif //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - -#define BOOST_CONTAINER_PP_PARAM_INC(z, n, data) \ - BOOST_PP_CAT(++this->m_p, n) \ -//! - -#define BOOST_CONTAINER_PP_IDENTITY(z, n, data) data - - -#define BOOST_CONTAINER_PP_PARAM_FORWARD(z, n, data) \ -::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \ -//! - -#define BOOST_CONTAINER_PP_DECLVAL(z, n, data) \ -::boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \ -//! - -#define BOOST_CONTAINER_PP_MEMBER_IT_FORWARD(z, n, data) \ -BOOST_PP_CAT(*this->m_p, n) \ -//! - -#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_VOID_DEFAULT(z, n, data) \ - BOOST_PP_CAT(class P, n) = void \ -//! - -#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT(z, n, default_type) \ - BOOST_PP_CAT(class P, n) = default_type \ -//! - -#define BOOST_CONTAINER_PP_STATIC_PARAM_REF_DECLARE(z, n, data) \ - static BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n); \ -//! - -#define BOOST_CONTAINER_PP_PARAM_PASS(z, n, data) \ - BOOST_PP_CAT(p, n) \ -//! - -#define BOOST_CONTAINER_PP_FWD_TYPE(z, n, data) \ - typename ::boost::move_detail::forward_type< BOOST_PP_CAT(P, n) >::type \ -//! - -#include <boost/container/detail/config_end.hpp> - -//#else - -//#ifdef BOOST_CONTAINER_PERFECT_FORWARDING -//#error "This file is not needed when perfect forwarding is available" -//#endif //BOOST_CONTAINER_PERFECT_FORWARDING - -#endif //#ifndef BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP diff --git a/boost/container/detail/singleton.hpp b/boost/container/detail/singleton.hpp index a2372c3a96..6fd6a54f30 100644 --- a/boost/container/detail/singleton.hpp +++ b/boost/container/detail/singleton.hpp @@ -22,7 +22,11 @@ #ifndef BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP #define BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/std_fwd.hpp b/boost/container/detail/std_fwd.hpp index a2edeccff1..a2931c134b 100644 --- a/boost/container/detail/std_fwd.hpp +++ b/boost/container/detail/std_fwd.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP #define BOOST_CONTAINER_DETAIL_STD_FWD_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -25,6 +29,12 @@ #pragma GCC diagnostic ignored "-Wc++11-extensions" #define BOOST_CONTAINER_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD #define BOOST_CONTAINER_STD_NS_END _LIBCPP_END_NAMESPACE_STD +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE_VERSION) //GCC >= 4.6 + #define BOOST_CONTAINER_STD_NS_BEG namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + #define BOOST_CONTAINER_STD_NS_END _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE) //GCC >= 4.2 + #define BOOST_CONTAINER_STD_NS_BEG _GLIBCXX_BEGIN_NAMESPACE(std) + #define BOOST_CONTAINER_STD_NS_END _GLIBCXX_END_NAMESPACE #else #define BOOST_CONTAINER_STD_NS_BEG namespace std{ #define BOOST_CONTAINER_STD_NS_END } @@ -49,6 +59,11 @@ struct forward_iterator_tag; struct bidirectional_iterator_tag; struct random_access_iterator_tag; +template<class Container> +class insert_iterator; + +struct allocator_arg_t; + BOOST_CONTAINER_STD_NS_END #ifdef BOOST_CONTAINER_CLANG_INLINE_STD_NS diff --git a/boost/container/detail/to_raw_pointer.hpp b/boost/container/detail/to_raw_pointer.hpp new file mode 100644 index 0000000000..0b4445a942 --- /dev/null +++ b/boost/container/detail/to_raw_pointer.hpp @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_DETAIL_TO_RAW_POINTER_HPP +#define BOOST_CONTAINER_DETAIL_TO_RAW_POINTER_HPP + +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include <boost/intrusive/detail/to_raw_pointer.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +using ::boost::intrusive::detail::to_raw_pointer; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_TO_RAW_POINTER_HPP diff --git a/boost/container/detail/transform_iterator.hpp b/boost/container/detail/transform_iterator.hpp index c4e746c389..ba64c7de79 100644 --- a/boost/container/detail/transform_iterator.hpp +++ b/boost/container/detail/transform_iterator.hpp @@ -14,15 +14,18 @@ #ifndef BOOST_CONTAINER_DETAIL_TRANSFORM_ITERATORS_HPP #define BOOST_CONTAINER_DETAIL_TRANSFORM_ITERATORS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> - #include <boost/container/detail/type_traits.hpp> -#include <iterator> +#include <boost/container/detail/iterator.hpp> namespace boost { namespace container { @@ -58,7 +61,7 @@ struct operator_arrow_proxy<T&> template <class Iterator, class UnaryFunction> class transform_iterator : public UnaryFunction - , public std::iterator + , public boost::container::iterator < typename Iterator::iterator_category , typename container_detail::remove_reference<typename UnaryFunction::result_type>::type , typename Iterator::difference_type @@ -156,10 +159,10 @@ class transform_iterator { return UnaryFunction::operator()(*m_it); } void advance(typename Iterator::difference_type n) - { std::advance(m_it, n); } + { boost::container::iterator_advance(m_it, n); } typename Iterator::difference_type distance_to(const transform_iterator &other)const - { return std::distance(other.m_it, m_it); } + { return boost::container::iterator_distance(other.m_it, m_it); } }; template <class Iterator, class UnaryFunc> diff --git a/boost/container/detail/tree.hpp b/boost/container/detail/tree.hpp index e59bca0887..0f90b5a4e2 100644 --- a/boost/container/detail/tree.hpp +++ b/boost/container/detail/tree.hpp @@ -11,62 +11,66 @@ #ifndef BOOST_CONTAINER_TREE_HPP #define BOOST_CONTAINER_TREE_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> +// container +#include <boost/container/allocator_traits.hpp> #include <boost/container/container_fwd.hpp> +#include <boost/container/options.hpp> -#include <boost/container/detail/utilities.hpp> +// container/detail +#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare +#include <boost/container/detail/compare_functors.hpp> +#include <boost/container/detail/destroyers.hpp> +#include <boost/container/detail/iterator.hpp> #include <boost/container/detail/iterators.hpp> -#include <boost/container/detail/algorithms.hpp> #include <boost/container/detail/node_alloc_holder.hpp> -#include <boost/container/detail/destroyers.hpp> #include <boost/container/detail/pair.hpp> #include <boost/container/detail/type_traits.hpp> -#include <boost/container/allocator_traits.hpp> -#include <boost/container/options.hpp> - -// +// intrusive #include <boost/intrusive/pointer_traits.hpp> #include <boost/intrusive/rbtree.hpp> #include <boost/intrusive/avltree.hpp> #include <boost/intrusive/splaytree.hpp> #include <boost/intrusive/sgtree.hpp> -// +// intrusive/detail +#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair +// move #include <boost/move/utility_core.hpp> -#include <boost/type_traits/has_trivial_destructor.hpp> -#include <boost/core/no_exceptions_support.hpp> -// -#ifndef BOOST_CONTAINER_PERFECT_FORWARDING -#include <boost/container/detail/preprocessor.hpp> +// move/detail +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include <boost/move/detail/fwd_macros.hpp> #endif - -#include <utility> //std::pair -#include <iterator> -#include <algorithm> +// other +#include <boost/core/no_exceptions_support.hpp> namespace boost { namespace container { namespace container_detail { -template<class Key, class Value, class KeyCompare, class KeyOfValue> +template<class Key, class T, class Compare, class KeyOfValue> struct tree_value_compare - : public KeyCompare + : public Compare { - typedef Value value_type; - typedef KeyCompare key_compare; + typedef T value_type; + typedef Compare key_compare; typedef KeyOfValue key_of_value; typedef Key key_type; explicit tree_value_compare(const key_compare &kcomp) - : KeyCompare(kcomp) + : Compare(kcomp) {} tree_value_compare() - : KeyCompare() + : Compare() {} const key_compare &key_comp() const @@ -75,25 +79,29 @@ struct tree_value_compare key_compare &key_comp() { return static_cast<key_compare &>(*this); } - template<class T> + template<class U> struct is_key { - static const bool value = is_same<const T, const key_type>::value; + static const bool value = is_same<const U, const key_type>::value; }; - template<class T> - typename enable_if_c<is_key<T>::value, const key_type &>::type - key_forward(const T &key) const + template<class U> + typename enable_if_c<is_key<U>::value, const key_type &>::type + key_forward(const U &key) const { return key; } - template<class T> - typename enable_if_c<!is_key<T>::value, const key_type &>::type - key_forward(const T &key) const + template<class U> + typename enable_if_c<!is_key<U>::value, const key_type &>::type + key_forward(const U &key) const { return KeyOfValue()(key); } template<class KeyType, class KeyType2> bool operator()(const KeyType &key1, const KeyType2 &key2) const { return key_compare::operator()(this->key_forward(key1), this->key_forward(key2)); } + + template<class KeyType, class KeyType2> + bool operator()(const KeyType &key1, const KeyType2 &key2) + { return key_compare::operator()(this->key_forward(key1), this->key_forward(key2)); } }; template<class VoidPointer, boost::container::tree_type_enum tree_type_value, bool OptimizeSize> @@ -183,17 +191,17 @@ struct tree_node internal_type m_data; - template<class A, class B> - void do_assign(const std::pair<const A, B> &p) + template<class T1, class T2> + void do_assign(const std::pair<const T1, T2> &p) { - const_cast<A&>(m_data.first) = p.first; + const_cast<T1&>(m_data.first) = p.first; m_data.second = p.second; } - template<class A, class B> - void do_assign(const pair<const A, B> &p) + template<class T1, class T2> + void do_assign(const pair<const T1, T2> &p) { - const_cast<A&>(m_data.first) = p.first; + const_cast<T1&>(m_data.first) = p.first; m_data.second = p.second; } @@ -201,17 +209,17 @@ struct tree_node void do_assign(const V &v) { m_data = v; } - template<class A, class B> - void do_move_assign(std::pair<const A, B> &p) + template<class T1, class T2> + void do_move_assign(std::pair<const T1, T2> &p) { - const_cast<A&>(m_data.first) = ::boost::move(p.first); + const_cast<T1&>(m_data.first) = ::boost::move(p.first); m_data.second = ::boost::move(p.second); } - template<class A, class B> - void do_move_assign(pair<const A, B> &p) + template<class T1, class T2> + void do_move_assign(pair<const T1, T2> &p) { - const_cast<A&>(m_data.first) = ::boost::move(p.first); + const_cast<T1&>(m_data.first) = ::boost::move(p.first); m_data.second = ::boost::move(p.second); } @@ -314,20 +322,21 @@ struct intrusive_tree_dispatch >::type type; }; -template<class A, class ValueCompare, boost::container::tree_type_enum tree_type_value, bool OptimizeSize> +template<class Allocator, class ValueCompare, boost::container::tree_type_enum tree_type_value, bool OptimizeSize> struct intrusive_tree_type { private: typedef typename boost::container:: - allocator_traits<A>::value_type value_type; + allocator_traits<Allocator>::value_type value_type; typedef typename boost::container:: - allocator_traits<A>::void_pointer void_pointer; + allocator_traits<Allocator>::void_pointer void_pointer; typedef typename boost::container:: - allocator_traits<A>::size_type size_type; + allocator_traits<Allocator>::size_type size_type; typedef typename container_detail::tree_node < value_type, void_pointer , tree_type_value, OptimizeSize> node_type; - typedef node_compare<ValueCompare, node_type> node_compare_type; + typedef value_to_node_compare + <node_type, ValueCompare> node_compare_type; //Deducing the hook type from node_type (e.g. node_type::hook_type) would //provoke an early instantiation of node_type that could ruin recursive //tree definitions, so retype the complete type to avoid any problem. @@ -391,10 +400,10 @@ class RecyclingCloner {} static void do_assign(node_ptr_type &p, const node_type &other, bool_<true>) - { p->do_assign(other.m_data); } + { p->do_move_assign(const_cast<node_type &>(other).m_data); } static void do_assign(node_ptr_type &p, const node_type &other, bool_<false>) - { p->do_move_assign(const_cast<node_type &>(other).m_data); } + { p->do_assign(other.m_data); } node_ptr_type operator()(const node_type &other) const { @@ -425,7 +434,7 @@ class RecyclingCloner }; template<class KeyValueCompare, class Node> -//where KeyValueCompare is tree_value_compare<Key, Value, KeyCompare, KeyOfValue> +//where KeyValueCompare is tree_value_compare<Key, T, Compare, KeyOfValue> struct key_node_compare : private KeyValueCompare { @@ -454,35 +463,35 @@ struct key_node_compare { return KeyValueCompare::operator()(this->key_forward(key1), this->key_forward(key2)); } }; -template <class Key, class Value, class KeyOfValue, - class KeyCompare, class A, +template <class Key, class T, class KeyOfValue, + class Compare, class Allocator, class Options = tree_assoc_defaults> class tree : protected container_detail::node_alloc_holder - < A + < Allocator , typename container_detail::intrusive_tree_type - < A, tree_value_compare<Key, Value, KeyCompare, KeyOfValue> //ValComp + < Allocator, tree_value_compare<Key, T, Compare, KeyOfValue> //ValComp , Options::tree_type, Options::optimize_size>::type > { typedef tree_value_compare - <Key, Value, KeyCompare, KeyOfValue> ValComp; + <Key, T, Compare, KeyOfValue> ValComp; typedef typename container_detail::intrusive_tree_type - < A, ValComp, Options::tree_type + < Allocator, ValComp, Options::tree_type , Options::optimize_size>::type Icont; typedef container_detail::node_alloc_holder - <A, Icont> AllocHolder; + <Allocator, Icont> AllocHolder; typedef typename AllocHolder::NodePtr NodePtr; - typedef tree < Key, Value, KeyOfValue - , KeyCompare, A, Options> ThisType; + typedef tree < Key, T, KeyOfValue + , Compare, Allocator, Options> ThisType; typedef typename AllocHolder::NodeAlloc NodeAlloc; + typedef boost::container:: + allocator_traits<NodeAlloc> allocator_traits_type; typedef typename AllocHolder::ValAlloc ValAlloc; typedef typename AllocHolder::Node Node; typedef typename Icont::iterator iiterator; typedef typename Icont::const_iterator iconst_iterator; typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer; - typedef typename AllocHolder::allocator_v1 allocator_v1; - typedef typename AllocHolder::allocator_v2 allocator_v2; typedef typename AllocHolder::alloc_version alloc_version; typedef intrusive_tree_proxy<Options::tree_type> intrusive_tree_proxy_t; @@ -491,22 +500,22 @@ class tree public: typedef Key key_type; - typedef Value value_type; - typedef A allocator_type; - typedef KeyCompare key_compare; + typedef T value_type; + typedef Allocator allocator_type; + typedef Compare key_compare; typedef ValComp value_compare; typedef typename boost::container:: - allocator_traits<A>::pointer pointer; + allocator_traits<Allocator>::pointer pointer; typedef typename boost::container:: - allocator_traits<A>::const_pointer const_pointer; + allocator_traits<Allocator>::const_pointer const_pointer; typedef typename boost::container:: - allocator_traits<A>::reference reference; + allocator_traits<Allocator>::reference reference; typedef typename boost::container:: - allocator_traits<A>::const_reference const_reference; + allocator_traits<Allocator>::const_reference const_reference; typedef typename boost::container:: - allocator_traits<A>::size_type size_type; + allocator_traits<Allocator>::size_type size_type; typedef typename boost::container:: - allocator_traits<A>::difference_type difference_type; + allocator_traits<Allocator>::difference_type difference_type; typedef difference_type tree_difference_type; typedef pointer tree_pointer; typedef const_pointer tree_const_pointer; @@ -519,17 +528,17 @@ class tree typedef key_node_compare<value_compare, Node> KeyNodeCompare; public: - typedef container_detail::iterator<iiterator, false> iterator; - typedef container_detail::iterator<iiterator, true > const_iterator; - typedef container_detail::reverse_iterator<iterator> reverse_iterator; - typedef container_detail::reverse_iterator<const_iterator> const_reverse_iterator; + typedef container_detail::iterator_from_iiterator<iiterator, false> iterator; + typedef container_detail::iterator_from_iiterator<iiterator, true > const_iterator; + typedef boost::container::reverse_iterator<iterator> reverse_iterator; + typedef boost::container::reverse_iterator<const_iterator> const_reverse_iterator; tree() - : AllocHolder(ValComp(key_compare())) + : AllocHolder() {} explicit tree(const key_compare& comp, const allocator_type& a = allocator_type()) - : AllocHolder(a, ValComp(comp)) + : AllocHolder(ValComp(comp), a) {} explicit tree(const allocator_type& a) @@ -542,11 +551,11 @@ class tree #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::enable_if_c < container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, allocator_v1>::value + || container_detail::is_same<alloc_version, version_1>::value >::type * = 0 #endif ) - : AllocHolder(a, value_compare(comp)) + : AllocHolder(value_compare(comp), a) { //Use cend() as hint to achieve linear time for //ordered ranges as required by the standard @@ -570,11 +579,11 @@ class tree #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::enable_if_c < !(container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, allocator_v1>::value) + || container_detail::is_same<alloc_version, version_1>::value) >::type * = 0 #endif ) - : AllocHolder(a, value_compare(comp)) + : AllocHolder(value_compare(comp), a) { if(unique_insertion){ //Use cend() as hint to achieve linear time for @@ -588,7 +597,7 @@ class tree else{ //Optimized allocation and construction this->allocate_many_and_construct - ( first, std::distance(first, last) + ( first, boost::container::iterator_distance(first, last) , insert_equal_end_hint_functor<Node, Icont>(this->icont())); } } @@ -599,11 +608,11 @@ class tree #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::enable_if_c < container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, allocator_v1>::value + || container_detail::is_same<alloc_version, version_1>::value >::type * = 0 #endif ) - : AllocHolder(a, value_compare(comp)) + : AllocHolder(value_compare(comp), a) { for ( ; first != last; ++first){ this->push_back_impl(*first); @@ -616,45 +625,45 @@ class tree #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename container_detail::enable_if_c < !(container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, allocator_v1>::value) + || container_detail::is_same<alloc_version, version_1>::value) >::type * = 0 #endif ) - : AllocHolder(a, value_compare(comp)) + : AllocHolder(value_compare(comp), a) { //Optimized allocation and construction this->allocate_many_and_construct - ( first, std::distance(first, last) + ( first, boost::container::iterator_distance(first, last) , container_detail::push_back_functor<Node, Icont>(this->icont())); } tree(const tree& x) - : AllocHolder(x, x.value_comp()) + : AllocHolder(x.value_comp(), x) { this->icont().clone_from (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); } tree(BOOST_RV_REF(tree) x) - : AllocHolder(::boost::move(static_cast<AllocHolder&>(x)), x.value_comp()) + : AllocHolder(BOOST_MOVE_BASE(AllocHolder, x), x.value_comp()) {} tree(const tree& x, const allocator_type &a) - : AllocHolder(a, x.value_comp()) + : AllocHolder(x.value_comp(), a) { this->icont().clone_from (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); } tree(BOOST_RV_REF(tree) x, const allocator_type &a) - : AllocHolder(a, x.value_comp()) + : AllocHolder(x.value_comp(), a) { if(this->node_alloc() == x.node_alloc()){ this->icont().swap(x.icont()); } else{ this->icont().clone_from - (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); + (x.icont(), typename AllocHolder::move_cloner(*this), Destroyer(this->node_alloc())); } } @@ -693,6 +702,8 @@ class tree } tree& operator=(BOOST_RV_REF(tree) x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_move_assignable<Compare>::value ) { BOOST_ASSERT(this != &x); NodeAlloc &this_alloc = this->node_alloc(); @@ -735,10 +746,10 @@ class tree public: // accessors: value_compare value_comp() const - { return this->icont().value_comp().value_comp(); } + { return this->icont().value_comp().predicate(); } key_compare key_comp() const - { return this->icont().value_comp().value_comp().key_comp(); } + { return this->icont().value_comp().predicate().key_comp(); } allocator_type get_allocator() const { return allocator_type(this->node_alloc()); } @@ -817,6 +828,8 @@ class tree { return AllocHolder::max_size(); } void swap(ThisType& x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_swappable<Compare>::value ) { AllocHolder::swap(x); } public: @@ -851,9 +864,9 @@ class tree template<class MovableConvertible> iterator insert_unique_commit - (BOOST_FWD_REF(MovableConvertible) mv, insert_commit_data &data) + (BOOST_FWD_REF(MovableConvertible) v, insert_commit_data &data) { - NodePtr tmp = AllocHolder::create_node(boost::forward<MovableConvertible>(mv)); + NodePtr tmp = AllocHolder::create_node(boost::forward<MovableConvertible>(v)); scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc()); iterator ret(this->icont().insert_unique_commit(*tmp, data)); destroy_deallocator.release(); @@ -872,13 +885,13 @@ class tree } template<class MovableConvertible> - std::pair<iterator,bool> insert_unique(BOOST_FWD_REF(MovableConvertible) mv) + std::pair<iterator,bool> insert_unique(BOOST_FWD_REF(MovableConvertible) v) { insert_commit_data data; std::pair<iterator,bool> ret = - this->insert_unique_check(KeyOfValue()(mv), data); + this->insert_unique_check(KeyOfValue()(v), data); if(ret.second){ - ret.first = this->insert_unique_commit(boost::forward<MovableConvertible>(mv), data); + ret.first = this->insert_unique_commit(boost::forward<MovableConvertible>(v), data); } return ret; } @@ -886,9 +899,9 @@ class tree private: template<class MovableConvertible> - void push_back_impl(BOOST_FWD_REF(MovableConvertible) mv) + void push_back_impl(BOOST_FWD_REF(MovableConvertible) v) { - NodePtr tmp(AllocHolder::create_node(boost::forward<MovableConvertible>(mv))); + NodePtr tmp(AllocHolder::create_node(boost::forward<MovableConvertible>(v))); //push_back has no-throw guarantee so avoid any deallocator/destroyer this->icont().push_back(*tmp); } @@ -925,18 +938,18 @@ class tree public: - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template <class... Args> - std::pair<iterator, bool> emplace_unique(Args&&... args) + std::pair<iterator, bool> emplace_unique(BOOST_FWD_REF(Args)... args) { return this->emplace_unique_impl(AllocHolder::create_node(boost::forward<Args>(args)...)); } template <class... Args> - iterator emplace_hint_unique(const_iterator hint, Args&&... args) + iterator emplace_hint_unique(const_iterator hint, BOOST_FWD_REF(Args)... args) { return this->emplace_unique_hint_impl(hint, AllocHolder::create_node(boost::forward<Args>(args)...)); } template <class... Args> - iterator emplace_equal(Args&&... args) + iterator emplace_equal(BOOST_FWD_REF(Args)... args) { NodePtr tmp(AllocHolder::create_node(boost::forward<Args>(args)...)); scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc()); @@ -946,7 +959,7 @@ class tree } template <class... Args> - iterator emplace_hint_equal(const_iterator hint, Args&&... args) + iterator emplace_hint_equal(const_iterator hint, BOOST_FWD_REF(Args)... args) { NodePtr tmp(AllocHolder::create_node(boost::forward<Args>(args)...)); scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc()); @@ -955,49 +968,41 @@ class tree return ret; } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - #define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - std::pair<iterator, bool> emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - return this->emplace_unique_impl \ - (AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_hint_unique(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - return this->emplace_unique_hint_impl \ - (hint, AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - NodePtr tmp(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ - scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc()); \ - iterator ret(this->icont().insert_equal(this->icont().end(), *tmp)); \ - destroy_deallocator.release(); \ - return ret; \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_hint_equal(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - NodePtr tmp(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ - scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc()); \ - iterator ret(this->icont().insert_equal(hint.get(), *tmp)); \ - destroy_deallocator.release(); \ - return ret; \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + #define BOOST_CONTAINER_TREE_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + std::pair<iterator, bool> emplace_unique(BOOST_MOVE_UREF##N)\ + { return this->emplace_unique_impl(AllocHolder::create_node(BOOST_MOVE_FWD##N)); }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint_unique(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + { return this->emplace_unique_hint_impl(hint, AllocHolder::create_node(BOOST_MOVE_FWD##N)); }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_equal(BOOST_MOVE_UREF##N)\ + {\ + NodePtr tmp(AllocHolder::create_node(BOOST_MOVE_FWD##N));\ + scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc());\ + iterator ret(this->icont().insert_equal(this->icont().end(), *tmp));\ + destroy_deallocator.release();\ + return ret;\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint_equal(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + NodePtr tmp(AllocHolder::create_node(BOOST_MOVE_FWD##N));\ + scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc());\ + iterator ret(this->icont().insert_equal(hint.get(), *tmp));\ + destroy_deallocator.release();\ + return ret;\ + }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_TREE_EMPLACE_CODE) + #undef BOOST_CONTAINER_TREE_EMPLACE_CODE + + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) iterator insert_unique(const_iterator hint, const value_type& v) { @@ -1010,14 +1015,14 @@ class tree } template<class MovableConvertible> - iterator insert_unique(const_iterator hint, BOOST_FWD_REF(MovableConvertible) mv) + iterator insert_unique(const_iterator hint, BOOST_FWD_REF(MovableConvertible) v) { insert_commit_data data; std::pair<iterator,bool> ret = - this->insert_unique_check(hint, KeyOfValue()(mv), data); + this->insert_unique_check(hint, KeyOfValue()(v), data); if(!ret.second) return ret.first; - return this->insert_unique_commit(boost::forward<MovableConvertible>(mv), data); + return this->insert_unique_commit(boost::forward<MovableConvertible>(v), data); } template <class InputIterator> @@ -1037,9 +1042,9 @@ class tree } template<class MovableConvertible> - iterator insert_equal(BOOST_FWD_REF(MovableConvertible) mv) + iterator insert_equal(BOOST_FWD_REF(MovableConvertible) v) { - NodePtr tmp(AllocHolder::create_node(boost::forward<MovableConvertible>(mv))); + NodePtr tmp(AllocHolder::create_node(boost::forward<MovableConvertible>(v))); scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc()); iterator ret(this->icont().insert_equal(this->icont().end(), *tmp)); destroy_deallocator.release(); @@ -1056,9 +1061,9 @@ class tree } template<class MovableConvertible> - iterator insert_equal(const_iterator hint, BOOST_FWD_REF(MovableConvertible) mv) + iterator insert_equal(const_iterator hint, BOOST_FWD_REF(MovableConvertible) v) { - NodePtr tmp(AllocHolder::create_node(boost::forward<MovableConvertible>(mv))); + NodePtr tmp(AllocHolder::create_node(boost::forward<MovableConvertible>(v))); scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(tmp, this->node_alloc()); iterator ret(this->icont().insert_equal(hint.get(), *tmp)); destroy_deallocator.release(); @@ -1141,10 +1146,10 @@ class tree { intrusive_tree_proxy_t::rebalance(this->icont()); } friend bool operator==(const tree& x, const tree& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } + { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } friend bool operator<(const tree& x, const tree& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + { return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } friend bool operator!=(const tree& x, const tree& y) { return !(x == y); } @@ -1164,17 +1169,25 @@ class tree } //namespace container_detail { } //namespace container { -/* + +template <class T> +struct has_trivial_destructor_after_move; + //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations -template <class K, class V, class KOV, -class C, class A> +template <class Key, class T, class KeyOfValue, class Compare, class Allocator, class Options> struct has_trivial_destructor_after_move - <boost::container::container_detail::tree<K, V, KOV, C, A> > + < + ::boost::container::container_detail::tree + <Key, T, KeyOfValue, Compare, Allocator, Options> + > { - static const bool value = has_trivial_destructor_after_move<A>::value && has_trivial_destructor_after_move<C>::value; + typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value && + ::boost::has_trivial_destructor_after_move<pointer>::value && + ::boost::has_trivial_destructor_after_move<Compare>::value; }; -*/ + } //namespace boost { #include <boost/container/detail/config_end.hpp> diff --git a/boost/container/detail/type_traits.hpp b/boost/container/detail/type_traits.hpp index 9ff361454a..1ae2426863 100644 --- a/boost/container/detail/type_traits.hpp +++ b/boost/container/detail/type_traits.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // (C) Copyright John Maddock 2000. -// (C) Copyright Ion Gaztanaga 2005-2013. +// (C) Copyright Ion Gaztanaga 2005-2015. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -8,230 +8,60 @@ // // See http://www.boost.org/libs/container for documentation. // -// The alignment_of implementation comes from John Maddock's boost::alignment_of code +// The alignment and Type traits implementation comes from +// John Maddock's TypeTraits library. // +// Some other tricks come from Howard Hinnant's papers and StackOverflow replies ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP #define BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif -#include <boost/container/detail/config_begin.hpp> -#include <boost/container/detail/workaround.hpp> +#include <boost/move/detail/type_traits.hpp> namespace boost { namespace container { namespace container_detail { -struct nat{}; - -template <typename U> -struct LowPriorityConversion -{ - // Convertible from T with user-defined-conversion rank. - LowPriorityConversion(const U&) { } -}; - -//boost::alignment_of yields to 10K lines of preprocessed code, so we -//need an alternative -template <typename T> struct alignment_of; - -template <typename T> -struct alignment_of_hack -{ - char c; - T t; - alignment_of_hack(); -}; - -template <unsigned A, unsigned S> -struct alignment_logic -{ - enum{ value = A < S ? A : S }; -}; - -template< typename T > -struct alignment_of -{ - enum{ value = alignment_logic - < sizeof(alignment_of_hack<T>) - sizeof(T) - , sizeof(T)>::value }; -}; - -//This is not standard, but should work with all compilers -union max_align -{ - char char_; - short short_; - int int_; - long long_; - #ifdef BOOST_HAS_LONG_LONG - long long long_long_; - #endif - float float_; - double double_; - long double long_double_; - void * void_ptr_; -}; - -template<class T> -struct remove_reference -{ - typedef T type; -}; - -template<class T> -struct remove_reference<T&> -{ - typedef T type; -}; - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -template<class T> -struct remove_reference<T&&> -{ - typedef T type; -}; - -#else - -} // namespace container_detail { -} //namespace container { - -template<class T> -class rv; - -namespace container { -namespace container_detail { - -template<class T> -struct remove_reference< ::boost::rv<T> > -{ - typedef T type; -}; - -#endif - -template<class T> -struct is_reference -{ - enum { value = false }; -}; - -template<class T> -struct is_reference<T&> -{ - enum { value = true }; -}; - -template<class T> -struct is_pointer -{ - enum { value = false }; -}; - -template<class T> -struct is_pointer<T*> -{ - enum { value = true }; -}; - -template <typename T> -struct add_reference -{ - typedef T& type; -}; - -template<class T> -struct add_reference<T&> -{ - typedef T& type; -}; - -template<> -struct add_reference<void> -{ - typedef nat &type; -}; - -template<> -struct add_reference<const void> -{ - typedef const nat &type; -}; - -template <class T> -struct add_const_reference -{ typedef const T &type; }; - -template <class T> -struct add_const_reference<T&> -{ typedef T& type; }; - -template <class T> -struct add_const -{ typedef const T type; }; - -template <typename T, typename U> -struct is_same -{ - typedef char yes_type; - struct no_type - { - char padding[8]; - }; - - template <typename V> - static yes_type is_same_tester(V*, V*); - static no_type is_same_tester(...); - - static T *t; - static U *u; - - static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u)); -}; - -template<class T> -struct remove_const -{ - typedef T type; -}; - -template<class T> -struct remove_const< const T> -{ - typedef T type; -}; - -template<class T> -struct remove_ref_const -{ - typedef typename remove_const< typename remove_reference<T>::type >::type type; -}; - -template <class T> -struct make_unsigned -{ - typedef T type; -}; - -template <> struct make_unsigned<bool> {}; -template <> struct make_unsigned<signed char> {typedef unsigned char type;}; -template <> struct make_unsigned<signed short> {typedef unsigned short type;}; -template <> struct make_unsigned<signed int> {typedef unsigned int type;}; -template <> struct make_unsigned<signed long> {typedef unsigned long type;}; -#ifdef BOOST_HAS_LONG_LONG -template <> struct make_unsigned<signed long long> {typedef unsigned long long type;}; -#endif - -} // namespace container_detail +using ::boost::move_detail::is_same; +using ::boost::move_detail::is_pointer; +using ::boost::move_detail::add_reference; +using ::boost::move_detail::add_const; +using ::boost::move_detail::add_const_reference; +using ::boost::move_detail::remove_const; +using ::boost::move_detail::remove_reference; +using ::boost::move_detail::make_unsigned; +using ::boost::move_detail::is_floating_point; +using ::boost::move_detail::is_integral; +using ::boost::move_detail::is_enum; +using ::boost::move_detail::is_pod; +using ::boost::move_detail::is_empty; +using ::boost::move_detail::is_trivially_destructible; +using ::boost::move_detail::is_trivially_default_constructible; +using ::boost::move_detail::is_trivially_copy_constructible; +using ::boost::move_detail::is_trivially_move_constructible; +using ::boost::move_detail::is_trivially_copy_assignable; +using ::boost::move_detail::is_trivially_move_assignable; +using ::boost::move_detail::is_nothrow_default_constructible; +using ::boost::move_detail::is_nothrow_copy_constructible; +using ::boost::move_detail::is_nothrow_move_constructible; +using ::boost::move_detail::is_nothrow_copy_assignable; +using ::boost::move_detail::is_nothrow_move_assignable; +using ::boost::move_detail::is_nothrow_swappable; +using ::boost::move_detail::alignment_of; +using ::boost::move_detail::aligned_storage; +using ::boost::move_detail::nat; +using ::boost::move_detail::max_align_t; + +} //namespace container_detail { } //namespace container { } //namespace boost { -#include <boost/container/detail/config_end.hpp> - #endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP diff --git a/boost/container/detail/value_init.hpp b/boost/container/detail/value_init.hpp index 68f9678358..eb4c976d92 100644 --- a/boost/container/detail/value_init.hpp +++ b/boost/container/detail/value_init.hpp @@ -13,7 +13,11 @@ #ifndef BOOST_CONTAINER_DETAIL_VALUE_INIT_HPP #define BOOST_CONTAINER_DETAIL_VALUE_INIT_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/variadic_templates_tools.hpp b/boost/container/detail/variadic_templates_tools.hpp index b07fe3050e..ec8b8ceef0 100644 --- a/boost/container/detail/variadic_templates_tools.hpp +++ b/boost/container/detail/variadic_templates_tools.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP #define BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/version_type.hpp b/boost/container/detail/version_type.hpp index 2eabc62483..a20b3eedaa 100644 --- a/boost/container/detail/version_type.hpp +++ b/boost/container/detail/version_type.hpp @@ -16,7 +16,11 @@ #ifndef BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP #define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -30,8 +34,6 @@ namespace boost{ namespace container { namespace container_detail { -//using namespace boost; - template <class T, unsigned V> struct version_type : public container_detail::integral_constant<unsigned, V> @@ -95,6 +97,11 @@ struct is_version }; } //namespace container_detail { + +typedef container_detail::integral_constant<unsigned, 0> version_0; +typedef container_detail::integral_constant<unsigned, 1> version_1; +typedef container_detail::integral_constant<unsigned, 2> version_2; + } //namespace container { } //namespace boost{ diff --git a/boost/container/detail/workaround.hpp b/boost/container/detail/workaround.hpp index 55ebe339ce..026e65d6bb 100644 --- a/boost/container/detail/workaround.hpp +++ b/boost/container/detail/workaround.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP #define BOOST_CONTAINER_DETAIL_WORKAROUND_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -22,18 +26,6 @@ #define BOOST_CONTAINER_PERFECT_FORWARDING #endif -#if defined(BOOST_NO_CXX11_NOEXCEPT) - #if defined(BOOST_MSVC) - #define BOOST_CONTAINER_NOEXCEPT throw() - #else - #define BOOST_CONTAINER_NOEXCEPT - #endif - #define BOOST_CONTAINER_NOEXCEPT_IF(x) -#else - #define BOOST_CONTAINER_NOEXCEPT noexcept - #define BOOST_CONTAINER_NOEXCEPT_IF(x) noexcept(x) -#endif - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(__GXX_EXPERIMENTAL_CXX0X__)\ && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40700) #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST |