diff --git a/doc/container.qbk b/doc/container.qbk index 3c0ad5a..d18d000 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1244,6 +1244,7 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes_boost_1_70_00 Boost 1.70 Release] * Removed support for already deprecated GCC < 4.3 and MSVC < 9.0 (Visual 2008) compilers. +* Default allocator parameter changed form `new_alloator` to `void` to reduce symbol lenghts. * Fixed bugs: * [@https://github.com/boostorg/container/pull/96 GitHub #96: ['"Workaround: Intel compilers do not offer CTAD yet"]]. * [@https://github.com/boostorg/container/issues/97 GitHub #97: ['"buffer overflow in boost::container::flat_map on FreeBSD"]]. diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp index bb5a2d3..8cfb037 100644 --- a/include/boost/container/allocator_traits.hpp +++ b/include/boost/container/allocator_traits.hpp @@ -77,7 +77,7 @@ namespace container { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -template +template class small_vector_allocator; namespace allocator_traits_detail { @@ -100,7 +100,7 @@ struct is_std_allocator< std::allocator > { static const bool value = true; }; template -struct is_std_allocator< small_vector_allocator< std::allocator > > +struct is_std_allocator< small_vector_allocator > > { static const bool value = true; }; template @@ -469,6 +469,22 @@ struct allocator_traits #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) }; +#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + +template +struct real_allocator +{ + typedef AllocatorOrVoid type; +}; + +template +struct real_allocator +{ + typedef new_allocator type; +}; + +#endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + } //namespace container { } //namespace boost { diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp index ddc9a4d..b7591cd 100644 --- a/include/boost/container/container_fwd.hpp +++ b/include/boost/container/container_fwd.hpp @@ -90,6 +90,9 @@ namespace container { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED +template +struct pair; + template class new_allocator; @@ -99,92 +102,83 @@ template > + ,class Allocator = void > class stable_vector; template class static_vector; template < class T, std::size_t N - , class Allocator= new_allocator > + , class Allocator = void > class small_vector; template > + ,class Allocator = void > class deque; template > + ,class Allocator = void > class list; template > + ,class Allocator = void > class slist; template - ,class Allocator = new_allocator + ,class Allocator = void ,class Options = void> class set; template - ,class Allocator = new_allocator + ,class Allocator = void ,class Options = void > class multiset; template - ,class Allocator = new_allocator > + ,class Allocator = void ,class Options = void > class map; template - ,class Allocator = new_allocator > + ,class Allocator = void ,class Options = void > class multimap; template - ,class Allocator = new_allocator > + ,class Allocator = void > class flat_set; template - ,class Allocator = new_allocator > + ,class Allocator = void > class flat_multiset; template - ,class Allocator = new_allocator > > + ,class Allocator = void > class flat_map; template - ,class Allocator = new_allocator > > + ,class Allocator = void > class flat_multimap; template - ,class Allocator = new_allocator > + ,class Allocator = void > class basic_string; -typedef basic_string - - ,new_allocator > -string; - -typedef basic_string - - ,new_allocator > -wstring; +typedef basic_string string; +typedef basic_string wstring; static const std::size_t ADP_nodes_per_block = 256u; static const std::size_t ADP_max_free_blocks = 2u; diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index 35cea2f..7de127a 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -483,12 +483,13 @@ template > #else template #endif -class deque : protected deque_base +class deque : protected deque_base::type> { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: - typedef deque_base Base; + typedef deque_base::type> Base; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + typedef typename real_allocator::type ValAllocator; public: @@ -499,13 +500,13 @@ class deque : protected deque_base ////////////////////////////////////////////// typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; + typedef ValAllocator allocator_type; + typedef typename ::boost::container::allocator_traits::pointer pointer; + typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; + typedef typename ::boost::container::allocator_traits::reference reference; + typedef typename ::boost::container::allocator_traits::const_reference const_reference; + typedef typename ::boost::container::allocator_traits::size_type size_type; + typedef typename ::boost::container::allocator_traits::difference_type difference_type; typedef BOOST_CONTAINER_IMPDEF(allocator_type) stored_allocator_type; typedef BOOST_CONTAINER_IMPDEF(typename Base::iterator) iterator; typedef BOOST_CONTAINER_IMPDEF(typename Base::const_iterator) const_iterator; @@ -519,7 +520,7 @@ class deque : protected deque_base typedef typename Base::ptr_alloc_ptr index_pointer; static size_type s_buffer_size() { return Base::s_buffer_size(); } - typedef allocator_traits allocator_traits_type; + typedef allocator_traits allocator_traits_type; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -535,7 +536,7 @@ class deque : protected deque_base //! Throws: If allocator_type's default constructor throws. //! //! Complexity: Constant. - deque() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) + deque() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) : Base() {} @@ -558,7 +559,7 @@ class deque : protected deque_base explicit deque(size_type n) : Base(n, allocator_type()) { - dtl::insert_value_initialized_n_proxy proxy; + dtl::insert_value_initialized_n_proxy proxy; proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n); //deque_base will deallocate in case of exception... } @@ -575,7 +576,7 @@ class deque : protected deque_base deque(size_type n, default_init_t) : Base(n, allocator_type()) { - dtl::insert_default_initialized_n_proxy proxy; + dtl::insert_default_initialized_n_proxy proxy; proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n); //deque_base will deallocate in case of exception... } @@ -590,7 +591,7 @@ class deque : protected deque_base explicit deque(size_type n, const allocator_type &a) : Base(n, a) { - dtl::insert_value_initialized_n_proxy proxy; + dtl::insert_value_initialized_n_proxy proxy; proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n); //deque_base will deallocate in case of exception... } @@ -607,7 +608,7 @@ class deque : protected deque_base deque(size_type n, default_init_t, const allocator_type &a) : Base(n, a) { - dtl::insert_default_initialized_n_proxy proxy; + dtl::insert_default_initialized_n_proxy proxy; proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n); //deque_base will deallocate in case of exception... } @@ -1096,7 +1097,7 @@ class deque : protected deque_base this->priv_erase_last_n(len - new_size); else{ const size_type n = new_size - this->size(); - dtl::insert_value_initialized_n_proxy proxy; + dtl::insert_value_initialized_n_proxy proxy; priv_insert_back_aux_impl(n, proxy); } } @@ -1116,7 +1117,7 @@ class deque : protected deque_base this->priv_erase_last_n(len - new_size); else{ const size_type n = new_size - this->size(); - dtl::insert_default_initialized_n_proxy proxy; + dtl::insert_default_initialized_n_proxy proxy; priv_insert_back_aux_impl(n, proxy); } } @@ -1366,7 +1367,7 @@ class deque : protected deque_base return r; } else{ - typedef dtl::insert_nonmovable_emplace_proxy type; + typedef dtl::insert_nonmovable_emplace_proxy type; return *this->priv_insert_front_aux_impl(1, type(boost::forward(args)...)); } } @@ -1392,7 +1393,7 @@ class deque : protected deque_base return r; } else{ - typedef dtl::insert_nonmovable_emplace_proxy type; + typedef dtl::insert_nonmovable_emplace_proxy type; return *this->priv_insert_back_aux_impl(1, type(boost::forward(args)...)); } } @@ -1419,7 +1420,7 @@ class deque : protected deque_base return (this->end()-1); } else{ - typedef dtl::insert_emplace_proxy type; + typedef dtl::insert_emplace_proxy type; return this->priv_insert_aux_impl(p, 1, type(boost::forward(args)...)); } } @@ -1439,7 +1440,7 @@ class deque : protected deque_base }\ else{\ typedef dtl::insert_nonmovable_emplace_proxy##N\ - type;\ + type;\ return *priv_insert_front_aux_impl(1, type(BOOST_MOVE_FWD##N));\ }\ }\ @@ -1456,7 +1457,7 @@ class deque : protected deque_base }\ else{\ typedef dtl::insert_nonmovable_emplace_proxy##N\ - type;\ + type;\ return *priv_insert_back_aux_impl(1, type(BOOST_MOVE_FWD##N));\ }\ }\ @@ -1475,7 +1476,7 @@ class deque : protected deque_base }\ else{\ typedef dtl::insert_emplace_proxy_arg##N\ - type;\ + type;\ return this->priv_insert_aux_impl(p, 1, type(BOOST_MOVE_FWD##N));\ }\ } @@ -1633,7 +1634,7 @@ class deque : protected deque_base ) { BOOST_ASSERT(this->priv_in_range_or_end(p)); - dtl::insert_range_proxy proxy(first); + dtl::insert_range_proxy proxy(first); return priv_insert_aux_impl(p, boost::container::iterator_distance(first, last), proxy); } #endif @@ -1874,7 +1875,7 @@ class deque : protected deque_base else { return priv_insert_aux_impl ( p, (size_type)1 - , dtl::get_insert_value_proxy(::boost::forward(x))); + , dtl::get_insert_value_proxy(::boost::forward(x))); } } @@ -1889,7 +1890,7 @@ class deque : protected deque_base else{ priv_insert_aux_impl ( this->cbegin(), (size_type)1 - , dtl::get_insert_value_proxy(::boost::forward(x))); + , dtl::get_insert_value_proxy(::boost::forward(x))); } } @@ -1904,7 +1905,7 @@ class deque : protected deque_base else{ priv_insert_aux_impl ( this->cend(), (size_type)1 - , dtl::get_insert_value_proxy(::boost::forward(x))); + , dtl::get_insert_value_proxy(::boost::forward(x))); } } diff --git a/include/boost/container/detail/compare_functors.hpp b/include/boost/container/detail/compare_functors.hpp index 2c8dc6a..21f222b 100644 --- a/include/boost/container/detail/compare_functors.hpp +++ b/include/boost/container/detail/compare_functors.hpp @@ -24,10 +24,10 @@ namespace boost { namespace container { -template +template class equal_to_value { - typedef typename Allocator::value_type value_type; + typedef ValueType value_type; const value_type &t_; public: diff --git a/include/boost/container/detail/container_or_allocator_rebind.hpp b/include/boost/container/detail/container_or_allocator_rebind.hpp index d74df6c..1525e41 100644 --- a/include/boost/container/detail/container_or_allocator_rebind.hpp +++ b/include/boost/container/detail/container_or_allocator_rebind.hpp @@ -34,7 +34,11 @@ struct container_or_allocator_rebind_impl template struct container_or_allocator_rebind_impl : allocator_traits::template portable_rebind_alloc +{}; +template +struct container_or_allocator_rebind_impl + : real_allocator {}; template diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index e131cf1..db47562 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -427,13 +427,15 @@ class flat_tree_value_compare { return *this; } }; + /////////////////////////////////////// // // select_container_type // /////////////////////////////////////// template < class Value, class AllocatorOrContainer - , bool = boost::container::dtl::is_container::value > + , bool = boost::container::dtl::is_container::value + > struct select_container_type { typedef AllocatorOrContainer type; @@ -442,7 +444,7 @@ struct select_container_type template struct select_container_type { - typedef boost::container::vector type; + typedef boost::container::vector::type> type; }; diff --git a/include/boost/container/detail/is_container.hpp b/include/boost/container/detail/is_container.hpp index feab702..7181c7f 100644 --- a/include/boost/container/detail/is_container.hpp +++ b/include/boost/container/detail/is_container.hpp @@ -48,6 +48,13 @@ struct is_container has_member_function_callable_with_empty::value; }; +template <> +struct is_container +{ + static const bool value = false; +}; + + } //namespace dtl { } //namespace container { } //namespace boost { diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp index 498fc73..08965e5 100644 --- a/include/boost/container/detail/tree.hpp +++ b/include/boost/container/detail/tree.hpp @@ -484,32 +484,65 @@ struct get_tree_opt typedef tree_assoc_defaults type; }; +template +struct real_key_of_value +{ + typedef KeyOfValue type; +}; + +template +struct real_key_of_value +{ + typedef dtl::identity type; +}; + +template +struct real_key_of_value, int> +{ + typedef dtl::select1st type; +}; + +template +struct real_key_of_value, int> +{ + typedef dtl::select1st type; +}; + template class tree : public dtl::node_alloc_holder - < Allocator + < typename real_allocator::type , typename dtl::intrusive_tree_type - < Allocator, tree_value_compare - ::pointer, Compare, KeyOfValue> + < typename real_allocator::type + , tree_value_compare + ::type>::pointer, Compare, typename real_key_of_value::type> , get_tree_opt::type::tree_type , get_tree_opt::type::optimize_size >::type > { + typedef tree < T, KeyOfValue + , Compare, Allocator, Options> ThisType; + public: + typedef typename real_allocator::type allocator_type; + + private: + typedef allocator_traits allocator_traits_t; + typedef typename real_key_of_value::type key_of_value_t; typedef tree_value_compare - < typename allocator_traits::pointer - , Compare, KeyOfValue> ValComp; + < typename allocator_traits_t::pointer + , Compare + , key_of_value_t> ValComp; typedef typename get_tree_opt::type options_type; typedef typename dtl::intrusive_tree_type - < Allocator, ValComp + < allocator_type, ValComp , options_type::tree_type , options_type::optimize_size >::type Icont; typedef dtl::node_alloc_holder - AllocHolder; + AllocHolder; typedef typename AllocHolder::NodePtr NodePtr; - typedef tree < T, KeyOfValue - , Compare, Allocator, Options> ThisType; + typedef typename AllocHolder::NodeAlloc NodeAlloc; typedef boost::container:: allocator_traits allocator_traits_type; @@ -525,41 +558,40 @@ class tree public: - typedef typename KeyOfValue::type key_type; - typedef T value_type; - typedef Allocator allocator_type; - typedef Compare key_compare; - typedef ValComp value_compare; + typedef typename key_of_value_t::type key_type; + typedef T value_type; + typedef Compare key_compare; + typedef ValComp value_compare; typedef typename boost::container:: - allocator_traits::pointer pointer; + allocator_traits::pointer pointer; typedef typename boost::container:: - allocator_traits::const_pointer const_pointer; + allocator_traits::const_pointer const_pointer; typedef typename boost::container:: - allocator_traits::reference reference; + allocator_traits::reference reference; typedef typename boost::container:: - allocator_traits::const_reference const_reference; + allocator_traits::const_reference const_reference; typedef typename boost::container:: - allocator_traits::size_type size_type; + allocator_traits::size_type size_type; typedef typename boost::container:: - allocator_traits::difference_type difference_type; + allocator_traits::difference_type difference_type; typedef dtl::iterator_from_iiterator - iterator; + iterator; typedef dtl::iterator_from_iiterator - const_iterator; + const_iterator; typedef boost::container::reverse_iterator - reverse_iterator; + reverse_iterator; typedef boost::container::reverse_iterator - const_reverse_iterator; + const_reverse_iterator; typedef node_handle - < NodeAlloc, void> node_type; + < NodeAlloc, void> node_type; typedef insert_return_type_base - insert_return_type; + insert_return_type; - typedef NodeAlloc stored_allocator_type; + typedef NodeAlloc stored_allocator_type; private: - typedef key_node_compare KeyNodeCompare; + typedef key_node_compare KeyNodeCompare; public: @@ -955,7 +987,7 @@ class tree { insert_commit_data data; std::pair ret = - this->insert_unique_check(KeyOfValue()(v), data); + this->insert_unique_check(key_of_value_t()(v), data); if(ret.second){ ret.first = this->insert_unique_commit(boost::forward(v), data); } @@ -998,7 +1030,7 @@ class tree insert_commit_data data; scoped_destroy_deallocator destroy_deallocator(p, this->node_alloc()); std::pair ret = - this->insert_unique_check(KeyOfValue()(v), data); + this->insert_unique_check(key_of_value_t()(v), data); if(!ret.second){ return ret; } @@ -1015,7 +1047,7 @@ class tree value_type &v = p->get_data(); insert_commit_data data; std::pair ret = - this->insert_unique_check(hint, KeyOfValue()(v), data); + this->insert_unique_check(hint, key_of_value_t()(v), data); if(!ret.second){ Destroyer(this->node_alloc())(p); return ret.first; @@ -1131,7 +1163,7 @@ class tree BOOST_ASSERT((priv_is_linked)(hint)); insert_commit_data data; std::pair ret = - this->insert_unique_check(hint, KeyOfValue()(v), data); + this->insert_unique_check(hint, key_of_value_t()(v), data); if(!ret.second) return ret.first; return this->insert_unique_commit(boost::forward(v), data); @@ -1246,7 +1278,7 @@ class tree if(!nh.empty()){ insert_commit_data data; std::pair ret = - this->insert_unique_check(hint, KeyOfValue()(nh.value()), data); + this->insert_unique_check(hint, key_of_value_t()(nh.value()), data); if(ret.second){ irt.inserted = true; irt.position = iterator(this->icont().insert_unique_commit(*nh.get(), data)); diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp index 736af1c..b55a6ca 100644 --- a/include/boost/container/flat_map.hpp +++ b/include/boost/container/flat_map.hpp @@ -195,7 +195,7 @@ class flat_map typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type; //AllocatorOrContainer::value_type must be std::pair - BOOST_STATIC_ASSERT((dtl::is_same, typename allocator_type::value_type>::value)); + BOOST_STATIC_ASSERT((dtl::is_same, value_type>::value)); ////////////////////////////////////////////// // @@ -1773,7 +1773,7 @@ class flat_multimap typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type; //AllocatorOrContainer::value_type must be std::pair - BOOST_STATIC_ASSERT((dtl::is_same, typename AllocatorOrContainer::value_type>::value)); + BOOST_STATIC_ASSERT((dtl::is_same, value_type>::value)); ////////////////////////////////////////////// // diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp index 4be33fc..5b68b97 100644 --- a/include/boost/container/list.hpp +++ b/include/boost/container/list.hpp @@ -162,28 +162,32 @@ struct intrusive_list_type //! or mutation is explicit. //! //! \tparam T The type of object that is stored in the list -//! \tparam Allocator The allocator used for all internal memory management +//! \tparam Allocator The allocator used for all internal memory management, use void +//! for the default allocator #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template > +template #else template #endif class list : protected dtl::node_alloc_holder - ::type> + < typename real_allocator::type + , typename dtl::intrusive_list_type::type>::type> { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + typedef typename real_allocator::type ValueAllocator; typedef typename - dtl::intrusive_list_type::type Icont; - typedef dtl::node_alloc_holder AllocHolder; + dtl::intrusive_list_type::type Icont; + typedef dtl::node_alloc_holder AllocHolder; typedef typename AllocHolder::NodePtr NodePtr; typedef typename AllocHolder::NodeAlloc NodeAlloc; typedef typename AllocHolder::ValAlloc ValAlloc; typedef typename AllocHolder::Node Node; - typedef dtl::allocator_destroyer Destroyer; + typedef dtl::allocator_destroyer Destroyer; typedef typename AllocHolder::alloc_version alloc_version; - typedef boost::container::allocator_traits allocator_traits_type; - typedef boost::container::equal_to_value equal_to_value_type; + typedef boost::container::allocator_traits allocator_traits_type; + typedef boost::container::equal_to_value + equal_to_value_type; BOOST_COPYABLE_AND_MOVABLE(list) @@ -199,13 +203,13 @@ class list ////////////////////////////////////////////// typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; + typedef typename ::boost::container::allocator_traits::pointer pointer; + typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; + typedef typename ::boost::container::allocator_traits::reference reference; + typedef typename ::boost::container::allocator_traits::const_reference const_reference; + typedef typename ::boost::container::allocator_traits::size_type size_type; + typedef typename ::boost::container::allocator_traits::difference_type difference_type; + typedef ValueAllocator allocator_type; typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type; typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator; typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator; @@ -223,7 +227,7 @@ class list //! Throws: If allocator_type's default constructor throws. //! //! Complexity: Constant. - list() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) + list() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) : AllocHolder() {} @@ -244,7 +248,7 @@ class list //! //! Complexity: Linear to n. explicit list(size_type n) - : AllocHolder(Allocator()) + : AllocHolder(ValueAllocator()) { this->resize(n); } //! Effects: Constructs a list that will use a copy of allocator a @@ -265,7 +269,7 @@ class list //! throws or T's default or copy constructor throws. //! //! Complexity: Linear to n. - list(size_type n, const T& value, const Allocator& a = Allocator()) + list(size_type n, const T& value, const ValueAllocator& a = ValueAllocator()) : AllocHolder(a) { this->insert(this->cbegin(), n, value); } @@ -325,7 +329,7 @@ class list //! //! Complexity: Linear to the range [first, last). template - list(InpIt first, InpIt last, const Allocator &a = Allocator()) + list(InpIt first, InpIt last, const ValueAllocator &a = ValueAllocator()) : AllocHolder(a) { this->insert(this->cbegin(), first, last); } @@ -339,7 +343,7 @@ class list //! std::initializer_list iterator throws. //! //! Complexity: Linear to the range [il.begin(), il.end()). - list(std::initializer_list il, const Allocator &a = Allocator()) + list(std::initializer_list il, const ValueAllocator &a = ValueAllocator()) : AllocHolder(a) { this->insert(this->cbegin(), il.begin(), il.end()); } #endif @@ -1503,9 +1507,9 @@ template list(InputIterator, InputIterator) -> list::value_type>; -template -list(InputIterator, InputIterator, Allocator const&) -> - list::value_type, Allocator>; +template +list(InputIterator, InputIterator, ValueAllocator const&) -> + list::value_type, ValueAllocator>; #endif #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp index 8592c2c..a21228b 100644 --- a/include/boost/container/map.hpp +++ b/include/boost/container/map.hpp @@ -72,7 +72,7 @@ namespace container { //! (e.g. allocator< std::pair > ). //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options. template < class Key, class T, class Compare = std::less - , class Allocator = new_allocator< std::pair< const Key, T> >, class Options = tree_assoc_defaults > + , class Allocator = void, class Options = tree_assoc_defaults > #else template #endif @@ -80,7 +80,7 @@ class map ///@cond : public dtl::tree < std::pair - , dtl::select1st + , int , Compare, Allocator, Options> ///@endcond { @@ -88,11 +88,11 @@ class map private: BOOST_COPYABLE_AND_MOVABLE(map) - typedef dtl::select1st select_1st_t; + typedef int select_1st_t; typedef std::pair value_type_impl; typedef dtl::tree base_t; - typedef dtl::pair movable_value_type_impl; + typedef dtl::pair movable_value_type_impl; typedef typename base_t::value_compare value_compare_impl; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -103,26 +103,26 @@ class map // ////////////////////////////////////////////// - typedef Key key_type; - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef T mapped_type; - typedef typename boost::container::allocator_traits::value_type value_type; - typedef typename boost::container::allocator_traits::pointer pointer; - typedef typename boost::container::allocator_traits::const_pointer const_pointer; - typedef typename boost::container::allocator_traits::reference reference; - typedef typename boost::container::allocator_traits::const_reference const_reference; - typedef typename boost::container::allocator_traits::size_type size_type; - typedef typename boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; - typedef Compare key_compare; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - typedef std::pair nonconst_value_type; - typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; + typedef Key key_type; + typedef T mapped_type; + typedef typename base_t::allocator_type allocator_type; + typedef ::boost::container::allocator_traits allocator_traits_type; + typedef typename boost::container::allocator_traits::value_type value_type; + typedef typename boost::container::allocator_traits::pointer pointer; + typedef typename boost::container::allocator_traits::const_pointer const_pointer; + typedef typename boost::container::allocator_traits::reference reference; + typedef typename boost::container::allocator_traits::const_reference const_reference; + typedef typename boost::container::allocator_traits::size_type size_type; + typedef typename boost::container::allocator_traits::difference_type difference_type; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; + typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; + typedef Compare key_compare; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; + typedef std::pair nonconst_value_type; + typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; typedef BOOST_CONTAINER_IMPDEF(node_handle< typename base_t::stored_allocator_type BOOST_MOVE_I pair_key_mapped_of_value @@ -143,7 +143,7 @@ class map //! //! Complexity: Constant. BOOST_CONTAINER_FORCEINLINE - map() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && + map() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && dtl::is_nothrow_default_constructible::value) : base_t() {} @@ -1405,7 +1405,7 @@ class multimap ///@cond : public dtl::tree < std::pair - , dtl::select1st + , int , Compare, Allocator, Options> ///@endcond { @@ -1413,7 +1413,7 @@ class multimap private: BOOST_COPYABLE_AND_MOVABLE(multimap) - typedef dtl::select1st select_1st_t; + typedef int select_1st_t; typedef std::pair value_type_impl; typedef dtl::tree base_t; @@ -1421,8 +1421,6 @@ class multimap typedef typename base_t::value_compare value_compare_impl; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef ::boost::container::allocator_traits allocator_traits_type; - public: ////////////////////////////////////////////// // @@ -1430,25 +1428,26 @@ class multimap // ////////////////////////////////////////////// - typedef Key key_type; - typedef T mapped_type; - typedef typename boost::container::allocator_traits::value_type value_type; - typedef typename boost::container::allocator_traits::pointer pointer; - typedef typename boost::container::allocator_traits::const_pointer const_pointer; - typedef typename boost::container::allocator_traits::reference reference; - typedef typename boost::container::allocator_traits::const_reference const_reference; - typedef typename boost::container::allocator_traits::size_type size_type; - typedef typename boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; - typedef Compare key_compare; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - typedef std::pair nonconst_value_type; - typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; + typedef Key key_type; + typedef T mapped_type; + typedef typename base_t::allocator_type allocator_type; + typedef ::boost::container::allocator_traits allocator_traits_type; + typedef typename boost::container::allocator_traits::value_type value_type; + typedef typename boost::container::allocator_traits::pointer pointer; + typedef typename boost::container::allocator_traits::const_pointer const_pointer; + typedef typename boost::container::allocator_traits::reference reference; + typedef typename boost::container::allocator_traits::const_reference const_reference; + typedef typename boost::container::allocator_traits::size_type size_type; + typedef typename boost::container::allocator_traits::difference_type difference_type; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; + typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; + typedef Compare key_compare; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; + typedef std::pair nonconst_value_type; + typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; typedef BOOST_CONTAINER_IMPDEF(node_handle< typename base_t::stored_allocator_type BOOST_MOVE_I pair_key_mapped_of_value @@ -1467,7 +1466,7 @@ class multimap //! //! Complexity: Constant. BOOST_CONTAINER_FORCEINLINE multimap() - BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && + BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && dtl::is_nothrow_default_constructible::value) : base_t() {} diff --git a/include/boost/container/set.hpp b/include/boost/container/set.hpp index 8f9f58d..44bad8c 100644 --- a/include/boost/container/set.hpp +++ b/include/boost/container/set.hpp @@ -67,14 +67,14 @@ template class set ///@cond : public dtl::tree - < Key, dtl::identity, Compare, Allocator, Options> + < Key, void, Compare, Allocator, Options> ///@endcond { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: BOOST_COPYABLE_AND_MOVABLE(set) typedef dtl::tree - < Key, dtl::identity, Compare, Allocator, Options> base_t; + < Key, void, Compare, Allocator, Options> base_t; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: @@ -83,25 +83,25 @@ class set // types // ////////////////////////////////////////////// - typedef Key key_type; - typedef Key value_type; - typedef Compare key_compare; - typedef Compare value_compare; - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::insert_return_type) insert_return_type; + typedef Key key_type; + typedef Key value_type; + typedef Compare key_compare; + typedef key_compare value_compare; + typedef typename base_t::allocator_type allocator_type; + typedef ::boost::container::allocator_traits allocator_traits_type; + typedef typename ::boost::container::allocator_traits::pointer pointer; + typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; + typedef typename ::boost::container::allocator_traits::reference reference; + typedef typename ::boost::container::allocator_traits::const_reference const_reference; + typedef typename ::boost::container::allocator_traits::size_type size_type; + typedef typename ::boost::container::allocator_traits::difference_type difference_type; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::insert_return_type) insert_return_type; ////////////////////////////////////////////// // @@ -114,7 +114,7 @@ class set //! Complexity: Constant. BOOST_CONTAINER_FORCEINLINE set() - BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && + BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && dtl::is_nothrow_default_constructible::value) : base_t() {} @@ -655,7 +655,7 @@ class set BOOST_CONTAINER_FORCEINLINE void merge(set& source) { typedef dtl::tree - , C2, Allocator, Options> base2_t; + base2_t; this->base_t::merge_unique(static_cast(source)); } @@ -669,7 +669,7 @@ class set BOOST_CONTAINER_FORCEINLINE void merge(multiset& source) { typedef dtl::tree - , C2, Allocator, Options> base2_t; + base2_t; this->base_t::merge_unique(static_cast(source)); } @@ -1058,14 +1058,14 @@ template class multiset /// @cond : public dtl::tree - , Compare, Allocator, Options> + /// @endcond { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: BOOST_COPYABLE_AND_MOVABLE(multiset) typedef dtl::tree - , Compare, Allocator, Options> base_t; + base_t; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: @@ -1075,24 +1075,24 @@ class multiset // types // ////////////////////////////////////////////// - typedef Key key_type; - typedef Key value_type; - typedef Compare key_compare; - typedef Compare value_compare; - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type; + typedef Key key_type; + typedef Key value_type; + typedef Compare key_compare; + typedef key_compare value_compare; + typedef typename base_t::allocator_type allocator_type; + typedef ::boost::container::allocator_traits allocator_traits_type; + typedef typename ::boost::container::allocator_traits::pointer pointer; + typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; + typedef typename ::boost::container::allocator_traits::reference reference; + typedef typename ::boost::container::allocator_traits::const_reference const_reference; + typedef typename ::boost::container::allocator_traits::size_type size_type; + typedef typename ::boost::container::allocator_traits::difference_type difference_type; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; + typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type; ////////////////////////////////////////////// // @@ -1102,7 +1102,7 @@ class multiset //! @copydoc ::boost::container::set::set() BOOST_CONTAINER_FORCEINLINE multiset() - BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && + BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value && dtl::is_nothrow_default_constructible::value) : base_t() {} @@ -1448,7 +1448,7 @@ class multiset BOOST_CONTAINER_FORCEINLINE void merge(multiset& source) { typedef dtl::tree - , C2, Allocator, Options> base2_t; + base2_t; this->base_t::merge_equal(static_cast(source)); } @@ -1462,7 +1462,7 @@ class multiset BOOST_CONTAINER_FORCEINLINE void merge(set& source) { typedef dtl::tree - , C2, Allocator, Options> base2_t; + base2_t; this->base_t::merge_equal(static_cast(source)); } diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp index 6310f58..a37851d 100644 --- a/include/boost/container/slist.hpp +++ b/include/boost/container/slist.hpp @@ -192,20 +192,23 @@ struct intrusive_slist_type //! then you should probably use list instead of slist. //! //! \tparam T The type of object that is stored in the list -//! \tparam Allocator The allocator used for all internal memory management +//! \tparam Allocator The allocator used for all internal memory management, use void +//! for the default allocator #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template > +template #else template #endif class slist : protected dtl::node_alloc_holder - ::type> + < typename real_allocator::type + , typename dtl::intrusive_slist_type::type>::type> { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + typedef typename real_allocator::type ValueAllocator; typedef typename - dtl::intrusive_slist_type::type Icont; - typedef dtl::node_alloc_holder AllocHolder; + dtl::intrusive_slist_type::type Icont; + typedef dtl::node_alloc_holder AllocHolder; typedef typename AllocHolder::NodePtr NodePtr; typedef typename AllocHolder::NodeAlloc NodeAlloc; typedef typename AllocHolder::ValAlloc ValAlloc; @@ -213,8 +216,9 @@ class slist typedef dtl::allocator_destroyer Destroyer; typedef typename AllocHolder::alloc_version alloc_version; typedef boost::container:: - allocator_traits allocator_traits_type; - typedef boost::container::equal_to_value equal_to_value_type; + allocator_traits allocator_traits_type; + typedef boost::container::equal_to_value + equal_to_value_type; BOOST_COPYABLE_AND_MOVABLE(slist) typedef dtl::iterator_from_iiterator iterator_impl; @@ -229,13 +233,13 @@ class slist ////////////////////////////////////////////// typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; + typedef typename ::boost::container::allocator_traits::pointer pointer; + typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; + typedef typename ::boost::container::allocator_traits::reference reference; + typedef typename ::boost::container::allocator_traits::const_reference const_reference; + typedef typename ::boost::container::allocator_traits::size_type size_type; + typedef typename ::boost::container::allocator_traits::difference_type difference_type; + typedef ValueAllocator allocator_type; typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type; typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator; typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator; @@ -253,7 +257,7 @@ class slist //! Throws: If allocator_type's copy constructor throws. //! //! Complexity: Constant. - slist() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) + slist() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) : AllocHolder() {} @@ -1710,11 +1714,11 @@ BOOST_CONTAINER_DOC1ST(namespace std {, BOOST_MOVE_STD_NS_BEG) //! A specialization of insert_iterator //! that works with slist -template -class insert_iterator > +template +class insert_iterator > { private: - typedef boost::container::slist Container; + typedef boost::container::slist Container; Container* container; typename Container::iterator iter; diff --git a/include/boost/container/small_vector.hpp b/include/boost/container/small_vector.hpp index c0edac8..83f1cad 100644 --- a/include/boost/container/small_vector.hpp +++ b/include/boost/container/small_vector.hpp @@ -50,7 +50,7 @@ namespace container { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -template > +template class small_vector_base; #endif @@ -78,45 +78,47 @@ class small_vector_base; //! is being used to store vector elements. //! //! `small_vector_allocator` assumes that will be instantiated as -//! `boost::container::vector< T, small_vector_allocator >` +//! `boost::container::vector< T, small_vector_allocator >` //! and internal storage can be obtained downcasting that vector //! to `small_vector_base`. -template +template class small_vector_allocator - : public Allocator + : public allocator_traits::type>::template portable_rebind_alloc::type { typedef unsigned int allocation_type; #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + typedef typename allocator_traits::type>::template portable_rebind_alloc::type allocator_type; + BOOST_COPYABLE_AND_MOVABLE(small_vector_allocator) - BOOST_CONTAINER_FORCEINLINE const Allocator &as_base() const - { return static_cast(*this); } + BOOST_CONTAINER_FORCEINLINE const allocator_type &as_base() const + { return static_cast(*this); } - BOOST_CONTAINER_FORCEINLINE Allocator &as_base() - { return static_cast(*this); } + BOOST_CONTAINER_FORCEINLINE allocator_type &as_base() + { return static_cast(*this); } #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef allocator_traits allocator_traits_type; + typedef allocator_traits allocator_traits_type; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef typename allocator_traits::value_type value_type; - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::reference reference; - typedef typename allocator_traits::const_reference const_reference; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::difference_type difference_type; - typedef typename allocator_traits::void_pointer void_pointer; - typedef typename allocator_traits::const_void_pointer const_void_pointer; + typedef typename allocator_traits::value_type value_type; + typedef typename allocator_traits::pointer pointer; + typedef typename allocator_traits::const_pointer const_pointer; + typedef typename allocator_traits::reference reference; + typedef typename allocator_traits::const_reference const_reference; + typedef typename allocator_traits::size_type size_type; + typedef typename allocator_traits::difference_type difference_type; + typedef typename allocator_traits::void_pointer void_pointer; + typedef typename allocator_traits::const_void_pointer const_void_pointer; - typedef typename allocator_traits::propagate_on_container_copy_assignment propagate_on_container_copy_assignment; - typedef typename allocator_traits::propagate_on_container_move_assignment propagate_on_container_move_assignment; - typedef typename allocator_traits::propagate_on_container_swap propagate_on_container_swap; + typedef typename allocator_traits::propagate_on_container_copy_assignment propagate_on_container_copy_assignment; + typedef typename allocator_traits::propagate_on_container_move_assignment propagate_on_container_move_assignment; + typedef typename allocator_traits::propagate_on_container_swap propagate_on_container_swap; //! An integral constant with member `value == false` typedef BOOST_CONTAINER_IMPDEF(dtl::bool_) is_always_equal; //! An integral constant with member `value == true` @@ -129,20 +131,20 @@ class small_vector_allocator template struct rebind { - typedef typename allocator_traits::template rebind_alloc::type other; + typedef typename allocator_traits::template portable_rebind_alloc::type other; }; #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //!Constructor from arbitrary arguments template BOOST_CONTAINER_FORCEINLINE explicit small_vector_allocator(BOOST_FWD_REF(Args) ...args) - : Allocator(::boost::forward(args)...) + : allocator_type(::boost::forward(args)...) {} #else #define BOOST_CONTAINER_SMALL_VECTOR_ALLOCATOR_CTOR_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ BOOST_CONTAINER_FORCEINLINE explicit small_vector_allocator(BOOST_MOVE_UREF##N)\ - : Allocator(BOOST_MOVE_FWD##N)\ + : allocator_type(BOOST_MOVE_FWD##N)\ {}\ // BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SMALL_VECTOR_ALLOCATOR_CTOR_CODE) @@ -153,57 +155,57 @@ class small_vector_allocator //!Never throws BOOST_CONTAINER_FORCEINLINE small_vector_allocator (const small_vector_allocator &other) BOOST_NOEXCEPT_OR_NOTHROW - : Allocator(other.as_base()) + : allocator_type(other.as_base()) {} //!Move constructor from small_vector_allocator. //!Never throws BOOST_CONTAINER_FORCEINLINE small_vector_allocator (BOOST_RV_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW - : Allocator(::boost::move(other.as_base())) + : allocator_type(::boost::move(other.as_base())) {} //!Constructor from related small_vector_allocator. //!Never throws - template + template BOOST_CONTAINER_FORCEINLINE small_vector_allocator - (const small_vector_allocator &other) BOOST_NOEXCEPT_OR_NOTHROW - : Allocator(other.as_base()) + (const small_vector_allocator &other) BOOST_NOEXCEPT_OR_NOTHROW + : allocator_type(other.as_base()) {} //!Move constructor from related small_vector_allocator. //!Never throws - template + template BOOST_CONTAINER_FORCEINLINE small_vector_allocator - (BOOST_RV_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW - : Allocator(::boost::move(other.as_base())) + (BOOST_RV_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW + : allocator_type(::boost::move(other.as_base())) {} //!Assignment from other small_vector_allocator. //!Never throws BOOST_CONTAINER_FORCEINLINE small_vector_allocator & operator=(BOOST_COPY_ASSIGN_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(this->Allocator::operator=(other.as_base())); } + { return static_cast(this->allocator_type::operator=(other.as_base())); } //!Move constructor from other small_vector_allocator. //!Never throws BOOST_CONTAINER_FORCEINLINE small_vector_allocator & operator=(BOOST_RV_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(this->Allocator::operator=(::boost::move(other.as_base()))); } + { return static_cast(this->allocator_type::operator=(::boost::move(other.as_base()))); } //!Assignment from related small_vector_allocator. //!Never throws - template + template BOOST_CONTAINER_FORCEINLINE small_vector_allocator & - operator=(BOOST_COPY_ASSIGN_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(this->Allocator::operator=(other.as_base())); } + operator=(BOOST_COPY_ASSIGN_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW + { return static_cast(this->allocator_type::operator=(other.as_base())); } //!Move assignment from related small_vector_allocator. //!Never throws - template + template BOOST_CONTAINER_FORCEINLINE small_vector_allocator & - operator=(BOOST_RV_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(this->Allocator::operator=(::boost::move(other.as_base()))); } + operator=(BOOST_RV_REF(small_vector_allocator) other) BOOST_NOEXCEPT_OR_NOTHROW + { return static_cast(this->allocator_type::operator=(::boost::move(other.as_base()))); } //!Allocates storage from the standard-conforming allocator BOOST_CONTAINER_FORCEINLINE pointer allocate(size_type count, const_void_pointer hint = const_void_pointer()) @@ -269,12 +271,16 @@ class small_vector_allocator //!must be deallocated only with deallocate_one(). //!Throws bad_alloc if there is no enough memory //!This function is available only with Version == 2 - using Allocator::allocate_one; - using Allocator::allocate_individual; - using Allocator::deallocate_one; - using Allocator::deallocate_individual; - using Allocator::allocate_many; - using Allocator::deallocate_many;*/ + using allocator_type::allocate_one; + using allocator_type::allocate_individual; + using allocator_type::deallocate_one; + using allocator_type::deallocate_individual; + using allocator_type::allocate_many; + using allocator_type::deallocate_many;*/ + + typedef vector_alloc_holder< small_vector_allocator, size_type > vector_alloc_holder_t; + typedef vector vector_base; + typedef small_vector_base derived_type; BOOST_CONTAINER_FORCEINLINE bool is_internal_storage(const_pointer p) const { return this->internal_storage() == p; } @@ -282,12 +288,6 @@ class small_vector_allocator BOOST_CONTAINER_FORCEINLINE const_pointer internal_storage() const { - typedef typename Allocator::value_type value_type; - typedef typename allocator_traits_type::size_type size_type; - typedef vector_alloc_holder< small_vector_allocator, size_type > vector_alloc_holder_t; - typedef vector > vector_base; - typedef small_vector_base derived_type; - // const vector_alloc_holder_t &v_holder = static_cast(*this); const vector_base &v_base = reinterpret_cast(v_holder); const derived_type &d_base = static_cast(v_base); @@ -297,12 +297,6 @@ class small_vector_allocator BOOST_CONTAINER_FORCEINLINE pointer internal_storage() { - typedef typename Allocator::value_type value_type; - typedef typename allocator_traits_type::size_type size_type; - typedef vector_alloc_holder< small_vector_allocator, size_type > vector_alloc_holder_t; - typedef vector > vector_base; - typedef small_vector_base derived_type; - // vector_alloc_holder_t &v_holder = static_cast(*this); vector_base &v_base = reinterpret_cast(v_holder); derived_type &d_base = static_cast(v_base); @@ -338,21 +332,31 @@ class small_vector_allocator //! template class small_vector_base - : public vector > + : public vector + < T + , small_vector_allocator + < T + , typename allocator_traits::type>::template portable_rebind_alloc::type + > + > { - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKEDVECTOR public: //Make it public as it will be inherited by small_vector and container //must have this public member - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::void_pointer void_pointer; - typedef typename allocator_traits::const_void_pointer const_void_pointer; + typedef typename real_allocator::type secondary_allocator_t; + typedef typename allocator_traits::template portable_rebind_alloc::type void_allocator_t; + typedef vector > base_type; + typedef typename allocator_traits::pointer pointer; + typedef typename allocator_traits::const_pointer const_pointer; + typedef typename allocator_traits::void_pointer void_pointer; + typedef typename allocator_traits::const_void_pointer const_void_pointer; + typedef small_vector_allocator allocator_type; private: BOOST_COPYABLE_AND_MOVABLE(small_vector_base) - friend class small_vector_allocator; + friend class small_vector_allocator; BOOST_CONTAINER_FORCEINLINE const_pointer internal_storage() const BOOST_NOEXCEPT_OR_NOTHROW @@ -374,14 +378,12 @@ class small_vector_base return boost::intrusive::pointer_traits::static_cast_from(void_p); } - typedef vector > base_type; base_type &as_base() { return static_cast(*this); } const base_type &as_base() const { return static_cast(*this); } public: typedef typename dtl::aligned_storage ::value>::type storage_type; - typedef small_vector_allocator allocator_type; protected: @@ -451,7 +453,9 @@ template struct small_vector_storage_calculator { typedef small_vector_base svh_type; - typedef vector > svhb_type; + typedef typename real_allocator::type value_allocator_t; + typedef typename allocator_traits::template portable_rebind_alloc::type void_allocator_t; + typedef vector > svhb_type; static const std::size_t s_align = dtl::alignment_of::value; static const std::size_t s_size = sizeof(Storage); static const std::size_t svh_sizeof = sizeof(svh_type); @@ -478,10 +482,10 @@ template struct small_vector_storage {}; -template +template struct small_vector_storage_definer { - typedef typename Allocator::value_type value_type; + typedef T value_type; typedef typename small_vector_base::storage_type storage_type; static const std::size_t needed_extra_storages = small_vector_storage_calculator::needed_extra_storages; @@ -501,16 +505,17 @@ struct small_vector_storage_definer //! //! \tparam T The type of object that is stored in the small_vector //! \tparam N The number of preallocated elements stored inside small_vector. It shall be less than Allocator::max_size(); -//! \tparam Allocator The allocator used for memory management when the number of elements exceeds N. -template ) > +//! \tparam Allocator The allocator used for memory management when the number of elements exceeds N. Use void +//! for the default allocator +template class small_vector : public small_vector_base #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - , private small_vector_storage_definer::type + , private small_vector_storage_definer::type #endif { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED typedef small_vector_base base_type; - typedef typename small_vector_storage_definer::type remaining_storage_holder; + typedef typename small_vector_storage_definer::type remaining_storage_holder; BOOST_COPYABLE_AND_MOVABLE(small_vector) diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 1f55c43..8af730b 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -465,14 +465,15 @@ class stable_vector_iterator //! \tparam T The type of object that is stored in the stable_vector //! \tparam Allocator The allocator used for all internal memory management #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template > +template #else template #endif class stable_vector { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef allocator_traits allocator_traits_type; + typedef typename real_allocator::type ValueAllocator; + typedef allocator_traits allocator_traits_type; typedef boost::intrusive:: pointer_traits ptr_traits; @@ -510,7 +511,7 @@ class stable_vector typedef ::boost::container::dtl::integral_constant ::value> alloc_version; + version::value> alloc_version; typedef typename allocator_traits_type:: template portable_rebind_alloc ::type node_allocator_type; @@ -533,10 +534,10 @@ class stable_vector friend class stable_vector_detail::clear_on_destroy; typedef stable_vector_iterator - < typename allocator_traits::pointer + < typename allocator_traits::pointer , false> iterator_impl; typedef stable_vector_iterator - < typename allocator_traits::pointer + < typename allocator_traits::pointer , true> const_iterator_impl; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: @@ -547,13 +548,13 @@ class stable_vector // ////////////////////////////////////////////// typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; + typedef typename ::boost::container::allocator_traits::pointer pointer; + typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; + typedef typename ::boost::container::allocator_traits::reference reference; + typedef typename ::boost::container::allocator_traits::const_reference const_reference; + typedef typename ::boost::container::allocator_traits::size_type size_type; + typedef typename ::boost::container::allocator_traits::difference_type difference_type; + typedef ValueAllocator allocator_type; typedef node_allocator_type stored_allocator_type; typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator; typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator; @@ -584,7 +585,7 @@ class stable_vector //! Throws: If allocator_type's default constructor throws. //! //! Complexity: Constant. - stable_vector() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) + stable_vector() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) : internal_data(), index() { STABLE_VECTOR_CHECK_INVARIANT; diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index ca51cfd..46ce035 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -87,9 +87,9 @@ class basic_string_base basic_string_base & operator=(const basic_string_base &); basic_string_base(const basic_string_base &); - typedef allocator_traits allocator_traits_type; + typedef Allocator allocator_type; public: - typedef Allocator allocator_type; + typedef allocator_traits allocator_traits_type; typedef allocator_type stored_allocator_type; typedef typename allocator_traits_type::pointer pointer; typedef typename allocator_traits_type::value_type value_type; @@ -207,7 +207,7 @@ class basic_string_base }; struct members_holder - : public Allocator + : public allocator_type { void init() { @@ -217,12 +217,12 @@ class basic_string_base } members_holder() - : Allocator() + : allocator_type() { this->init(); } template explicit members_holder(BOOST_FWD_REF(AllocatorConvertible) a) - : Allocator(boost::forward(a)) + : allocator_type(boost::forward(a)) { this->init(); } const short_t *pshort_repr() const @@ -240,10 +240,10 @@ class basic_string_base repr_t m_repr; } members_; - const Allocator &alloc() const + const allocator_type &alloc() const { return members_; } - Allocator &alloc() + allocator_type &alloc() { return members_; } static const size_type InternalBufferChars = (sizeof(repr_t) - ShortDataOffset)/sizeof(value_type); @@ -311,7 +311,7 @@ class basic_string_base protected: typedef dtl::integral_constant::value> alloc_version; + boost::container::dtl::version::value> alloc_version; pointer allocation_command(allocation_type command, size_type limit_size, @@ -322,7 +322,7 @@ class basic_string_base reuse = 0; command &= ~(expand_fwd | expand_bwd); } - return dtl::allocator_version_traits::allocation_command + return dtl::allocator_version_traits::allocation_command (this->alloc(), command, limit_size, prefer_in_recvd_out_size, reuse); } @@ -538,18 +538,18 @@ class basic_string_base //! \tparam Traits The Character Traits type, which encapsulates basic character operations //! \tparam Allocator The allocator, used for internal memory management. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template , class Allocator = new_allocator > +template , class Allocator = void > #else template #endif class basic_string - : private dtl::basic_string_base + : private dtl::basic_string_base::type> { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: - typedef allocator_traits allocator_traits_type; BOOST_COPYABLE_AND_MOVABLE(basic_string) - typedef dtl::basic_string_base base_t; + typedef dtl::basic_string_base::type> base_t; + typedef typename base_t::allocator_traits_type allocator_traits_type; static const typename base_t::size_type InternalBufferChars = base_t::InternalBufferChars; protected: @@ -596,13 +596,13 @@ class basic_string ////////////////////////////////////////////// typedef Traits traits_type; typedef CharT value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; + typedef typename real_allocator::type allocator_type; + typedef typename ::boost::container::allocator_traits::pointer pointer; + typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; + typedef typename ::boost::container::allocator_traits::reference reference; + typedef typename ::boost::container::allocator_traits::const_reference const_reference; + typedef typename ::boost::container::allocator_traits::size_type size_type; + typedef typename ::boost::container::allocator_traits::difference_type difference_type; typedef BOOST_CONTAINER_IMPDEF(allocator_type) stored_allocator_type; typedef BOOST_CONTAINER_IMPDEF(pointer) iterator; typedef BOOST_CONTAINER_IMPDEF(const_pointer) const_iterator; @@ -639,7 +639,7 @@ class basic_string //! Effects: Default constructs a basic_string. //! //! Throws: If allocator_type's default constructor throws. - basic_string() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) + basic_string() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) : base_t() { this->priv_terminate_string(); } @@ -667,7 +667,7 @@ class basic_string //! //! Throws: If allocator_type's default constructor or allocation throws. template