|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80795 - in trunk: boost/container boost/container/detail libs/container/doc libs/container/proj libs/container/test
From: igaztanaga_at_[hidden]
Date: 2012-09-30 16:38:07
Author: igaztanaga
Date: 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
New Revision: 80795
URL: http://svn.boost.org/trac/boost/changeset/80795
Log:
More Doxygen documentation improvements
Text files modified:
trunk/boost/container/container_fwd.hpp | 52 +-
trunk/boost/container/deque.hpp | 116 ++--
trunk/boost/container/detail/flat_tree.hpp | 3
trunk/boost/container/detail/tree.hpp | 10
trunk/boost/container/detail/utilities.hpp | 30 -
trunk/boost/container/flat_map.hpp | 314 ++++++-------
trunk/boost/container/flat_set.hpp | 850 ++++++++++++++++++++-------------------
trunk/boost/container/list.hpp | 113 ++--
trunk/boost/container/map.hpp | 750 ++++++++++++++++++----------------
trunk/boost/container/scoped_allocator.hpp | 32
trunk/boost/container/set.hpp | 700 +++++++++++++++++---------------
trunk/boost/container/slist.hpp | 81 +--
trunk/boost/container/stable_vector.hpp | 279 +++++-------
trunk/boost/container/string.hpp | 315 +++++--------
trunk/boost/container/vector.hpp | 136 +++---
trunk/libs/container/doc/Jamfile.v2 | 4
trunk/libs/container/proj/to-do.txt | 15
trunk/libs/container/test/string_test.cpp | 22
18 files changed, 1902 insertions(+), 1920 deletions(-)
Modified: trunk/boost/container/container_fwd.hpp
==============================================================================
--- trunk/boost/container/container_fwd.hpp (original)
+++ trunk/boost/container/container_fwd.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -49,85 +49,85 @@
//vector class
template <class T
- ,class A = std::allocator<T> >
+ ,class Allocator = std::allocator<T> >
class vector;
//vector class
template <class T
- ,class A = std::allocator<T> >
+ ,class Allocator = std::allocator<T> >
class stable_vector;
//vector class
template <class T
- ,class A = std::allocator<T> >
+ ,class Allocator = std::allocator<T> >
class deque;
//list class
template <class T
- ,class A = std::allocator<T> >
+ ,class Allocator = std::allocator<T> >
class list;
//slist class
template <class T
- ,class A = std::allocator<T> >
+ ,class Allocator = std::allocator<T> >
class slist;
//set class
-template <class T
- ,class Pred = std::less<T>
- ,class A = std::allocator<T> >
+template <class Key
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<Key> >
class set;
//multiset class
-template <class T
- ,class Pred = std::less<T>
- ,class A = std::allocator<T> >
+template <class Key
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<Key> >
class multiset;
//map class
template <class Key
,class T
- ,class Pred = std::less<Key>
- ,class A = std::allocator<std::pair<const Key, T> > >
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<std::pair<const Key, T> > >
class map;
//multimap class
template <class Key
,class T
- ,class Pred = std::less<Key>
- ,class A = std::allocator<std::pair<const Key, T> > >
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<std::pair<const Key, T> > >
class multimap;
//flat_set class
-template <class T
- ,class Pred = std::less<T>
- ,class A = std::allocator<T> >
+template <class Key
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<Key> >
class flat_set;
//flat_multiset class
-template <class T
- ,class Pred = std::less<T>
- ,class A = std::allocator<T> >
+template <class Key
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<Key> >
class flat_multiset;
//flat_map class
template <class Key
,class T
- ,class Pred = std::less<Key>
- ,class A = std::allocator<std::pair<Key, T> > >
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<std::pair<Key, T> > >
class flat_map;
//flat_multimap class
template <class Key
,class T
- ,class Pred = std::less<Key>
- ,class A = std::allocator<std::pair<Key, T> > >
+ ,class Compare = std::less<Key>
+ ,class Allocator = std::allocator<std::pair<Key, T> > >
class flat_multimap;
//basic_string class
template <class CharT
,class Traits = std::char_traits<CharT>
- ,class A = std::allocator<CharT> >
+ ,class Allocator = std::allocator<CharT> >
class basic_string;
//! Type used to tag that the input range is
Modified: trunk/boost/container/deque.hpp
==============================================================================
--- trunk/boost/container/deque.hpp (original)
+++ trunk/boost/container/deque.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -67,17 +67,17 @@
/// @cond
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class A = std::allocator<T> >
+template <class T, class Allocator = std::allocator<T> >
#else
-template <class T, class A>
+template <class T, class Allocator>
#endif
class deque;
-template <class T, class A>
+template <class T, class Allocator>
struct deque_value_traits
{
typedef T value_type;
- typedef A allocator_type;
+ typedef Allocator allocator_type;
static const bool trivial_dctr = boost::has_trivial_destructor<value_type>::value;
static const bool trivial_dctr_after_move = false;
//::boost::has_trivial_destructor_after_move<value_type>::value || trivial_dctr;
@@ -96,12 +96,12 @@
// Deque base class. It has two purposes. First, its constructor
// and destructor allocate (but don't initialize) storage. This makes
// exception safety easier.
-template <class T, class A>
+template <class T, class Allocator>
class deque_base
{
BOOST_COPYABLE_AND_MOVABLE(deque_base)
public:
- typedef allocator_traits<A> val_alloc_traits_type;
+ typedef allocator_traits<Allocator> val_alloc_traits_type;
typedef typename val_alloc_traits_type::value_type val_alloc_val;
typedef typename val_alloc_traits_type::pointer val_alloc_ptr;
typedef typename val_alloc_traits_type::const_pointer val_alloc_cptr;
@@ -117,13 +117,13 @@
typedef typename ptr_alloc_traits_type::const_pointer ptr_alloc_cptr;
typedef typename ptr_alloc_traits_type::reference ptr_alloc_ref;
typedef typename ptr_alloc_traits_type::const_reference ptr_alloc_cref;
- typedef A allocator_type;
+ typedef Allocator allocator_type;
typedef allocator_type stored_allocator_type;
typedef val_alloc_size size_type;
protected:
- typedef deque_value_traits<T, A> traits_t;
+ typedef deque_value_traits<T, Allocator> traits_t;
typedef ptr_alloc_t map_allocator_type;
static size_type s_buffer_size() { return deque_buf_size(sizeof(T)); }
@@ -163,7 +163,7 @@
// [map, map + map_size) is a valid, non-empty range.
// [start.node, finish.node] is a valid range contained within
// [map, map + map_size).
- // A pointer in the range [map, map + map_size) points to an allocated node
+ // Allocator pointer in the range [map, map + map_size) points to an allocated node
// if and only if the pointer is in the range [start.node, finish.node].
class const_iterator
: public std::iterator<std::random_access_iterator_tag,
@@ -171,7 +171,7 @@
val_alloc_cptr, val_alloc_cref>
{
public:
- static size_type s_buffer_size() { return deque_base<T, A>::s_buffer_size(); }
+ static size_type s_buffer_size() { return deque_base<T, Allocator>::s_buffer_size(); }
typedef std::random_access_iterator_tag iterator_category;
typedef val_alloc_val value_type;
@@ -182,8 +182,8 @@
typedef ptr_alloc_ptr index_pointer;
typedef const_iterator self_t;
- friend class deque<T, A>;
- friend class deque_base<T, A>;
+ friend class deque<T, Allocator>;
+ friend class deque_base<T, Allocator>;
protected:
val_alloc_ptr m_cur;
@@ -323,8 +323,8 @@
typedef ptr_alloc_ptr index_pointer;
typedef const_iterator self_t;
- friend class deque<T, A>;
- friend class deque_base<T, A>;
+ friend class deque<T, Allocator>;
+ friend class deque_base<T, Allocator>;
private:
explicit iterator(const const_iterator& x) : const_iterator(x){}
@@ -525,15 +525,15 @@
//! Deque class
//!
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class A = std::allocator<T> >
+template <class T, class Allocator = std::allocator<T> >
#else
-template <class T, class A>
+template <class T, class Allocator>
#endif
-class deque : protected deque_base<T, A>
+class deque : protected deque_base<T, Allocator>
{
/// @cond
private:
- typedef deque_base<T, A> Base;
+ typedef deque_base<T, Allocator> Base;
/// @endcond
public:
@@ -544,19 +544,19 @@
//
//////////////////////////////////////////////
- typedef T value_type;
- typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
- typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits<A>::reference reference;
- typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
- typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
- typedef A allocator_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;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_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;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
/// @cond
@@ -568,7 +568,7 @@
typedef container_detail::advanced_insert_aux_int<iterator> advanced_insert_aux_int_t;
typedef repeat_iterator<T, difference_type> r_iterator;
typedef boost::move_iterator<r_iterator> move_it;
- typedef allocator_traits<A> allocator_traits_type;
+ typedef allocator_traits<Allocator> allocator_traits_type;
/// @endcond
@@ -607,7 +607,7 @@
explicit deque(size_type n)
: Base(n, allocator_type())
{
- container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n);
+ container_detail::default_construct_aux_proxy<Allocator, iterator> proxy(this->alloc(), n);
proxy.uninitialized_copy_remaining_to(this->begin());
//deque_base will deallocate in case of exception...
}
@@ -1020,7 +1020,7 @@
this->priv_erase_last_n(len - new_size);
else{
const size_type n = new_size - this->size();
- container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n);
+ container_detail::default_construct_aux_proxy<Allocator, iterator> proxy(this->alloc(), n);
priv_insert_back_aux_impl(n, proxy);
}
}
@@ -1176,7 +1176,7 @@
this->priv_push_front_simple_commit();
}
else{
- typedef container_detail::advanced_insert_aux_non_movable_emplace<A, iterator, Args...> type;
+ typedef container_detail::advanced_insert_aux_non_movable_emplace<Allocator, iterator, Args...> type;
type &&proxy = type(this->alloc(), boost::forward<Args>(args)...);
this->priv_insert_front_aux_impl(1, proxy);
}
@@ -1199,7 +1199,7 @@
this->priv_push_back_simple_commit();
}
else{
- typedef container_detail::advanced_insert_aux_non_movable_emplace<A, iterator, Args...> type;
+ typedef container_detail::advanced_insert_aux_non_movable_emplace<Allocator, iterator, Args...> type;
type &&proxy = type(this->alloc(), boost::forward<Args>(args)...);
this->priv_insert_back_aux_impl(1, proxy);
}
@@ -1226,7 +1226,7 @@
return (this->end()-1);
}
else{
- typedef container_detail::advanced_insert_aux_emplace<A, iterator, Args...> type;
+ typedef container_detail::advanced_insert_aux_emplace<Allocator, iterator, Args...> type;
type &&proxy = type(this->alloc(), boost::forward<Args>(args)...);
return this->priv_insert_aux_impl(p, 1, proxy);
}
@@ -1249,7 +1249,7 @@
else{ \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT \
(advanced_insert_aux_non_movable_emplace, n), arg) \
- <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
+ <Allocator, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
(this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
priv_insert_front_aux_impl(1, proxy); \
} \
@@ -1268,7 +1268,7 @@
else{ \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT( \
advanced_insert_aux_non_movable_emplace, n), arg) \
- <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
+ <Allocator, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
(this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
priv_insert_back_aux_impl(1, proxy); \
} \
@@ -1288,7 +1288,7 @@
} \
else{ \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
- <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
+ <Allocator, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
(this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
return this->priv_insert_aux_impl(p, 1, proxy); \
} \
@@ -1424,7 +1424,7 @@
#endif
)
{
- container_detail::advanced_insert_aux_proxy<A, FwdIt, iterator> proxy(this->alloc(), first, last);
+ container_detail::advanced_insert_aux_proxy<Allocator, FwdIt, iterator> proxy(this->alloc(), first, last);
return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
}
#endif
@@ -1978,36 +1978,36 @@
};
// Nonmember functions.
-template <class T, class A>
-inline bool operator==(const deque<T, A>& x, const deque<T, A>& y)
+template <class T, class Allocator>
+inline bool operator==(const deque<T, Allocator>& x, const deque<T, Allocator>& y)
{
return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
}
-template <class T, class A>
-inline bool operator<(const deque<T, A>& x, const deque<T, A>& y)
+template <class T, class Allocator>
+inline bool operator<(const deque<T, Allocator>& x, const deque<T, Allocator>& y)
{
return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
}
-template <class T, class A>
-inline bool operator!=(const deque<T, A>& x, const deque<T, A>& y)
+template <class T, class Allocator>
+inline bool operator!=(const deque<T, Allocator>& x, const deque<T, Allocator>& y)
{ return !(x == y); }
-template <class T, class A>
-inline bool operator>(const deque<T, A>& x, const deque<T, A>& y)
+template <class T, class Allocator>
+inline bool operator>(const deque<T, Allocator>& x, const deque<T, Allocator>& y)
{ return y < x; }
-template <class T, class A>
-inline bool operator>=(const deque<T, A>& x, const deque<T, A>& y)
+template <class T, class Allocator>
+inline bool operator>=(const deque<T, Allocator>& x, const deque<T, Allocator>& y)
{ return !(x < y); }
-template <class T, class A>
-inline bool operator<=(const deque<T, A>& x, const deque<T, A>& y)
+template <class T, class Allocator>
+inline bool operator<=(const deque<T, Allocator>& x, const deque<T, Allocator>& y)
{ return !(y < x); }
-template <class T, class A>
-inline void swap(deque<T, A>& x, deque<T, A>& y)
+template <class T, class Allocator>
+inline void swap(deque<T, Allocator>& x, deque<T, Allocator>& y)
{ x.swap(y); }
}}
@@ -2018,10 +2018,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class A>
-struct has_trivial_destructor_after_move<boost::container::deque<T, A> >
+template <class T, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::deque<T, Allocator> >
{
- enum { value = has_trivial_destructor<A>::value };
+ enum { value = has_trivial_destructor<Allocator>::value };
};
*/
}
Modified: trunk/boost/container/detail/flat_tree.hpp
==============================================================================
--- trunk/boost/container/detail/flat_tree.hpp (original)
+++ trunk/boost/container/detail/flat_tree.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -414,7 +414,8 @@
void insert_equal(ordered_range_t, FwdIt first, FwdIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
- < container_detail::is_forward_iterator<FwdIt>::value
+ < !container_detail::is_input_iterator<FwdIt>::value &&
+ container_detail::is_forward_iterator<FwdIt>::value
>::type * = 0
#endif
)
Modified: trunk/boost/container/detail/tree.hpp
==============================================================================
--- trunk/boost/container/detail/tree.hpp (original)
+++ trunk/boost/container/detail/tree.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -41,7 +41,7 @@
namespace container_detail {
template<class Key, class Value, class KeyCompare, class KeyOfValue>
-struct value_compare_impl
+struct tree_value_compare
: public KeyCompare
{
typedef Value value_type;
@@ -49,7 +49,7 @@
typedef KeyOfValue key_of_value;
typedef Key key_type;
- value_compare_impl(const key_compare &kcomp)
+ tree_value_compare(const key_compare &kcomp)
: key_compare(kcomp)
{}
@@ -209,13 +209,13 @@
: protected container_detail::node_alloc_holder
< A
, typename container_detail::intrusive_rbtree_type
- <A, value_compare_impl<Key, Value, KeyCompare, KeyOfValue>
+ <A, tree_value_compare<Key, Value, KeyCompare, KeyOfValue>
>::type
, KeyCompare
>
{
typedef typename container_detail::intrusive_rbtree_type
- < A, value_compare_impl
+ < A, tree_value_compare
<Key, Value, KeyCompare, KeyOfValue>
>::type Icont;
typedef container_detail::node_alloc_holder
@@ -315,7 +315,7 @@
typedef Value value_type;
typedef A allocator_type;
typedef KeyCompare key_compare;
- typedef value_compare_impl< Key, Value
+ typedef tree_value_compare< Key, Value
, KeyCompare, KeyOfValue> value_compare;
typedef typename boost::container::
allocator_traits<A>::pointer pointer;
Modified: trunk/boost/container/detail/utilities.hpp
==============================================================================
--- trunk/boost/container/detail/utilities.hpp (original)
+++ trunk/boost/container/detail/utilities.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -122,36 +122,6 @@
{
enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo };
};
-/*
-template <class _TypeT>
-struct __rw_is_enum
-{
- struct _C_no { };
- struct _C_yes { int _C_dummy [2]; };
-
- struct _C_indirect {
- // prevent classes with user-defined conversions from matching
-
- // use double to prevent float->int gcc conversion warnings
- _C_indirect (double);
-};
-
-// nested struct gets rid of bogus gcc errors
-struct _C_nest {
- // supply first argument to prevent HP aCC warnings
- static _C_no _C_is (int, ...);
- static _C_yes _C_is (int, _C_indirect);
-
- static _TypeT _C_make_T ();
-};
-
-enum {
- _C_val = sizeof (_C_yes) == sizeof (_C_nest::_C_is (0, _C_nest::_C_make_T ()))
- && !::boost::is_fundamental<_TypeT>::value
-};
-
-};
-*/
template<class T>
struct move_const_ref_type
Modified: trunk/boost/container/flat_map.hpp
==============================================================================
--- trunk/boost/container/flat_map.hpp (original)
+++ trunk/boost/container/flat_map.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -28,27 +28,23 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/container/allocator_traits.hpp>
#include <boost/move/move.hpp>
+#include <boost/move/move_helpers.hpp>
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-namespace boost {
-namespace container {
-#else
namespace boost {
namespace container {
-#endif
/// @cond
// Forward declarations of operators == and <, needed for friend declarations.
-template <class Key, class T, class Pred, class A>
+template <class Key, class T, class Compare, class Allocator>
class flat_map;
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y);
-
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y);
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y);
namespace container_detail{
@@ -78,9 +74,9 @@
//! flat_map<Key,T> the key_type is Key and the value_type is std::pair<Key,T>
//! (unlike std::map<Key, T> which value_type is std::pair<<b>const</b> Key, T>).
//!
-//! Pred is the ordering function for Keys (e.g. <i>std::less<Key></i>).
+//! Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
//!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
//! (e.g. <i>allocator< std::pair<Key, T> ></i>).
//!
//! flat_map is similar to std::map but it's implemented like an ordered vector.
@@ -90,9 +86,9 @@
//! Erasing an element of a flat_map invalidates iterators and references
//! pointing to elements that come after (their keys are bigger) the erased element.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< Key, T> > >
+template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< Key, T> > >
#else
-template <class Key, class T, class Pred, class A>
+template <class Key, class T, class Compare, class Allocator>
#endif
class flat_map
{
@@ -103,43 +99,33 @@
typedef container_detail::flat_tree<Key,
std::pair<Key, T>,
container_detail::select1st< std::pair<Key, T> >,
- Pred,
- A> tree_t;
+ Compare,
+ Allocator> tree_t;
//This is the real tree stored here. It's based on a movable pair
typedef container_detail::flat_tree<Key,
container_detail::pair<Key, T>,
container_detail::select1st<container_detail::pair<Key, T> >,
- Pred,
- typename allocator_traits<A>::template portable_rebind_alloc
+ Compare,
+ typename allocator_traits<Allocator>::template portable_rebind_alloc
<container_detail::pair<Key, T> >::type> impl_tree_t;
impl_tree_t m_flat_tree; // flat tree representing flat_map
typedef typename impl_tree_t::value_type impl_value_type;
- typedef typename impl_tree_t::pointer impl_pointer;
- typedef typename impl_tree_t::const_pointer impl_const_pointer;
- typedef typename impl_tree_t::reference impl_reference;
- typedef typename impl_tree_t::const_reference impl_const_reference;
- typedef typename impl_tree_t::value_compare impl_value_compare;
- typedef typename impl_tree_t::iterator impl_iterator;
typedef typename impl_tree_t::const_iterator impl_const_iterator;
- typedef typename impl_tree_t::reverse_iterator impl_reverse_iterator;
- typedef typename impl_tree_t::const_reverse_iterator impl_const_reverse_iterator;
typedef typename impl_tree_t::allocator_type impl_allocator_type;
- typedef allocator_traits<A> allocator_traits_type;
typedef container_detail::flat_tree_value_compare
- < Pred
+ < Compare
, container_detail::select1st< std::pair<Key, T> >
- , std::pair<Key, T> > value_compare_impl;
+ , std::pair<Key, T> > value_compare_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::iterator iterator_impl;
+ <typename allocator_traits<Allocator>::pointer>::iterator iterator_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::const_iterator const_iterator_impl;
+ <typename allocator_traits<Allocator>::pointer>::const_iterator const_iterator_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::reverse_iterator reverse_iterator_impl;
+ <typename allocator_traits<Allocator>::pointer>::reverse_iterator reverse_iterator_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::const_reverse_iterator const_reverse_iterator_impl;
-
+ <typename allocator_traits<Allocator>::pointer>::const_reverse_iterator const_reverse_iterator_impl;
/// @endcond
public:
@@ -149,24 +135,24 @@
// types
//
//////////////////////////////////////////////
- typedef Key key_type;
- typedef T mapped_type;
- typedef typename std::pair<key_type, mapped_type> value_type;
- typedef typename boost::container::allocator_traits<A>::pointer pointer;
- typedef typename boost::container::allocator_traits<A>::const_pointer const_pointer;
- typedef typename boost::container::allocator_traits<A>::reference reference;
- typedef typename boost::container::allocator_traits<A>::const_reference const_reference;
- typedef typename boost::container::allocator_traits<A>::size_type size_type;
- typedef typename boost::container::allocator_traits<A>::difference_type difference_type;
- typedef A allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(A) stored_allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
- typedef Pred key_compare;
- typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
- typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
- typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl) const_reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type;
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef std::pair<Key, T> value_type;
+ typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(Allocator) stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
+ typedef Compare key_compare;
+ typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl) const_reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type;
public:
//////////////////////////////////////////////
@@ -185,7 +171,7 @@
//! comparison object and allocator.
//!
//! <b>Complexity</b>: Constant.
- explicit flat_map(const Pred& comp, const allocator_type& a = allocator_type())
+ explicit flat_map(const Compare& comp, const allocator_type& a = allocator_type())
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a)) {}
//! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
@@ -194,7 +180,7 @@
//! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
//! comp and otherwise N logN, where N is last - first.
template <class InputIterator>
- flat_map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
+ flat_map(InputIterator first, InputIterator last, const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_flat_tree(true, first, last, comp, container_detail::force<impl_allocator_type>(a))
{}
@@ -211,7 +197,7 @@
//! <b>Note</b>: Non-standard extension.
template <class InputIterator>
flat_map( ordered_unique_range_t, InputIterator first, InputIterator last
- , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
+ , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
: m_flat_tree(ordered_range, first, last, comp, a)
{}
@@ -466,7 +452,7 @@
//! Effects: If there is no key equivalent to x in the flat_map, inserts
//! value_type(x, T()) into the flat_map.
//!
- //! Returns: A reference to the mapped_type corresponding to x in *this.
+ //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
//!
//! Complexity: Logarithmic.
mapped_type &operator[](const key_type& k);
@@ -474,16 +460,16 @@
//! Effects: If there is no key equivalent to x in the flat_map, inserts
//! value_type(move(x), T()) into the flat_map (the key is move-constructed)
//!
- //! Returns: A reference to the mapped_type corresponding to x in *this.
+ //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
//!
//! Complexity: Logarithmic.
mapped_type &operator[](key_type &&k) ;
#else
- BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, priv_subscript)
+ BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
#endif
- //! Returns: A reference to the element whose key is equivalent to x.
+ //! Returns: Allocator reference to the element whose key is equivalent to x.
//!
//! Throws: An exception object of type out_of_range if no such element is present.
//!
@@ -497,7 +483,7 @@
return i->second;
}
- //! Returns: A reference to the element whose key is equivalent to x.
+ //! Returns: Allocator reference to the element whose key is equivalent to x.
//!
//! Throws: An exception object of type out_of_range if no such element is present.
//!
@@ -790,7 +776,7 @@
iterator find(const key_type& x)
{ return container_detail::force_copy<iterator>(m_flat_tree.find(x)); }
- //! <b>Returns</b>: A const_iterator pointing to an element with the key
+ //! <b>Returns</b>: Allocator const_iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.s
@@ -810,7 +796,7 @@
iterator lower_bound(const key_type& x)
{ return container_detail::force_copy<iterator>(m_flat_tree.lower_bound(x)); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -824,7 +810,7 @@
iterator upper_bound(const key_type& x)
{ return container_detail::force_copy<iterator>(m_flat_tree.upper_bound(x)); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -876,39 +862,39 @@
/// @endcond
};
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y)
{ return x.m_flat_tree == y.m_flat_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y)
{ return x.m_flat_tree < y.m_flat_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator!=(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator!=(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y)
{ return !(x == y); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y)
{ return y < x; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<=(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<=(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y)
{ return !(y < x); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>=(const flat_map<Key,T,Pred,A>& x,
- const flat_map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>=(const flat_map<Key,T,Compare,Allocator>& x,
+ const flat_map<Key,T,Compare,Allocator>& y)
{ return !(x < y); }
-template <class Key, class T, class Pred, class A>
-inline void swap(flat_map<Key,T,Pred,A>& x,
- flat_map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline void swap(flat_map<Key,T,Compare,Allocator>& x,
+ flat_map<Key,T,Compare,Allocator>& y)
{ x.swap(y); }
/// @cond
@@ -917,25 +903,25 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class K, class T, class C, class A>
-struct has_trivial_destructor_after_move<boost::container::flat_map<K, T, C, A> >
+template <class K, class T, class C, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::flat_map<K, T, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value && has_trivial_destructor<C>::value;
};
*/
namespace container {
// Forward declaration of operators < and ==, needed for friend declaration.
-template <class Key, class T, class Pred, class A>
+template <class Key, class T, class Compare, class Allocator>
class flat_multimap;
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y);
-
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y);
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y);
/// @endcond
//! A flat_multimap is a kind of associative container that supports equivalent keys
@@ -948,14 +934,14 @@
//! flat_multimap<Key,T> the key_type is Key and the value_type is std::pair<Key,T>
//! (unlike std::multimap<Key, T> which value_type is std::pair<<b>const</b> Key, T>).
//!
-//! Pred is the ordering function for Keys (e.g. <i>std::less<Key></i>).
+//! Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
//!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
//! (e.g. <i>allocator< std::pair<Key, T> ></i>).
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< Key, T> > >
+template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< Key, T> > >
#else
-template <class Key, class T, class Pred, class A>
+template <class Key, class T, class Compare, class Allocator>
#endif
class flat_multimap
{
@@ -965,41 +951,32 @@
typedef container_detail::flat_tree<Key,
std::pair<Key, T>,
container_detail::select1st< std::pair<Key, T> >,
- Pred,
- A> tree_t;
+ Compare,
+ Allocator> tree_t;
//This is the real tree stored here. It's based on a movable pair
typedef container_detail::flat_tree<Key,
container_detail::pair<Key, T>,
container_detail::select1st<container_detail::pair<Key, T> >,
- Pred,
- typename allocator_traits<A>::template portable_rebind_alloc
+ Compare,
+ typename allocator_traits<Allocator>::template portable_rebind_alloc
<container_detail::pair<Key, T> >::type> impl_tree_t;
impl_tree_t m_flat_tree; // flat tree representing flat_map
typedef typename impl_tree_t::value_type impl_value_type;
- typedef typename impl_tree_t::pointer impl_pointer;
- typedef typename impl_tree_t::const_pointer impl_const_pointer;
- typedef typename impl_tree_t::reference impl_reference;
- typedef typename impl_tree_t::const_reference impl_const_reference;
- typedef typename impl_tree_t::value_compare impl_value_compare;
- typedef typename impl_tree_t::iterator impl_iterator;
typedef typename impl_tree_t::const_iterator impl_const_iterator;
- typedef typename impl_tree_t::reverse_iterator impl_reverse_iterator;
- typedef typename impl_tree_t::const_reverse_iterator impl_const_reverse_iterator;
typedef typename impl_tree_t::allocator_type impl_allocator_type;
- typedef allocator_traits<A> allocator_traits_type;
typedef container_detail::flat_tree_value_compare
- < Pred
+ < Compare
, container_detail::select1st< std::pair<Key, T> >
- , std::pair<Key, T> > value_compare_impl;
+ , std::pair<Key, T> > value_compare_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::iterator iterator_impl;
+ <typename allocator_traits<Allocator>::pointer>::iterator iterator_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::const_iterator const_iterator_impl;
+ <typename allocator_traits<Allocator>::pointer>::const_iterator const_iterator_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::reverse_iterator reverse_iterator_impl;
+ <typename allocator_traits<Allocator>::pointer>::reverse_iterator reverse_iterator_impl;
typedef typename container_detail::get_flat_tree_iterators
- <typename allocator_traits<A>::pointer>::const_reverse_iterator const_reverse_iterator_impl;
+ <typename allocator_traits<Allocator>::pointer>::const_reverse_iterator const_reverse_iterator_impl;
/// @endcond
public:
@@ -1009,24 +986,24 @@
// types
//
//////////////////////////////////////////////
- typedef Key key_type;
- typedef T mapped_type;
- typedef typename std::pair<key_type, mapped_type> value_type;
- typedef typename boost::container::allocator_traits<A>::pointer pointer;
- typedef typename boost::container::allocator_traits<A>::const_pointer const_pointer;
- typedef typename boost::container::allocator_traits<A>::reference reference;
- typedef typename boost::container::allocator_traits<A>::const_reference const_reference;
- typedef typename boost::container::allocator_traits<A>::size_type size_type;
- typedef typename boost::container::allocator_traits<A>::difference_type difference_type;
- typedef A allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(A) stored_allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
- typedef Pred key_compare;
- typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
- typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
- typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl) const_reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type;
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef std::pair<Key, T> value_type;
+ typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(Allocator) stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
+ typedef Compare key_compare;
+ typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(reverse_iterator_impl) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(const_reverse_iterator_impl) const_reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(impl_value_type) movable_value_type;
//////////////////////////////////////////////
//
@@ -1044,7 +1021,7 @@
//! object and allocator.
//!
//! <b>Complexity</b>: Constant.
- explicit flat_multimap(const Pred& comp,
+ explicit flat_multimap(const Compare& comp,
const allocator_type& a = allocator_type())
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a)) { }
@@ -1055,7 +1032,7 @@
//! comp and otherwise N logN, where N is last - first.
template <class InputIterator>
flat_multimap(InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_flat_tree(false, first, last, comp, container_detail::force<impl_allocator_type>(a))
{}
@@ -1071,7 +1048,7 @@
//! <b>Note</b>: Non-standard extension.
template <class InputIterator>
flat_multimap(ordered_range_t, InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_flat_tree(ordered_range, first, last, comp, a)
{}
@@ -1595,7 +1572,7 @@
iterator lower_bound(const key_type& x)
{ return container_detail::force_copy<iterator>(m_flat_tree.lower_bound(x)); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key
//! not less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1609,7 +1586,7 @@
iterator upper_bound(const key_type& x)
{return container_detail::force_copy<iterator>(m_flat_tree.upper_bound(x)); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key
//! not less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1625,8 +1602,7 @@
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<const_iterator,const_iterator>
- equal_range(const key_type& x) const
+ std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
{ return container_detail::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
/// @cond
@@ -1640,38 +1616,38 @@
/// @endcond
};
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y)
{ return x.m_flat_tree == y.m_flat_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y)
{ return x.m_flat_tree < y.m_flat_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator!=(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator!=(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y)
{ return !(x == y); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y)
{ return y < x; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<=(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<=(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y)
{ return !(y < x); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>=(const flat_multimap<Key,T,Pred,A>& x,
- const flat_multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>=(const flat_multimap<Key,T,Compare,Allocator>& x,
+ const flat_multimap<Key,T,Compare,Allocator>& y)
{ return !(x < y); }
-template <class Key, class T, class Pred, class A>
-inline void swap(flat_multimap<Key,T,Pred,A>& x, flat_multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline void swap(flat_multimap<Key,T,Compare,Allocator>& x, flat_multimap<Key,T,Compare,Allocator>& y)
{ x.swap(y); }
}}
@@ -1682,10 +1658,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class K, class T, class C, class A>
-struct has_trivial_destructor_after_move< boost::container::flat_multimap<K, T, C, A> >
+template <class K, class T, class C, class Allocator>
+struct has_trivial_destructor_after_move< boost::container::flat_multimap<K, T, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value && has_trivial_destructor<C>::value;
};
*/
} //namespace boost {
Modified: trunk/boost/container/flat_set.hpp
==============================================================================
--- trunk/boost/container/flat_set.hpp (original)
+++ trunk/boost/container/flat_set.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -24,33 +24,30 @@
#include <memory>
#include <boost/container/detail/flat_tree.hpp>
#include <boost/container/detail/mpl.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/move/move.hpp>
+#include <boost/move/move_helpers.hpp>
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-namespace boost {
-namespace container {
-#else
namespace boost {
namespace container {
-#endif
/// @cond
// Forward declarations of operators < and ==, needed for friend declaration.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class Pred = std::less<T>, class A = std::allocator<T> >
+template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
#else
-template <class T, class Pred, class A>
+template <class Key, class Compare, class Allocator>
#endif
class flat_set;
-template <class T, class Pred, class A>
-inline bool operator==(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y);
-
-template <class T, class Pred, class A>
-inline bool operator<(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y);
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y);
/// @endcond
//! flat_set is a Sorted Associative Container that stores objects of type Key.
@@ -65,40 +62,48 @@
//! Erasing an element of a flat_set invalidates iterators and references
//! pointing to elements that come after (their keys are bigger) the erased element.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class Pred = std::less<T>, class A = std::allocator<T> >
+template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
#else
-template <class T, class Pred, class A>
+template <class Key, class Compare, class Allocator>
#endif
class flat_set
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(flat_set)
- typedef container_detail::flat_tree<T, T, container_detail::identity<T>, Pred, A> tree_t;
+ typedef container_detail::flat_tree<Key, Key, container_detail::identity<Key>, Compare, Allocator> tree_t;
tree_t m_flat_tree; // flat tree representing flat_set
- typedef typename container_detail::
- move_const_ref_type<T>::type insert_const_ref_type;
/// @endcond
public:
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+ typedef Key key_type;
+ typedef Key value_type;
+ typedef Compare key_compare;
+ typedef Compare value_compare;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator) iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
- // typedefs:
- typedef typename tree_t::key_type key_type;
- typedef typename tree_t::value_type value_type;
- typedef typename tree_t::pointer pointer;
- typedef typename tree_t::const_pointer const_pointer;
- typedef typename tree_t::reference reference;
- typedef typename tree_t::const_reference const_reference;
- typedef typename tree_t::key_compare key_compare;
- typedef typename tree_t::value_compare value_compare;
- typedef typename tree_t::iterator iterator;
- typedef typename tree_t::const_iterator const_iterator;
- typedef typename tree_t::reverse_iterator reverse_iterator;
- typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
- typedef typename tree_t::size_type size_type;
- typedef typename tree_t::difference_type difference_type;
- typedef typename tree_t::allocator_type allocator_type;
- typedef typename tree_t::stored_allocator_type stored_allocator_type;
+ public:
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
//! <b>Effects</b>: Default constructs an empty flat_set.
//!
@@ -111,7 +116,7 @@
//! comparison object and allocator.
//!
//! <b>Complexity</b>: Constant.
- explicit flat_set(const Pred& comp,
+ explicit flat_set(const Compare& comp,
const allocator_type& a = allocator_type())
: m_flat_tree(comp, a)
{}
@@ -123,7 +128,7 @@
//! comp and otherwise N logN, where N is last - first.
template <class InputIterator>
flat_set(InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_flat_tree(true, first, last, comp, a)
{}
@@ -140,7 +145,7 @@
//! <b>Note</b>: Non-standard extension.
template <class InputIterator>
flat_set(ordered_unique_range_t, InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_flat_tree(ordered_range, first, last, comp, a)
{}
@@ -188,20 +193,6 @@
flat_set& operator=(BOOST_RV_REF(flat_set) mx)
{ m_flat_tree = boost::move(mx.m_flat_tree); return *this; }
- //! <b>Effects</b>: Returns the comparison object out
- //! of which a was constructed.
- //!
- //! <b>Complexity</b>: Constant.
- key_compare key_comp() const
- { return m_flat_tree.key_comp(); }
-
- //! <b>Effects</b>: Returns an object of value_compare constructed out
- //! of the comparison object.
- //!
- //! <b>Complexity</b>: Constant.
- value_compare value_comp() const
- { return m_flat_tree.key_comp(); }
-
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
//!
@@ -229,6 +220,12 @@
const stored_allocator_type &get_stored_allocator() const
{ return m_flat_tree.get_stored_allocator(); }
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
//!
//! <b>Throws</b>: Nothing.
@@ -245,14 +242,6 @@
const_iterator begin() const
{ return m_flat_tree.begin(); }
- //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_iterator cbegin() const
- { return m_flat_tree.cbegin(); }
-
//! <b>Effects</b>: Returns an iterator to the end of the container.
//!
//! <b>Throws</b>: Nothing.
@@ -269,14 +258,6 @@
const_iterator end() const
{ return m_flat_tree.end(); }
- //! <b>Effects</b>: Returns a const_iterator to the end of the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_iterator cend() const
- { return m_flat_tree.cend(); }
-
//! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
//! of the reversed container.
//!
@@ -295,32 +276,48 @@
const_reverse_iterator rbegin() const
{ return m_flat_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
//! of the reversed container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crbegin() const
- { return m_flat_tree.crbegin(); }
+ reverse_iterator rend()
+ { return m_flat_tree.rend(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
//! of the reversed container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend()
+ const_reverse_iterator rend() const
{ return m_flat_tree.rend(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_iterator cbegin() const
+ { return m_flat_tree.cbegin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator to the end of the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_iterator cend() const
+ { return m_flat_tree.cend(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
//! of the reversed container.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
- { return m_flat_tree.rend(); }
+ const_reverse_iterator crbegin() const
+ { return m_flat_tree.crbegin(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
//! of the reversed container.
@@ -331,6 +328,13 @@
const_reverse_iterator crend() const
{ return m_flat_tree.crend(); }
+
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns true if the container contains no elements.
//!
//! <b>Throws</b>: Nothing.
@@ -355,15 +359,46 @@
size_type max_size() const
{ return m_flat_tree.max_size(); }
- //! <b>Effects</b>: Swaps the contents of *this and x.
+ //! <b>Effects</b>: Number of elements for which memory has been allocated.
+ //! capacity() is always greater than or equal to size().
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- void swap(flat_set& x)
- { m_flat_tree.swap(x.m_flat_tree); }
+ size_type capacity() const
+ { return m_flat_tree.capacity(); }
- //! <b>Effects</b>: Inserts x if and only if there is no element in the container
+ //! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
+ //! effect. Otherwise, it is a request for allocation of additional memory.
+ //! If the request is successful, then capacity() is greater than or equal to
+ //! n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
+ //!
+ //! <b>Throws</b>: If memory allocation allocation throws or Key's copy constructor throws.
+ //!
+ //! <b>Note</b>: If capacity() is less than "count", iterators and references to
+ //! to values might be invalidated.
+ void reserve(size_type count)
+ { m_flat_tree.reserve(count); }
+
+ //! <b>Effects</b>: Tries to deallocate the excess of memory created
+ // with previous allocations. The size of the vector is unchanged
+ //!
+ //! <b>Throws</b>: If memory allocation throws, or Key's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to size().
+ void shrink_to_fit()
+ { m_flat_tree.shrink_to_fit(); }
+
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
+
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Inserts an object x of type Key constructed with
+ //! std::forward<Args>(args)... if and only if there is no element in the container
//! with key equivalent to the key of x.
//!
//! <b>Returns</b>: The bool component of the returned pair is true if and only
@@ -374,17 +409,57 @@
//! to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- std::pair<iterator, bool> insert(insert_const_ref_type x)
- { return priv_insert(x); }
+ template <class... Args>
+ std::pair<iterator,bool> emplace(Args&&... args)
+ { return m_flat_tree.emplace_unique(boost::forward<Args>(args)...); }
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- std::pair<iterator, bool> insert(T &x)
- { return this->insert(const_cast<const T &>(x)); }
-
- template<class U>
- std::pair<iterator, bool> insert(const U &u, typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(u); }
- #endif
+ //! <b>Effects</b>: Inserts an object of type Key constructed with
+ //! std::forward<Args>(args)... in the container if and only if there is
+ //! no element in the container with key equivalent to the key of x.
+ //! p is a hint pointing to where the insert should start to search.
+ //!
+ //! <b>Returns</b>: An iterator pointing to the element with key equivalent
+ //! to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
+ //! right before p) plus insertion linear to the elements with bigger keys than x.
+ //!
+ //! <b>Note</b>: If an element is inserted it might invalidate elements.
+ template <class... Args>
+ iterator emplace_hint(const_iterator hint, Args&&... args)
+ { return m_flat_tree.emplace_hint_unique(hint, boost::forward<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, >) \
+ std::pair<iterator,bool> emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_flat_tree.emplace_unique(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(const_iterator hint \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_flat_tree.emplace_hint_unique \
+ (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \
+ //!
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+
+ #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts x if and only if there is no element in the container
+ //! with key equivalent to the key of x.
+ //!
+ //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! if the insertion takes place, and the iterator component of the pair
+ //! points to the element with key equivalent to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic search time plus linear insertion
+ //! to the elements with bigger keys than x.
+ //!
+ //! <b>Note</b>: If an element is inserted it might invalidate elements.
+ std::pair<iterator, bool> insert(const value_type &x);
//! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and
//! only if there is no element in the container with key equivalent to the key of x.
@@ -397,9 +472,15 @@
//! to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
- { return m_flat_tree.insert_unique(boost::move(x)); }
+ std::pair<iterator, bool> insert(value_type &&x);
+ #else
+ private:
+ typedef std::pair<iterator, bool> insert_return_pair;
+ public:
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
+ #endif
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
//! no element in the container with key equivalent to the key of x.
//! p is a hint pointing to where the insert should start to search.
@@ -411,17 +492,7 @@
//! right before p) plus insertion linear to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- iterator insert(const_iterator p, insert_const_ref_type x)
- { return priv_insert(p, x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(const_iterator position, T &x)
- { return this->insert(position, const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(position, u); }
- #endif
+ iterator insert(const_iterator p, const value_type &x);
//! <b>Effects</b>: Inserts an element move constructed from x in the container.
//! p is a hint pointing to where the insert should start to search.
@@ -432,8 +503,10 @@
//! right before p) plus insertion linear to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
- { return m_flat_tree.insert_unique(position, boost::move(x)); }
+ iterator insert(const_iterator position, value_type &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+ #endif
//! <b>Requires</b>: first, last are not iterators into *this.
//!
@@ -463,58 +536,6 @@
void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
{ m_flat_tree.insert_unique(ordered_unique_range, first, last); }
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- //! <b>Effects</b>: Inserts an object x of type T constructed with
- //! std::forward<Args>(args)... if and only if there is no element in the container
- //! with key equivalent to the key of x.
- //!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
- //! if the insertion takes place, and the iterator component of the pair
- //! points to the element with key equivalent to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic search time plus linear insertion
- //! to the elements with bigger keys than x.
- //!
- //! <b>Note</b>: If an element is inserted it might invalidate elements.
- template <class... Args>
- std::pair<iterator,bool> emplace(Args&&... args)
- { return m_flat_tree.emplace_unique(boost::forward<Args>(args)...); }
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the container if and only if there is
- //! no element in the container with key equivalent to the key of x.
- //! p is a hint pointing to where the insert should start to search.
- //!
- //! <b>Returns</b>: An iterator pointing to the element with key equivalent
- //! to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
- //! right before p) plus insertion linear to the elements with bigger keys than x.
- //!
- //! <b>Note</b>: If an element is inserted it might invalidate elements.
- template <class... Args>
- iterator emplace_hint(const_iterator hint, Args&&... args)
- { return m_flat_tree.emplace_hint_unique(hint, boost::forward<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, >) \
- std::pair<iterator,bool> emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_flat_tree.emplace_unique(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(const_iterator hint \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_flat_tree.emplace_hint_unique \
- (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
@@ -548,6 +569,14 @@
iterator erase(const_iterator first, const_iterator last)
{ return m_flat_tree.erase(first, last); }
+ //! <b>Effects</b>: Swaps the contents of *this and x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ void swap(flat_set& x)
+ { m_flat_tree.swap(x.m_flat_tree); }
+
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
@@ -556,14 +585,31 @@
void clear()
{ m_flat_tree.clear(); }
- //! <b>Effects</b>: Tries to deallocate the excess of memory created
- // with previous allocations. The size of the vector is unchanged
+ //////////////////////////////////////////////
+ //
+ // observers
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns the comparison object out
+ //! of which a was constructed.
//!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //! <b>Complexity</b>: Constant.
+ key_compare key_comp() const
+ { return m_flat_tree.key_comp(); }
+
+ //! <b>Effects</b>: Returns an object of value_compare constructed out
+ //! of the comparison object.
//!
- //! <b>Complexity</b>: Linear to size().
- void shrink_to_fit()
- { m_flat_tree.shrink_to_fit(); }
+ //! <b>Complexity</b>: Constant.
+ value_compare value_comp() const
+ { return m_flat_tree.key_comp(); }
+
+ //////////////////////////////////////////////
+ //
+ // set operations
+ //
+ //////////////////////////////////////////////
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
@@ -572,7 +618,7 @@
iterator find(const key_type& x)
{ return m_flat_tree.find(x); }
- //! <b>Returns</b>: A const_iterator pointing to an element with the key
+ //! <b>Returns</b>: Allocator const_iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.s
@@ -592,7 +638,7 @@
iterator lower_bound(const key_type& x)
{ return m_flat_tree.lower_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -606,7 +652,7 @@
iterator upper_bound(const key_type& x)
{ return m_flat_tree.upper_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -616,38 +662,15 @@
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<const_iterator, const_iterator>
- equal_range(const key_type& x) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
{ return m_flat_tree.equal_range(x); }
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<iterator,iterator>
- equal_range(const key_type& x)
+ std::pair<iterator,iterator> equal_range(const key_type& x)
{ return m_flat_tree.equal_range(x); }
- //! <b>Effects</b>: Number of elements for which memory has been allocated.
- //! capacity() is always greater than or equal to size().
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- size_type capacity() const
- { return m_flat_tree.capacity(); }
-
- //! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
- //! effect. Otherwise, it is a request for allocation of additional memory.
- //! If the request is successful, then capacity() is greater than or equal to
- //! n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
- //!
- //! <b>Throws</b>: If memory allocation allocation throws or T's copy constructor throws.
- //!
- //! <b>Note</b>: If capacity() is less than "count", iterators and references to
- //! to values might be invalidated.
- void reserve(size_type count)
- { m_flat_tree.reserve(count); }
-
/// @cond
template <class K1, class C1, class A1>
friend bool operator== (const flat_set<K1,C1,A1>&, const flat_set<K1,C1,A1>&);
@@ -656,46 +679,48 @@
friend bool operator< (const flat_set<K1,C1,A1>&, const flat_set<K1,C1,A1>&);
private:
- std::pair<iterator, bool> priv_insert(const T &x)
- { return m_flat_tree.insert_unique(x); }
-
- iterator priv_insert(const_iterator p, const T &x)
- { return m_flat_tree.insert_unique(p, x); }
+ template<class KeyType>
+ std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x)
+ { return m_flat_tree.insert_unique(::boost::forward<KeyType>(x)); }
+
+ template<class KeyType>
+ iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+ { return m_flat_tree.insert_unique(p, ::boost::forward<KeyType>(x)); }
/// @endcond
};
-template <class T, class Pred, class A>
-inline bool operator==(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y)
{ return x.m_flat_tree == y.m_flat_tree; }
-template <class T, class Pred, class A>
-inline bool operator<(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y)
{ return x.m_flat_tree < y.m_flat_tree; }
-template <class T, class Pred, class A>
-inline bool operator!=(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator!=(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y)
{ return !(x == y); }
-template <class T, class Pred, class A>
-inline bool operator>(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y)
{ return y < x; }
-template <class T, class Pred, class A>
-inline bool operator<=(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<=(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y)
{ return !(y < x); }
-template <class T, class Pred, class A>
-inline bool operator>=(const flat_set<T,Pred,A>& x,
- const flat_set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>=(const flat_set<Key,Compare,Allocator>& x,
+ const flat_set<Key,Compare,Allocator>& y)
{ return !(x < y); }
-template <class T, class Pred, class A>
-inline void swap(flat_set<T,Pred,A>& x, flat_set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline void swap(flat_set<Key,Compare,Allocator>& x, flat_set<Key,Compare,Allocator>& y)
{ x.swap(y); }
/// @cond
@@ -704,10 +729,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class C, class A>
-struct has_trivial_destructor_after_move<boost::container::flat_set<T, C, A> >
+template <class Key, class C, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::flat_set<Key, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value &&has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value &&has_trivial_destructor<C>::value;
};
*/
namespace container {
@@ -715,19 +740,19 @@
// Forward declaration of operators < and ==, needed for friend declaration.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class Pred = std::less<T>, class A = std::allocator<T> >
+template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
#else
-template <class T, class Pred, class A>
+template <class Key, class Compare, class Allocator>
#endif
class flat_multiset;
-template <class T, class Pred, class A>
-inline bool operator==(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y);
-
-template <class T, class Pred, class A>
-inline bool operator<(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y);
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y);
/// @endcond
//! flat_multiset is a Sorted Associative Container that stores objects of type Key.
@@ -742,39 +767,41 @@
//! Erasing an element of a flat_multiset invalidates iterators and references
//! pointing to elements that come after (their keys are equal or bigger) the erased element.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class Pred = std::less<T>, class A = std::allocator<T> >
+template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
#else
-template <class T, class Pred, class A>
+template <class Key, class Compare, class Allocator>
#endif
class flat_multiset
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(flat_multiset)
- typedef container_detail::flat_tree<T, T, container_detail::identity<T>, Pred, A> tree_t;
+ typedef container_detail::flat_tree<Key, Key, container_detail::identity<Key>, Compare, Allocator> tree_t;
tree_t m_flat_tree; // flat tree representing flat_multiset
- typedef typename container_detail::
- move_const_ref_type<T>::type insert_const_ref_type;
/// @endcond
public:
- // typedefs:
- typedef typename tree_t::key_type key_type;
- typedef typename tree_t::value_type value_type;
- typedef typename tree_t::pointer pointer;
- typedef typename tree_t::const_pointer const_pointer;
- typedef typename tree_t::reference reference;
- typedef typename tree_t::const_reference const_reference;
- typedef typename tree_t::key_compare key_compare;
- typedef typename tree_t::value_compare value_compare;
- typedef typename tree_t::iterator iterator;
- typedef typename tree_t::const_iterator const_iterator;
- typedef typename tree_t::reverse_iterator reverse_iterator;
- typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
- typedef typename tree_t::size_type size_type;
- typedef typename tree_t::difference_type difference_type;
- typedef typename tree_t::allocator_type allocator_type;
- typedef typename tree_t::stored_allocator_type stored_allocator_type;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+ typedef Key key_type;
+ typedef Key value_type;
+ typedef Compare key_compare;
+ typedef Compare value_compare;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator) iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
//! <b>Effects</b>: Default constructs an empty flat_multiset.
//!
@@ -783,13 +810,13 @@
: m_flat_tree()
{}
- explicit flat_multiset(const Pred& comp,
+ explicit flat_multiset(const Compare& comp,
const allocator_type& a = allocator_type())
: m_flat_tree(comp, a) {}
template <class InputIterator>
flat_multiset(InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_flat_tree(false, first, last, comp, a)
{}
@@ -805,7 +832,7 @@
//! <b>Note</b>: Non-standard extension.
template <class InputIterator>
flat_multiset(ordered_range_t, InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_flat_tree(ordered_range, first, last, comp, a)
{}
@@ -853,20 +880,6 @@
flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx)
{ m_flat_tree = boost::move(mx.m_flat_tree); return *this; }
- //! <b>Effects</b>: Returns the comparison object out
- //! of which a was constructed.
- //!
- //! <b>Complexity</b>: Constant.
- key_compare key_comp() const
- { return m_flat_tree.key_comp(); }
-
- //! <b>Effects</b>: Returns an object of value_compare constructed out
- //! of the comparison object.
- //!
- //! <b>Complexity</b>: Constant.
- value_compare value_comp() const
- { return m_flat_tree.key_comp(); }
-
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
//!
@@ -996,6 +1009,12 @@
const_reverse_iterator crend() const
{ return m_flat_tree.crend(); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns true if the container contains no elements.
//!
//! <b>Throws</b>: Nothing.
@@ -1020,32 +1039,98 @@
size_type max_size() const
{ return m_flat_tree.max_size(); }
- //! <b>Effects</b>: Swaps the contents of *this and x.
+ //! <b>Effects</b>: Number of elements for which memory has been allocated.
+ //! capacity() is always greater than or equal to size().
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- void swap(flat_multiset& x)
- { m_flat_tree.swap(x.m_flat_tree); }
+ size_type capacity() const
+ { return m_flat_tree.capacity(); }
- //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
+ //! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
+ //! effect. Otherwise, it is a request for allocation of additional memory.
+ //! If the request is successful, then capacity() is greater than or equal to
+ //! n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
+ //!
+ //! <b>Throws</b>: If memory allocation allocation throws or Key's copy constructor throws.
+ //!
+ //! <b>Note</b>: If capacity() is less than "count", iterators and references to
+ //! to values might be invalidated.
+ void reserve(size_type count)
+ { m_flat_tree.reserve(count); }
+
+ //! <b>Effects</b>: Tries to deallocate the excess of memory created
+ // with previous allocations. The size of the vector is unchanged
+ //!
+ //! <b>Throws</b>: If memory allocation throws, or Key's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to size().
+ void shrink_to_fit()
+ { m_flat_tree.shrink_to_fit(); }
+
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
+
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Inserts an object of type Key constructed with
+ //! std::forward<Args>(args)... and returns the iterator pointing to the
//! newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic search time plus linear insertion
//! to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- iterator insert(insert_const_ref_type x)
- { return priv_insert(x); }
+ template <class... Args>
+ iterator emplace(Args&&... args)
+ { return m_flat_tree.emplace_equal(boost::forward<Args>(args)...); }
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(T &x)
- { return this->insert(const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert(const U &u, typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(u); }
- #endif
+ //! <b>Effects</b>: Inserts an object of type Key constructed with
+ //! std::forward<Args>(args)... in the container.
+ //! p is a hint pointing to where the insert should start to search.
+ //!
+ //! <b>Returns</b>: An iterator pointing to the element with key equivalent
+ //! to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
+ //! right before p) plus insertion linear to the elements with bigger keys than x.
+ //!
+ //! <b>Note</b>: If an element is inserted it might invalidate elements.
+ template <class... Args>
+ iterator emplace_hint(const_iterator hint, Args&&... args)
+ { return m_flat_tree.emplace_hint_equal(hint, boost::forward<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, >) \
+ iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_flat_tree.emplace_equal(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(const_iterator hint \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_flat_tree.emplace_hint_equal \
+ (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \
+ //!
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+
+ #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
+ //! newly inserted element.
+ //!
+ //! <b>Complexity</b>: Logarithmic search time plus linear insertion
+ //! to the elements with bigger keys than x.
+ //!
+ //! <b>Note</b>: If an element is inserted it might invalidate elements.
+ iterator insert(const value_type &x);
//! <b>Effects</b>: Inserts a new value_type move constructed from x
//! and returns the iterator pointing to the newly inserted element.
@@ -1054,9 +1139,12 @@
//! to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- iterator insert(BOOST_RV_REF(value_type) x)
- { return m_flat_tree.insert_equal(boost::move(x)); }
+ iterator insert(value_type &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
+ #endif
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts a copy of x in the container.
//! p is a hint pointing to where the insert should start to search.
//!
@@ -1067,18 +1155,7 @@
//! right before p) plus insertion linear to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- iterator insert(const_iterator p, insert_const_ref_type x)
- { return priv_insert(p, x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(const_iterator position, T &x)
- { return this->insert(position, const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert( const_iterator position, const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(position, u); }
- #endif
+ iterator insert(const_iterator p, const value_type &x);
//! <b>Effects</b>: Inserts a new value move constructed from x in the container.
//! p is a hint pointing to where the insert should start to search.
@@ -1090,8 +1167,10 @@
//! right before p) plus insertion linear to the elements with bigger keys than x.
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
- iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
- { return m_flat_tree.insert_equal(position, boost::move(x)); }
+ iterator insert(const_iterator position, value_type &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+ #endif
//! <b>Requires</b>: first, last are not iterators into *this.
//!
@@ -1119,53 +1198,6 @@
void insert(ordered_range_t, InputIterator first, InputIterator last)
{ m_flat_tree.insert_equal(ordered_range, first, last); }
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... and returns the iterator pointing to the
- //! newly inserted element.
- //!
- //! <b>Complexity</b>: Logarithmic search time plus linear insertion
- //! to the elements with bigger keys than x.
- //!
- //! <b>Note</b>: If an element is inserted it might invalidate elements.
- template <class... Args>
- iterator emplace(Args&&... args)
- { return m_flat_tree.emplace_equal(boost::forward<Args>(args)...); }
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the container.
- //! p is a hint pointing to where the insert should start to search.
- //!
- //! <b>Returns</b>: An iterator pointing to the element with key equivalent
- //! to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
- //! right before p) plus insertion linear to the elements with bigger keys than x.
- //!
- //! <b>Note</b>: If an element is inserted it might invalidate elements.
- template <class... Args>
- iterator emplace_hint(const_iterator hint, Args&&... args)
- { return m_flat_tree.emplace_hint_equal(hint, boost::forward<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, >) \
- iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_flat_tree.emplace_equal(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(const_iterator hint \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_flat_tree.emplace_hint_equal \
- (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
@@ -1199,6 +1231,14 @@
iterator erase(const_iterator first, const_iterator last)
{ return m_flat_tree.erase(first, last); }
+ //! <b>Effects</b>: Swaps the contents of *this and x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ void swap(flat_multiset& x)
+ { m_flat_tree.swap(x.m_flat_tree); }
+
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
@@ -1207,14 +1247,31 @@
void clear()
{ m_flat_tree.clear(); }
- //! <b>Effects</b>: Tries to deallocate the excess of memory created
- // with previous allocations. The size of the vector is unchanged
+ //////////////////////////////////////////////
+ //
+ // observers
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns the comparison object out
+ //! of which a was constructed.
//!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //! <b>Complexity</b>: Constant.
+ key_compare key_comp() const
+ { return m_flat_tree.key_comp(); }
+
+ //! <b>Effects</b>: Returns an object of value_compare constructed out
+ //! of the comparison object.
//!
- //! <b>Complexity</b>: Linear to size().
- void shrink_to_fit()
- { m_flat_tree.shrink_to_fit(); }
+ //! <b>Complexity</b>: Constant.
+ value_compare value_comp() const
+ { return m_flat_tree.key_comp(); }
+
+ //////////////////////////////////////////////
+ //
+ // set operations
+ //
+ //////////////////////////////////////////////
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
@@ -1223,7 +1280,7 @@
iterator find(const key_type& x)
{ return m_flat_tree.find(x); }
- //! <b>Returns</b>: A const_iterator pointing to an element with the key
+ //! <b>Returns</b>: Allocator const_iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.s
@@ -1243,7 +1300,7 @@
iterator lower_bound(const key_type& x)
{ return m_flat_tree.lower_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1257,7 +1314,7 @@
iterator upper_bound(const key_type& x)
{ return m_flat_tree.upper_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1267,38 +1324,15 @@
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<const_iterator, const_iterator>
- equal_range(const key_type& x) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
{ return m_flat_tree.equal_range(x); }
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<iterator,iterator>
- equal_range(const key_type& x)
+ std::pair<iterator,iterator> equal_range(const key_type& x)
{ return m_flat_tree.equal_range(x); }
- //! <b>Effects</b>: Number of elements for which memory has been allocated.
- //! capacity() is always greater than or equal to size().
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- size_type capacity() const
- { return m_flat_tree.capacity(); }
-
- //! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
- //! effect. Otherwise, it is a request for allocation of additional memory.
- //! If the request is successful, then capacity() is greater than or equal to
- //! n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
- //!
- //! <b>Throws</b>: If memory allocation allocation throws or T's copy constructor throws.
- //!
- //! <b>Note</b>: If capacity() is less than "count", iterators and references to
- //! to values might be invalidated.
- void reserve(size_type count)
- { m_flat_tree.reserve(count); }
-
/// @cond
template <class K1, class C1, class A1>
friend bool operator== (const flat_multiset<K1,C1,A1>&,
@@ -1307,46 +1341,48 @@
friend bool operator< (const flat_multiset<K1,C1,A1>&,
const flat_multiset<K1,C1,A1>&);
private:
- iterator priv_insert(const T &x)
- { return m_flat_tree.insert_equal(x); }
-
- iterator priv_insert(const_iterator p, const T &x)
- { return m_flat_tree.insert_equal(p, x); }
+ template <class KeyType>
+ iterator priv_insert(BOOST_FWD_REF(KeyType) x)
+ { return m_flat_tree.insert_equal(::boost::forward<KeyType>(x)); }
+
+ template <class KeyType>
+ iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+ { return m_flat_tree.insert_equal(p, ::boost::forward<KeyType>(x)); }
/// @endcond
};
-template <class T, class Pred, class A>
-inline bool operator==(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y)
{ return x.m_flat_tree == y.m_flat_tree; }
-template <class T, class Pred, class A>
-inline bool operator<(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y)
{ return x.m_flat_tree < y.m_flat_tree; }
-template <class T, class Pred, class A>
-inline bool operator!=(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator!=(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y)
{ return !(x == y); }
-template <class T, class Pred, class A>
-inline bool operator>(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y)
{ return y < x; }
-template <class T, class Pred, class A>
-inline bool operator<=(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<=(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y)
{ return !(y < x); }
-template <class T, class Pred, class A>
-inline bool operator>=(const flat_multiset<T,Pred,A>& x,
- const flat_multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>=(const flat_multiset<Key,Compare,Allocator>& x,
+ const flat_multiset<Key,Compare,Allocator>& y)
{ return !(x < y); }
-template <class T, class Pred, class A>
-inline void swap(flat_multiset<T,Pred,A>& x, flat_multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline void swap(flat_multiset<Key,Compare,Allocator>& x, flat_multiset<Key,Compare,Allocator>& y)
{ x.swap(y); }
/// @cond
@@ -1355,10 +1391,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class C, class A>
-struct has_trivial_destructor_after_move<boost::container::flat_multiset<T, C, A> >
+template <class Key, class C, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::flat_multiset<Key, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value && has_trivial_destructor<C>::value;
};
*/
namespace container {
Modified: trunk/boost/container/list.hpp
==============================================================================
--- trunk/boost/container/list.hpp (original)
+++ trunk/boost/container/list.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -7,8 +7,8 @@
// See http://www.boost.org/libs/container for documentation.
//
-#ifndef BOOST_CONTAINER_LIST_HPP_
-#define BOOST_CONTAINER_LIST_HPP_
+#ifndef BOOST_CONTAINER_LIST_HPP
+#define BOOST_CONTAINER_LIST_HPP
#if (defined _MSC_VER) && (_MSC_VER >= 1200)
# pragma once
@@ -43,13 +43,8 @@
#include <algorithm>
#include <stdexcept>
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
namespace boost {
namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
/// @cond
namespace container_detail {
@@ -73,10 +68,10 @@
T m_data;
};
-template<class A>
+template<class Allocator>
struct intrusive_list_type
{
- typedef boost::container::allocator_traits<A> allocator_traits_type;
+ typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
typedef typename allocator_traits_type::value_type value_type;
typedef typename boost::intrusive::pointer_traits
<typename allocator_traits_type::pointer>::template
@@ -213,27 +208,27 @@
//! not be invalidated or made to point to different elements unless that invalidation
//! or mutation is explicit.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class A = std::allocator<T> >
+template <class T, class Allocator = std::allocator<T> >
#else
-template <class T, class A>
+template <class T, class Allocator>
#endif
class list
: protected container_detail::node_alloc_holder
- <A, typename container_detail::intrusive_list_type<A>::type>
+ <Allocator, typename container_detail::intrusive_list_type<Allocator>::type>
{
/// @cond
typedef typename
- container_detail::intrusive_list_type<A>::type Icont;
- typedef container_detail::node_alloc_holder<A, Icont> AllocHolder;
- typedef typename AllocHolder::NodePtr NodePtr;
- typedef typename AllocHolder::NodeAlloc NodeAlloc;
- typedef typename AllocHolder::ValAlloc ValAlloc;
- typedef typename AllocHolder::Node Node;
- 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 boost::container::allocator_traits<A> allocator_traits_type;
+ container_detail::intrusive_list_type<Allocator>::type Icont;
+ typedef container_detail::node_alloc_holder<Allocator, Icont> AllocHolder;
+ typedef typename AllocHolder::NodePtr NodePtr;
+ typedef typename AllocHolder::NodeAlloc NodeAlloc;
+ typedef typename AllocHolder::ValAlloc ValAlloc;
+ typedef typename AllocHolder::Node Node;
+ 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 boost::container::allocator_traits<Allocator> allocator_traits_type;
class equal_to_value
{
@@ -277,19 +272,19 @@
//
//////////////////////////////////////////////
- typedef T value_type;
- typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
- typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits<A>::reference reference;
- typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
- typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
- typedef A 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;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator 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;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
//////////////////////////////////////////////
//
@@ -323,7 +318,7 @@
//!
//! <b>Complexity</b>: Linear to n.
explicit list(size_type n)
- : AllocHolder(A())
+ : AllocHolder(Allocator())
{ this->resize(n); }
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
@@ -333,7 +328,7 @@
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
- list(size_type n, const T& value, const A& a = A())
+ list(size_type n, const T& value, const Allocator& a = Allocator())
: AllocHolder(a)
{ this->insert(this->cbegin(), n, value); }
@@ -393,7 +388,7 @@
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InpIt>
- list(InpIt first, InpIt last, const A &a = A())
+ list(InpIt first, InpIt last, const Allocator &a = Allocator())
: AllocHolder(a)
{ this->insert(this->cbegin(), first, last); }
@@ -1430,13 +1425,13 @@
};
-template <class T, class A>
-inline bool operator==(const list<T,A>& x, const list<T,A>& y)
+template <class T, class Allocator>
+inline bool operator==(const list<T,Allocator>& x, const list<T,Allocator>& y)
{
if(x.size() != y.size()){
return false;
}
- typedef typename list<T,A>::const_iterator const_iterator;
+ typedef typename list<T,Allocator>::const_iterator const_iterator;
const_iterator end1 = x.end();
const_iterator i1 = x.begin();
@@ -1448,39 +1443,39 @@
return i1 == end1;
}
-template <class T, class A>
-inline bool operator<(const list<T,A>& x,
- const list<T,A>& y)
+template <class T, class Allocator>
+inline bool operator<(const list<T,Allocator>& x,
+ const list<T,Allocator>& y)
{
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
}
-template <class T, class A>
-inline bool operator!=(const list<T,A>& x, const list<T,A>& y)
+template <class T, class Allocator>
+inline bool operator!=(const list<T,Allocator>& x, const list<T,Allocator>& y)
{
return !(x == y);
}
-template <class T, class A>
-inline bool operator>(const list<T,A>& x, const list<T,A>& y)
+template <class T, class Allocator>
+inline bool operator>(const list<T,Allocator>& x, const list<T,Allocator>& y)
{
return y < x;
}
-template <class T, class A>
-inline bool operator<=(const list<T,A>& x, const list<T,A>& y)
+template <class T, class Allocator>
+inline bool operator<=(const list<T,Allocator>& x, const list<T,Allocator>& y)
{
return !(y < x);
}
-template <class T, class A>
-inline bool operator>=(const list<T,A>& x, const list<T,A>& y)
+template <class T, class Allocator>
+inline bool operator>=(const list<T,Allocator>& x, const list<T,Allocator>& y)
{
return !(x < y);
}
-template <class T, class A>
-inline void swap(list<T, A>& x, list<T, A>& y)
+template <class T, class Allocator>
+inline void swap(list<T, Allocator>& x, list<T, Allocator>& y)
{
x.swap(y);
}
@@ -1491,10 +1486,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class A>
-struct has_trivial_destructor_after_move<boost::container::list<T, A> >
+template <class T, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::list<T, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value;
};
*/
namespace container {
@@ -1505,4 +1500,4 @@
#include <boost/container/detail/config_end.hpp>
-#endif // BOOST_CONTAINER_LIST_HPP_
+#endif // BOOST_CONTAINER_LIST_HPP
Modified: trunk/boost/container/map.hpp
==============================================================================
--- trunk/boost/container/map.hpp (original)
+++ trunk/boost/container/map.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -35,24 +35,18 @@
#include <boost/static_assert.hpp>
#include <boost/container/detail/value_init.hpp>
-
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-namespace boost {
-namespace container {
-#else
namespace boost {
namespace container {
-#endif
/// @cond
// Forward declarations of operators == and <, needed for friend declarations.
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y);
-
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y);
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y);
/// @endcond
//! A map is a kind of associative container that supports unique keys (contains at
@@ -63,67 +57,63 @@
//! container and of an associative container. For a
//! map<Key,T> the key_type is Key and the value_type is std::pair<const Key,T>.
//!
-//! Pred is the ordering function for Keys (e.g. <i>std::less<Key></i>).
+//! Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
//!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
//! (e.g. <i>allocator< std::pair<const Key, T> > </i>).
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< const Key, T> > >
+template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< const Key, T> > >
#else
-template <class Key, class T, class Pred, class A>
+template <class Key, class T, class Compare, class Allocator>
#endif
class map
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(map)
- typedef container_detail::rbtree<Key,
- std::pair<const Key, T>,
- container_detail::select1st< std::pair<const Key, T> >,
- Pred,
- A> tree_t;
- tree_t m_tree; // red-black tree representing map
+ typedef std::pair<const Key, T> value_type_impl;
+ typedef container_detail::rbtree
+ <Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator> tree_t;
+ typedef container_detail::pair <Key, T> movable_value_type_impl;
+ typedef container_detail::tree_value_compare
+ < Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
+ > value_compare_impl;
+ tree_t m_tree; // red-black tree representing map
/// @endcond
public:
-
- // typedefs:
- typedef typename tree_t::key_type key_type;
- typedef typename tree_t::value_type value_type;
- typedef typename tree_t::pointer pointer;
- typedef typename tree_t::const_pointer const_pointer;
- typedef typename tree_t::reference reference;
- typedef typename tree_t::const_reference const_reference;
- typedef T mapped_type;
- typedef Pred key_compare;
- typedef typename tree_t::iterator iterator;
- typedef typename tree_t::const_iterator const_iterator;
- typedef typename tree_t::reverse_iterator reverse_iterator;
- typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
- typedef typename tree_t::size_type size_type;
- typedef typename tree_t::difference_type difference_type;
- typedef typename tree_t::allocator_type allocator_type;
- typedef typename tree_t::stored_allocator_type stored_allocator_type;
- typedef std::pair<key_type, mapped_type> nonconst_value_type;
- typedef container_detail::pair
- <key_type, mapped_type> nonconst_impl_value_type;
-
- /// @cond
- class value_compare_impl
- : public Pred,
- public std::binary_function<value_type, value_type, bool>
- {
- friend class map<Key,T,Pred,A>;
- protected :
- value_compare_impl(const Pred &c) : Pred(c) {}
- public:
- bool operator()(const value_type& x, const value_type& y) const {
- return Pred::operator()(x.first, y.first);
- }
- };
- /// @endcond
- typedef value_compare_impl value_compare;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef std::pair<const Key, T> value_type;
+ typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_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(tree_t::iterator) iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
+ typedef std::pair<key_type, mapped_type> nonconst_value_type;
+ typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
+
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
//! <b>Effects</b>: Default constructs an empty map.
//!
@@ -132,19 +122,19 @@
: m_tree()
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty map using the specified comparison object
//! and allocator.
//!
//! <b>Complexity</b>: Constant.
- explicit map(const Pred& comp,
+ explicit map(const Compare& comp,
const allocator_type& a = allocator_type())
: m_tree(comp, a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty map using the specified comparison object and
@@ -153,12 +143,12 @@
//! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
//! comp and otherwise N logN, where N is last - first.
template <class InputIterator>
- map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
+ map(InputIterator first, InputIterator last, const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_tree(true, first, last, comp, a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty map using the specified comparison object and
@@ -171,11 +161,11 @@
//! <b>Complexity</b>: Linear in N.
template <class InputIterator>
map( ordered_unique_range_t, InputIterator first, InputIterator last
- , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
+ , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
: m_tree(ordered_range, first, last, comp, a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Copy constructs a map.
@@ -185,7 +175,7 @@
: m_tree(x.m_tree)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources.
@@ -197,7 +187,7 @@
: m_tree(boost::move(x.m_tree))
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Copy constructs a map using the specified allocator.
@@ -207,7 +197,7 @@
: m_tree(x.m_tree, a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Move constructs a map using the specified allocator.
@@ -220,7 +210,7 @@
: m_tree(boost::move(x.m_tree), a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Makes *this a copy of x.
@@ -235,20 +225,6 @@
map& operator=(BOOST_RV_REF(map) x)
{ m_tree = boost::move(x.m_tree); return *this; }
- //! <b>Effects</b>: Returns the comparison object out
- //! of which a was constructed.
- //!
- //! <b>Complexity</b>: Constant.
- key_compare key_comp() const
- { return m_tree.key_comp(); }
-
- //! <b>Effects</b>: Returns an object of value_compare constructed out
- //! of the comparison object.
- //!
- //! <b>Complexity</b>: Constant.
- value_compare value_comp() const
- { return value_compare(m_tree.key_comp()); }
-
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
//!
@@ -276,6 +252,12 @@
const stored_allocator_type &get_stored_allocator() const
{ return m_tree.get_stored_allocator(); }
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
//!
//! <b>Throws</b>: Nothing.
@@ -292,14 +274,6 @@
const_iterator begin() const
{ return this->cbegin(); }
- //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_iterator cbegin() const
- { return m_tree.begin(); }
-
//! <b>Effects</b>: Returns an iterator to the end of the container.
//!
//! <b>Throws</b>: Nothing.
@@ -316,14 +290,6 @@
const_iterator end() const
{ return this->cend(); }
- //! <b>Effects</b>: Returns a const_iterator to the end of the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_iterator cend() const
- { return m_tree.end(); }
-
//! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
//! of the reversed container.
//!
@@ -342,15 +308,6 @@
const_reverse_iterator rbegin() const
{ return this->crbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_reverse_iterator crbegin() const
- { return m_tree.rbegin(); }
-
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
//! of the reversed container.
//!
@@ -369,6 +326,31 @@
const_reverse_iterator rend() const
{ return this->crend(); }
+ //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_iterator cbegin() const
+ { return m_tree.begin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator to the end of the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_iterator cend() const
+ { return m_tree.end(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reverse_iterator crbegin() const
+ { return m_tree.rbegin(); }
+
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
//! of the reversed container.
//!
@@ -378,6 +360,12 @@
const_reverse_iterator crend() const
{ return m_tree.rend(); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns true if the container contains no elements.
//!
//! <b>Throws</b>: Nothing.
@@ -402,11 +390,17 @@
size_type max_size() const
{ return m_tree.max_size(); }
+ //////////////////////////////////////////////
+ //
+ // element access
+ //
+ //////////////////////////////////////////////
+
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! Effects: If there is no key equivalent to x in the map, inserts
//! value_type(x, T()) into the map.
//!
- //! Returns: A reference to the mapped_type corresponding to x in *this.
+ //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
//!
//! Complexity: Logarithmic.
mapped_type& operator[](const key_type &k);
@@ -414,15 +408,15 @@
//! Effects: If there is no key equivalent to x in the map, inserts
//! value_type(boost::move(x), T()) into the map (the key is move-constructed)
//!
- //! Returns: A reference to the mapped_type corresponding to x in *this.
+ //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
//!
//! Complexity: Logarithmic.
mapped_type& operator[](key_type &&k);
#else
- BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, priv_subscript)
+ BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
#endif
- //! Returns: A reference to the element whose key is equivalent to x.
+ //! Returns: Allocator reference to the element whose key is equivalent to x.
//! Throws: An exception object of type out_of_range if no such element is present.
//! Complexity: logarithmic.
T& at(const key_type& k)
@@ -434,7 +428,7 @@
return i->second;
}
- //! Returns: A reference to the element whose key is equivalent to x.
+ //! Returns: Allocator reference to the element whose key is equivalent to x.
//! Throws: An exception object of type out_of_range if no such element is present.
//! Complexity: logarithmic.
const T& at(const key_type& k) const
@@ -446,13 +440,11 @@
return i->second;
}
- //! <b>Effects</b>: Swaps the contents of *this and x.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- void swap(map& x)
- { m_tree.swap(x.m_tree); }
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
//! <b>Effects</b>: Inserts x if and only if there is no element in the container
//! with key equivalent to the key of x.
@@ -495,7 +487,7 @@
//! points to the element with key equivalent to the key of x.
//!
//! <b>Complexity</b>: Logarithmic.
- std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_impl_value_type) x)
+ std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x)
{ return m_tree.insert_unique(boost::move(x)); }
//! <b>Effects</b>: Move constructs a new value from x if and only if there is
@@ -518,7 +510,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(iterator position, const value_type& x)
+ iterator insert(const_iterator position, const value_type& x)
{ return m_tree.insert_unique(position, x); }
//! <b>Effects</b>: Move constructs a new value from x if and only if there is
@@ -530,7 +522,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(iterator position, BOOST_RV_REF(nonconst_value_type) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(nonconst_value_type) x)
{ return m_tree.insert_unique(position, boost::move(x)); }
//! <b>Effects</b>: Move constructs a new value from x if and only if there is
@@ -542,7 +534,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(iterator position, BOOST_RV_REF(nonconst_impl_value_type) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
{ return m_tree.insert_unique(position, boost::move(x)); }
//! <b>Effects</b>: Inserts a copy of x in the container.
@@ -551,7 +543,7 @@
//! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(iterator position, const nonconst_value_type& x)
+ iterator insert(const_iterator position, const nonconst_value_type& x)
{ return m_tree.insert_unique(position, x); }
//! <b>Effects</b>: Inserts an element move constructed from x in the container.
@@ -560,7 +552,7 @@
//! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(iterator position, BOOST_RV_REF(value_type) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
{ return m_tree.insert_unique(position, boost::move(x)); }
//! <b>Requires</b>: first, last are not iterators into *this.
@@ -648,6 +640,14 @@
iterator erase(const_iterator first, const_iterator last)
{ return m_tree.erase(first, last); }
+ //! <b>Effects</b>: Swaps the contents of *this and x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ void swap(map& x)
+ { m_tree.swap(x.m_tree); }
+
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
@@ -656,6 +656,32 @@
void clear()
{ m_tree.clear(); }
+ //////////////////////////////////////////////
+ //
+ // observers
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns the comparison object out
+ //! of which a was constructed.
+ //!
+ //! <b>Complexity</b>: Constant.
+ key_compare key_comp() const
+ { return m_tree.key_comp(); }
+
+ //! <b>Effects</b>: Returns an object of value_compare constructed out
+ //! of the comparison object.
+ //!
+ //! <b>Complexity</b>: Constant.
+ value_compare value_comp() const
+ { return value_compare(m_tree.key_comp()); }
+
+ //////////////////////////////////////////////
+ //
+ // map operations
+ //
+ //////////////////////////////////////////////
+
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
@@ -663,7 +689,7 @@
iterator find(const key_type& x)
{ return m_tree.find(x); }
- //! <b>Returns</b>: A const_iterator pointing to an element with the key
+ //! <b>Returns</b>: Allocator const_iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
@@ -683,7 +709,7 @@
iterator lower_bound(const key_type& x)
{ return m_tree.lower_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -697,7 +723,7 @@
iterator upper_bound(const key_type& x)
{ return m_tree.upper_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -731,7 +757,7 @@
// i->first is greater than or equivalent to k.
if (i == end() || key_comp()(k, (*i).first)){
container_detail::value_init<mapped_type> m;
- nonconst_impl_value_type val(k, boost::move(m.m_t));
+ movable_value_type val(k, boost::move(m.m_t));
i = insert(i, boost::move(val));
}
return (*i).second;
@@ -745,7 +771,7 @@
// i->first is greater than or equivalent to k.
if (i == end() || key_comp()(k, (*i).first)){
container_detail::value_init<mapped_type> m;
- nonconst_impl_value_type val(boost::move(k), boost::move(m.m_t));
+ movable_value_type val(boost::move(k), boost::move(m.m_t));
i = insert(i, boost::move(val));
}
return (*i).second;
@@ -754,60 +780,60 @@
/// @endcond
};
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y)
{ return x.m_tree == y.m_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y)
{ return x.m_tree < y.m_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator!=(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator!=(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y)
{ return !(x == y); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y)
{ return y < x; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<=(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<=(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y)
{ return !(y < x); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>=(const map<Key,T,Pred,A>& x,
- const map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>=(const map<Key,T,Compare,Allocator>& x,
+ const map<Key,T,Compare,Allocator>& y)
{ return !(x < y); }
-template <class Key, class T, class Pred, class A>
-inline void swap(map<Key,T,Pred,A>& x, map<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline void swap(map<Key,T,Compare,Allocator>& x, map<Key,T,Compare,Allocator>& y)
{ x.swap(y); }
/// @cond
// Forward declaration of operators < and ==, needed for friend declaration.
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y);
-
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y);
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y);
} //namespace container {
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class K, class T, class C, class A>
-struct has_trivial_destructor_after_move<boost::container::map<K, T, C, A> >
+template <class K, class T, class C, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::map<K, T, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value && has_trivial_destructor<C>::value;
};
*/
namespace container {
@@ -823,68 +849,63 @@
//! container and of an associative container. For a
//! map<Key,T> the key_type is Key and the value_type is std::pair<const Key,T>.
//!
-//! Pred is the ordering function for Keys (e.g. <i>std::less<Key></i>).
+//! Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
//!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
//!(e.g. <i>allocator< std::pair<<b>const</b> Key, T> ></i>).
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< const Key, T> > >
+template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< const Key, T> > >
#else
-template <class Key, class T, class Pred, class A>
+template <class Key, class T, class Compare, class Allocator>
#endif
class multimap
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(multimap)
- typedef container_detail::rbtree<Key,
- std::pair<const Key, T>,
- container_detail::select1st< std::pair<const Key, T> >,
- Pred,
- A> tree_t;
+
+ typedef std::pair<const Key, T> value_type_impl;
+ typedef container_detail::rbtree
+ <Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator> tree_t;
+ typedef container_detail::pair <Key, T> movable_value_type_impl;
+ typedef container_detail::tree_value_compare
+ < Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
+ > value_compare_impl;
tree_t m_tree; // red-black tree representing map
- typedef typename container_detail::
- move_const_ref_type<Key>::type insert_key_const_ref_type;
/// @endcond
public:
-
- // typedefs:
- typedef typename tree_t::key_type key_type;
- typedef typename tree_t::value_type value_type;
- typedef typename tree_t::pointer pointer;
- typedef typename tree_t::const_pointer const_pointer;
- typedef typename tree_t::reference reference;
- typedef typename tree_t::const_reference const_reference;
- typedef T mapped_type;
- typedef Pred key_compare;
- typedef typename tree_t::iterator iterator;
- typedef typename tree_t::const_iterator const_iterator;
- typedef typename tree_t::reverse_iterator reverse_iterator;
- typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
- typedef typename tree_t::size_type size_type;
- typedef typename tree_t::difference_type difference_type;
- typedef typename tree_t::allocator_type allocator_type;
- typedef typename tree_t::stored_allocator_type stored_allocator_type;
- typedef std::pair<key_type, mapped_type> nonconst_value_type;
- typedef container_detail::pair
- <key_type, mapped_type> nonconst_impl_value_type;
-
- /// @cond
- class value_compare_impl
- : public Pred,
- public std::binary_function<value_type, value_type, bool>
- {
- friend class multimap<Key,T,Pred,A>;
- protected :
- value_compare_impl(const Pred &c) : Pred(c) {}
- public:
- bool operator()(const value_type& x, const value_type& y) const {
- return Pred::operator()(x.first, y.first);
- }
- };
- /// @endcond
- typedef value_compare_impl value_compare;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef std::pair<const Key, T> value_type;
+ typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_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(tree_t::iterator) iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
+ typedef std::pair<key_type, mapped_type> nonconst_value_type;
+ typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
+
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
//! <b>Effects</b>: Default constructs an empty multimap.
//!
@@ -893,18 +914,18 @@
: m_tree()
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty multimap using the specified comparison
//! object and allocator.
//!
//! <b>Complexity</b>: Constant.
- explicit multimap(const Pred& comp, const allocator_type& a = allocator_type())
+ explicit multimap(const Compare& comp, const allocator_type& a = allocator_type())
: m_tree(comp, a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty multimap using the specified comparison object
@@ -914,12 +935,12 @@
//! comp and otherwise N logN, where N is last - first.
template <class InputIterator>
multimap(InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_tree(false, first, last, comp, a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
@@ -930,7 +951,7 @@
//!
//! <b>Complexity</b>: Linear in N.
template <class InputIterator>
- multimap(ordered_range_t ordered_range, InputIterator first, InputIterator last, const Pred& comp = Pred(),
+ multimap(ordered_range_t ordered_range, InputIterator first, InputIterator last, const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_tree(ordered_range, first, last, comp, a)
{}
@@ -942,7 +963,7 @@
: m_tree(x.m_tree)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Move constructs a multimap. Constructs *this using x's resources.
@@ -954,7 +975,7 @@
: m_tree(boost::move(x.m_tree))
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Copy constructs a multimap.
@@ -964,7 +985,7 @@
: m_tree(x.m_tree, a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Move constructs a multimap using the specified allocator.
@@ -976,7 +997,7 @@
: m_tree(boost::move(x.m_tree), a)
{
//Allocator type must be std::pair<CONST Key, T>
- BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
+ BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
}
//! <b>Effects</b>: Makes *this a copy of x.
@@ -991,20 +1012,6 @@
multimap& operator=(BOOST_RV_REF(multimap) x)
{ m_tree = boost::move(x.m_tree); return *this; }
- //! <b>Effects</b>: Returns the comparison object out
- //! of which a was constructed.
- //!
- //! <b>Complexity</b>: Constant.
- key_compare key_comp() const
- { return m_tree.key_comp(); }
-
- //! <b>Effects</b>: Returns an object of value_compare constructed out
- //! of the comparison object.
- //!
- //! <b>Complexity</b>: Constant.
- value_compare value_comp() const
- { return value_compare(m_tree.key_comp()); }
-
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
//!
@@ -1032,6 +1039,12 @@
const stored_allocator_type &get_stored_allocator() const
{ return m_tree.get_stored_allocator(); }
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
//!
//! <b>Throws</b>: Nothing.
@@ -1048,14 +1061,6 @@
const_iterator begin() const
{ return this->cbegin(); }
- //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_iterator cbegin() const
- { return m_tree.begin(); }
-
//! <b>Effects</b>: Returns an iterator to the end of the container.
//!
//! <b>Throws</b>: Nothing.
@@ -1072,14 +1077,6 @@
const_iterator end() const
{ return this->cend(); }
- //! <b>Effects</b>: Returns a const_iterator to the end of the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_iterator cend() const
- { return m_tree.end(); }
-
//! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
//! of the reversed container.
//!
@@ -1098,15 +1095,6 @@
const_reverse_iterator rbegin() const
{ return this->crbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_reverse_iterator crbegin() const
- { return m_tree.rbegin(); }
-
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
//! of the reversed container.
//!
@@ -1125,6 +1113,31 @@
const_reverse_iterator rend() const
{ return this->crend(); }
+ //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_iterator cbegin() const
+ { return m_tree.begin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator to the end of the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_iterator cend() const
+ { return m_tree.end(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reverse_iterator crbegin() const
+ { return m_tree.rbegin(); }
+
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
//! of the reversed container.
//!
@@ -1134,6 +1147,12 @@
const_reverse_iterator crend() const
{ return m_tree.rend(); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns true if the container contains no elements.
//!
//! <b>Throws</b>: Nothing.
@@ -1158,13 +1177,57 @@
size_type max_size() const
{ return m_tree.max_size(); }
- //! <b>Effects</b>: Swaps the contents of *this and x.
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
+
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... in the container.
+ //! p is a hint pointing to where the insert should start to search.
//!
- //! <b>Throws</b>: Nothing.
+ //! <b>Returns</b>: An iterator pointing to the element with key equivalent
+ //! to the key of x.
//!
- //! <b>Complexity</b>: Constant.
- void swap(multimap& x)
- { m_tree.swap(x.m_tree); }
+ //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
+ //! is inserted right before p.
+ template <class... Args>
+ iterator emplace(Args&&... args)
+ { return m_tree.emplace_equal(boost::forward<Args>(args)...); }
+
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... in the container.
+ //! p is a hint pointing to where the insert should start to search.
+ //!
+ //! <b>Returns</b>: An iterator pointing to the element with key equivalent
+ //! to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
+ //! is inserted right before p.
+ template <class... Args>
+ iterator emplace_hint(const_iterator hint, Args&&... args)
+ { return m_tree.emplace_hint_equal(hint, boost::forward<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, >) \
+ iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_tree.emplace_equal(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(const_iterator hint \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_tree.emplace_hint_equal(hint \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \
+ //!
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+
+ #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
//! <b>Effects</b>: Inserts x and returns the iterator pointing to the
//! newly inserted element.
@@ -1191,7 +1254,7 @@
//! the iterator pointing to the newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(BOOST_RV_REF(nonconst_impl_value_type) x)
+ iterator insert(BOOST_RV_REF(movable_value_type) x)
{ return m_tree.insert_equal(boost::move(x)); }
//! <b>Effects</b>: Inserts a copy of x in the container.
@@ -1202,7 +1265,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(iterator position, const value_type& x)
+ iterator insert(const_iterator position, const value_type& x)
{ return m_tree.insert_equal(position, x); }
//! <b>Effects</b>: Inserts a new value constructed from x in the container.
@@ -1213,7 +1276,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(iterator position, const nonconst_value_type& x)
+ iterator insert(const_iterator position, const nonconst_value_type& x)
{ return m_tree.insert_equal(position, x); }
//! <b>Effects</b>: Inserts a new value move constructed from x in the container.
@@ -1224,7 +1287,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(iterator position, BOOST_RV_REF(nonconst_value_type) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(nonconst_value_type) x)
{ return m_tree.insert_equal(position, boost::move(x)); }
//! <b>Effects</b>: Inserts a new value move constructed from x in the container.
@@ -1235,7 +1298,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(iterator position, BOOST_RV_REF(nonconst_impl_value_type) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
{ return m_tree.insert_equal(position, boost::move(x)); }
//! <b>Requires</b>: first, last are not iterators into *this.
@@ -1247,52 +1310,6 @@
void insert(InputIterator first, InputIterator last)
{ m_tree.insert_equal(first, last); }
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the container.
- //! p is a hint pointing to where the insert should start to search.
- //!
- //! <b>Returns</b>: An iterator pointing to the element with key equivalent
- //! to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
- //! is inserted right before p.
- template <class... Args>
- iterator emplace(Args&&... args)
- { return m_tree.emplace_equal(boost::forward<Args>(args)...); }
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the container.
- //! p is a hint pointing to where the insert should start to search.
- //!
- //! <b>Returns</b>: An iterator pointing to the element with key equivalent
- //! to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
- //! is inserted right before p.
- template <class... Args>
- iterator emplace_hint(const_iterator hint, Args&&... args)
- { return m_tree.emplace_hint_equal(hint, boost::forward<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, >) \
- iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_tree.emplace_equal(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(const_iterator hint \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_tree.emplace_hint_equal(hint \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
@@ -1319,6 +1336,14 @@
iterator erase(const_iterator first, const_iterator last)
{ return m_tree.erase(first, last); }
+ //! <b>Effects</b>: Swaps the contents of *this and x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ void swap(multimap& x)
+ { m_tree.swap(x.m_tree); }
+
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
@@ -1327,6 +1352,32 @@
void clear()
{ m_tree.clear(); }
+ //////////////////////////////////////////////
+ //
+ // observers
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns the comparison object out
+ //! of which a was constructed.
+ //!
+ //! <b>Complexity</b>: Constant.
+ key_compare key_comp() const
+ { return m_tree.key_comp(); }
+
+ //! <b>Effects</b>: Returns an object of value_compare constructed out
+ //! of the comparison object.
+ //!
+ //! <b>Complexity</b>: Constant.
+ value_compare value_comp() const
+ { return value_compare(m_tree.key_comp()); }
+
+ //////////////////////////////////////////////
+ //
+ // map operations
+ //
+ //////////////////////////////////////////////
+
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
@@ -1334,7 +1385,7 @@
iterator find(const key_type& x)
{ return m_tree.find(x); }
- //! <b>Returns</b>: A const iterator pointing to an element with the key
+ //! <b>Returns</b>: Allocator const iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
@@ -1354,7 +1405,7 @@
iterator lower_bound(const key_type& x)
{return m_tree.lower_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1368,13 +1419,7 @@
iterator upper_bound(const key_type& x)
{ return m_tree.upper_bound(x); }
- //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
- //!
- //! <b>Complexity</b>: Logarithmic
- std::pair<iterator,iterator> equal_range(const key_type& x)
- { return m_tree.equal_range(x); }
-
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1384,8 +1429,13 @@
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<const_iterator,const_iterator>
- equal_range(const key_type& x) const
+ std::pair<iterator,iterator> equal_range(const key_type& x)
+ { return m_tree.equal_range(x); }
+
+ //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
+ //!
+ //! <b>Complexity</b>: Logarithmic
+ std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
{ return m_tree.equal_range(x); }
/// @cond
@@ -1399,38 +1449,38 @@
/// @endcond
};
-template <class Key, class T, class Pred, class A>
-inline bool operator==(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator==(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y)
{ return x.m_tree == y.m_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y)
{ return x.m_tree < y.m_tree; }
-template <class Key, class T, class Pred, class A>
-inline bool operator!=(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator!=(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y)
{ return !(x == y); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y)
{ return y < x; }
-template <class Key, class T, class Pred, class A>
-inline bool operator<=(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator<=(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y)
{ return !(y < x); }
-template <class Key, class T, class Pred, class A>
-inline bool operator>=(const multimap<Key,T,Pred,A>& x,
- const multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline bool operator>=(const multimap<Key,T,Compare,Allocator>& x,
+ const multimap<Key,T,Compare,Allocator>& y)
{ return !(x < y); }
-template <class Key, class T, class Pred, class A>
-inline void swap(multimap<Key,T,Pred,A>& x, multimap<Key,T,Pred,A>& y)
+template <class Key, class T, class Compare, class Allocator>
+inline void swap(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y)
{ x.swap(y); }
/// @cond
@@ -1439,10 +1489,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class K, class T, class C, class A>
-struct has_trivial_destructor_after_move<boost::container::multimap<K, T, C, A> >
+template <class K, class T, class C, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::multimap<K, T, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value && has_trivial_destructor<C>::value;
};
*/
namespace container {
Modified: trunk/boost/container/scoped_allocator.hpp
==============================================================================
--- trunk/boost/container/scoped_allocator.hpp (original)
+++ trunk/boost/container/scoped_allocator.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -47,10 +47,10 @@
//! ill-formed.
//!
//! [Example:
-//! template <class T, class A = allocator<T> >
+//! template <class T, class Allocator = allocator<T> >
//! class Z {
//! public:
-//! typedef A allocator_type;
+//! typedef Allocator allocator_type;
//!
//! // Default constructor with optional allocator suffix
//! Z(const allocator_type& a = allocator_type());
@@ -61,8 +61,8 @@
//! };
//!
//! // Specialize trait for class template Z
-//! template <class T, class A = allocator<T> >
-//! struct constructible_with_allocator_suffix<Z<T,A> >
+//! template <class T, class Allocator = allocator<T> >
+//! struct constructible_with_allocator_suffix<Z<T,Allocator> >
//! : ::boost::true_type { };
//! -- end example]
//!
@@ -91,10 +91,10 @@
//! a constructor, then the program is ill-formed.
//!
//! [Example:
-//! template <class T, class A = allocator<T> >
+//! template <class T, class Allocator = allocator<T> >
//! class Y {
//! public:
-//! typedef A allocator_type;
+//! typedef Allocator allocator_type;
//!
//! // Default constructor with and allocator-extended default constructor
//! Y();
@@ -111,8 +111,8 @@
//! };
//!
//! // Specialize trait for class template Y
-//! template <class T, class A = allocator<T> >
-//! struct constructible_with_allocator_prefix<Y<T,A> >
+//! template <class T, class Allocator = allocator<T> >
+//! struct constructible_with_allocator_prefix<Y<T,Allocator> >
//! : ::boost::true_type { };
//!
//! -- end example]
@@ -1036,16 +1036,16 @@
typedef typename outer_traits_type::const_pointer const_pointer;
typedef typename outer_traits_type::void_pointer void_pointer;
typedef typename outer_traits_type::const_void_pointer const_void_pointer;
- //! Type: `true_type` if `allocator_traits<A>::propagate_on_container_copy_assignment::value` is
- //! true for any `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
+ //! Type: `true_type` if `allocator_traits<Allocator>::propagate_on_container_copy_assignment::value` is
+ //! true for any `Allocator` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
typedef typename base_type::
propagate_on_container_copy_assignment propagate_on_container_copy_assignment;
- //! Type: `true_type` if `allocator_traits<A>::propagate_on_container_move_assignment::value` is
- //! true for any `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
+ //! Type: `true_type` if `allocator_traits<Allocator>::propagate_on_container_move_assignment::value` is
+ //! true for any `Allocator` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
typedef typename base_type::
propagate_on_container_move_assignment propagate_on_container_move_assignment;
- //! Type: `true_type` if `allocator_traits<A>::propagate_on_container_swap::value` is true for any
- //! `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
+ //! Type: `true_type` if `allocator_traits<Allocator>::propagate_on_container_swap::value` is true for any
+ //! `Allocator` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise, false_type.
typedef typename base_type::
propagate_on_container_swap propagate_on_container_swap;
@@ -1211,9 +1211,9 @@
outer_traits_type::deallocate(this->outer_allocator(), p, n);
}
- //! <b>Returns</b>: A new scoped_allocator_adaptor object where each allocator
+ //! <b>Returns</b>: Allocator new scoped_allocator_adaptor object where each allocator
//! A in the adaptor is initialized from the result of calling
- //! `allocator_traits<A>::select_on_container_copy_construction()` on
+ //! `allocator_traits<Allocator>::select_on_container_copy_construction()` on
//! the corresponding allocator in *this.
scoped_allocator_adaptor select_on_container_copy_construction() const
{
Modified: trunk/boost/container/set.hpp
==============================================================================
--- trunk/boost/container/set.hpp (original)
+++ trunk/boost/container/set.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -24,6 +24,7 @@
#include <memory>
#include <boost/move/move.hpp>
+#include <boost/move/move_helpers.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/tree.hpp>
#include <boost/move/move.hpp>
@@ -31,23 +32,18 @@
#include <boost/container/detail/preprocessor.hpp>
#endif
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
namespace boost {
namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
/// @cond
// Forward declarations of operators < and ==, needed for friend declaration.
-template <class T, class Pred, class A>
-inline bool operator==(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y);
-
-template <class T, class Pred, class A>
-inline bool operator<(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y);
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y);
/// @endcond
//! A set is a kind of associative container that supports unique keys (contains at
@@ -58,41 +54,48 @@
//! , and of an associative container. A set also provides most operations described in
//! for unique keys.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class Pred = std::less<T>, class A = std::allocator<T> >
+template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
#else
-template <class T, class Pred, class A>
+template <class Key, class Compare, class Allocator>
#endif
class set
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(set)
- typedef container_detail::rbtree<T, T,
- container_detail::identity<T>, Pred, A> tree_t;
+ typedef container_detail::rbtree<Key, Key,
+ container_detail::identity<Key>, Compare, Allocator> tree_t;
tree_t m_tree; // red-black tree representing set
- typedef typename container_detail::
- move_const_ref_type<T>::type insert_const_ref_type;
/// @endcond
public:
-
- // typedefs:
- typedef typename tree_t::key_type key_type;
- typedef typename tree_t::value_type value_type;
- typedef typename tree_t::pointer pointer;
- typedef typename tree_t::const_pointer const_pointer;
- typedef typename tree_t::reference reference;
- typedef typename tree_t::const_reference const_reference;
- typedef Pred key_compare;
- typedef Pred value_compare;
- typedef typename tree_t::iterator iterator;
- typedef typename tree_t::const_iterator const_iterator;
- typedef typename tree_t::reverse_iterator reverse_iterator;
- typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
- typedef typename tree_t::size_type size_type;
- typedef typename tree_t::difference_type difference_type;
- typedef typename tree_t::allocator_type allocator_type;
- typedef typename tree_t::stored_allocator_type stored_allocator_type;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+ typedef Key key_type;
+ typedef Key value_type;
+ typedef Compare key_compare;
+ typedef Compare value_compare;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator) iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
+
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
//! <b>Effects</b>: Default constructs an empty set.
//!
@@ -105,7 +108,7 @@
//! and allocator.
//!
//! <b>Complexity</b>: Constant.
- explicit set(const Pred& comp,
+ explicit set(const Compare& comp,
const allocator_type& a = allocator_type())
: m_tree(comp, a)
{}
@@ -116,7 +119,7 @@
//! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
//! comp and otherwise N logN, where N is last - first.
template <class InputIterator>
- set(InputIterator first, InputIterator last, const Pred& comp = Pred(),
+ set(InputIterator first, InputIterator last, const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_tree(true, first, last, comp, a)
{}
@@ -131,7 +134,7 @@
//! <b>Complexity</b>: Linear in N.
template <class InputIterator>
set( ordered_unique_range_t, InputIterator first, InputIterator last
- , const Pred& comp = Pred(), const allocator_type& a = allocator_type())
+ , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
: m_tree(ordered_range, first, last, comp, a)
{}
@@ -178,20 +181,6 @@
set& operator=(BOOST_RV_REF(set) x)
{ m_tree = boost::move(x.m_tree); return *this; }
- //! <b>Effects</b>: Returns the comparison object out
- //! of which a was constructed.
- //!
- //! <b>Complexity</b>: Constant.
- key_compare key_comp() const
- { return m_tree.key_comp(); }
-
- //! <b>Effects</b>: Returns an object of value_compare constructed out
- //! of the comparison object.
- //!
- //! <b>Complexity</b>: Constant.
- value_compare value_comp() const
- { return m_tree.key_comp(); }
-
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
//!
@@ -219,6 +208,12 @@
stored_allocator_type &get_stored_allocator()
{ return m_tree.get_stored_allocator(); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
//!
//! <b>Throws</b>: Nothing.
@@ -321,6 +316,12 @@
const_reverse_iterator crend() const
{ return m_tree.crend(); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns true if the container contains no elements.
//!
//! <b>Throws</b>: Nothing.
@@ -345,90 +346,15 @@
size_type max_size() const
{ return m_tree.max_size(); }
- //! <b>Effects</b>: Swaps the contents of *this and x.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- void swap(set& x)
- { m_tree.swap(x.m_tree); }
-
- //! <b>Effects</b>: Inserts x if and only if there is no element in the container
- //! with key equivalent to the key of x.
- //!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
- //! if the insertion takes place, and the iterator component of the pair
- //! points to the element with key equivalent to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic.
- std::pair<iterator,bool> insert(insert_const_ref_type x)
- { return priv_insert(x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- std::pair<iterator,bool> insert(T &x)
- { return this->insert(const_cast<const T &>(x)); }
-
- template<class U>
- std::pair<iterator,bool> insert(const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(u); }
- #endif
-
- //! <b>Effects</b>: Move constructs a new value from x if and only if there is
- //! no element in the container with key equivalent to the key of x.
- //!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
- //! if the insertion takes place, and the iterator component of the pair
- //! points to the element with key equivalent to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic.
- std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
- { return m_tree.insert_unique(boost::move(x)); }
-
- //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
- //! no element in the container with key equivalent to the key of x.
- //! p is a hint pointing to where the insert should start to search.
- //!
- //! <b>Returns</b>: An iterator pointing to the element with key equivalent
- //! to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
- //! is inserted right before p.
- iterator insert(const_iterator p, insert_const_ref_type x)
- { return priv_insert(p, x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(const_iterator position, T &x)
- { return this->insert(position, const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert( const_iterator position, const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(position, u); }
- #endif
-
- //! <b>Effects</b>: Inserts an element move constructed from x in the container.
- //! p is a hint pointing to where the insert should start to search.
- //!
- //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic.
- iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
- { return m_tree.insert_unique(p, boost::move(x)); }
-
- //! <b>Requires</b>: first, last are not iterators into *this.
- //!
- //! <b>Effects</b>: inserts each element from the range [first,last) if and only
- //! if there is no element with key equivalent to the key of that element.
- //!
- //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
- template <class InputIterator>
- void insert(InputIterator first, InputIterator last)
- { m_tree.insert_unique(first, last); }
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! <b>Effects</b>: Inserts an object x of type T constructed with
+ //! <b>Effects</b>: Inserts an object x of type Key constructed with
//! std::forward<Args>(args)... if and only if there is
//! no element in the container with equivalent value.
//! and returns the iterator pointing to the
@@ -439,14 +365,14 @@
//! points to the element with key equivalent to the key of x.
//!
//! <b>Throws</b>: If memory allocation throws or
- //! T's in-place constructor throws.
+ //! Key's in-place constructor throws.
//!
//! <b>Complexity</b>: Logarithmic.
template <class... Args>
std::pair<iterator,bool> emplace(Args&&... args)
{ return m_tree.emplace_unique(boost::forward<Args>(args)...); }
- //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! <b>Effects</b>: Inserts an object of type Key constructed with
//! std::forward<Args>(args)... if and only if there is
//! no element in the container with equivalent value.
//! p is a hint pointing to where the insert
@@ -477,6 +403,66 @@
#endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts x if and only if there is no element in the container
+ //! with key equivalent to the key of x.
+ //!
+ //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! if the insertion takes place, and the iterator component of the pair
+ //! points to the element with key equivalent to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ std::pair<iterator, bool> insert(const value_type &x);
+
+ //! <b>Effects</b>: Move constructs a new value from x if and only if there is
+ //! no element in the container with key equivalent to the key of x.
+ //!
+ //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! if the insertion takes place, and the iterator component of the pair
+ //! points to the element with key equivalent to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ std::pair<iterator, bool> insert(value_type &&x);
+ #else
+ private:
+ typedef std::pair<iterator, bool> insert_return_pair;
+ public:
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
+ #endif
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
+ //! no element in the container with key equivalent to the key of x.
+ //! p is a hint pointing to where the insert should start to search.
+ //!
+ //! <b>Returns</b>: An iterator pointing to the element with key equivalent
+ //! to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
+ //! is inserted right before p.
+ iterator insert(const_iterator p, const value_type &x);
+
+ //! <b>Effects</b>: Inserts an element move constructed from x in the container.
+ //! p is a hint pointing to where the insert should start to search.
+ //!
+ //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ iterator insert(const_iterator position, value_type &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+ #endif
+
+ //! <b>Requires</b>: first, last are not iterators into *this.
+ //!
+ //! <b>Effects</b>: inserts each element from the range [first,last) if and only
+ //! if there is no element with key equivalent to the key of that element.
+ //!
+ //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last)
+ { m_tree.insert_unique(first, last); }
+
//! <b>Effects</b>: Erases the element pointed to by p.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
@@ -503,6 +489,14 @@
iterator erase(const_iterator first, const_iterator last)
{ return m_tree.erase(first, last); }
+ //! <b>Effects</b>: Swaps the contents of *this and x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ void swap(set& x)
+ { m_tree.swap(x.m_tree); }
+
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
@@ -511,6 +505,32 @@
void clear()
{ m_tree.clear(); }
+ //////////////////////////////////////////////
+ //
+ // observers
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns the comparison object out
+ //! of which a was constructed.
+ //!
+ //! <b>Complexity</b>: Constant.
+ key_compare key_comp() const
+ { return m_tree.key_comp(); }
+
+ //! <b>Effects</b>: Returns an object of value_compare constructed out
+ //! of the comparison object.
+ //!
+ //! <b>Complexity</b>: Constant.
+ value_compare value_comp() const
+ { return m_tree.key_comp(); }
+
+ //////////////////////////////////////////////
+ //
+ // set operations
+ //
+ //////////////////////////////////////////////
+
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
@@ -518,7 +538,7 @@
iterator find(const key_type& x)
{ return m_tree.find(x); }
- //! <b>Returns</b>: A const_iterator pointing to an element with the key
+ //! <b>Returns</b>: Allocator const_iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
@@ -538,7 +558,7 @@
iterator lower_bound(const key_type& x)
{ return m_tree.lower_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -552,7 +572,7 @@
iterator upper_bound(const key_type& x)
{ return m_tree.upper_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -562,15 +582,13 @@
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<iterator,iterator>
- equal_range(const key_type& x)
+ std::pair<iterator,iterator> equal_range(const key_type& x)
{ return m_tree.equal_range(x); }
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<const_iterator, const_iterator>
- equal_range(const key_type& x) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
{ return m_tree.equal_range(x); }
/// @cond
@@ -581,47 +599,48 @@
friend bool operator< (const set<K1,C1,A1>&, const set<K1,C1,A1>&);
private:
- std::pair<iterator, bool> priv_insert(const T &x)
- { return m_tree.insert_unique(x); }
-
- iterator priv_insert(const_iterator p, const T &x)
- { return m_tree.insert_unique(p, x); }
-
+ template <class KeyType>
+ std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x)
+ { return m_tree.insert_unique(::boost::forward<KeyType>(x)); }
+
+ template <class KeyType>
+ iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+ { return m_tree.insert_unique(p, ::boost::forward<KeyType>(x)); }
/// @endcond
};
-template <class T, class Pred, class A>
-inline bool operator==(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y)
{ return x.m_tree == y.m_tree; }
-template <class T, class Pred, class A>
-inline bool operator<(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y)
{ return x.m_tree < y.m_tree; }
-template <class T, class Pred, class A>
-inline bool operator!=(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator!=(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y)
{ return !(x == y); }
-template <class T, class Pred, class A>
-inline bool operator>(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y)
{ return y < x; }
-template <class T, class Pred, class A>
-inline bool operator<=(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<=(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y)
{ return !(y < x); }
-template <class T, class Pred, class A>
-inline bool operator>=(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>=(const set<Key,Compare,Allocator>& x,
+ const set<Key,Compare,Allocator>& y)
{ return !(x < y); }
-template <class T, class Pred, class A>
-inline void swap(set<T,Pred,A>& x, set<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline void swap(set<Key,Compare,Allocator>& x, set<Key,Compare,Allocator>& y)
{ x.swap(y); }
/// @cond
@@ -630,23 +649,23 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class C, class A>
-struct has_trivial_destructor_after_move<boost::container::set<T, C, A> >
+template <class Key, class C, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::set<Key, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value && has_trivial_destructor<C>::value;
};
*/
namespace container {
// Forward declaration of operators < and ==, needed for friend declaration.
-template <class T, class Pred, class A>
-inline bool operator==(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y);
-
-template <class T, class Pred, class A>
-inline bool operator<(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y);
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y);
/// @endcond
//! A multiset is a kind of associative container that supports equivalent keys
@@ -657,41 +676,49 @@
//! container, and of an associative container). multiset also provides most operations
//! described for duplicate keys.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class Pred = std::less<T>, class A = std::allocator<T> >
+template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
#else
-template <class T, class Pred, class A>
+template <class Key, class Compare, class Allocator>
#endif
class multiset
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(multiset)
- typedef container_detail::rbtree<T, T,
- container_detail::identity<T>, Pred, A> tree_t;
+ typedef container_detail::rbtree<Key, Key,
+ container_detail::identity<Key>, Compare, Allocator> tree_t;
tree_t m_tree; // red-black tree representing multiset
- typedef typename container_detail::
- move_const_ref_type<T>::type insert_const_ref_type;
/// @endcond
public:
- // typedefs:
- typedef typename tree_t::key_type key_type;
- typedef typename tree_t::value_type value_type;
- typedef typename tree_t::pointer pointer;
- typedef typename tree_t::const_pointer const_pointer;
- typedef typename tree_t::reference reference;
- typedef typename tree_t::const_reference const_reference;
- typedef Pred key_compare;
- typedef Pred value_compare;
- typedef typename tree_t::iterator iterator;
- typedef typename tree_t::const_iterator const_iterator;
- typedef typename tree_t::reverse_iterator reverse_iterator;
- typedef typename tree_t::const_reverse_iterator const_reverse_iterator;
- typedef typename tree_t::size_type size_type;
- typedef typename tree_t::difference_type difference_type;
- typedef typename tree_t::allocator_type allocator_type;
- typedef typename tree_t::stored_allocator_type stored_allocator_type;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+ typedef Key key_type;
+ typedef Key value_type;
+ typedef Compare key_compare;
+ typedef Compare value_compare;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator) iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
+ typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
+
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
//! <b>Effects</b>: Constructs an empty multiset using the specified comparison
//! object and allocator.
@@ -705,7 +732,7 @@
//! object and allocator.
//!
//! <b>Complexity</b>: Constant.
- explicit multiset(const Pred& comp,
+ explicit multiset(const Compare& comp,
const allocator_type& a = allocator_type())
: m_tree(comp, a)
{}
@@ -717,7 +744,7 @@
//! comp and otherwise N logN, where N is last - first.
template <class InputIterator>
multiset(InputIterator first, InputIterator last,
- const Pred& comp = Pred(),
+ const Compare& comp = Compare(),
const allocator_type& a = allocator_type())
: m_tree(false, first, last, comp, a)
{}
@@ -731,7 +758,7 @@
//! <b>Complexity</b>: Linear in N.
template <class InputIterator>
multiset( ordered_range_t ordered_range, InputIterator first, InputIterator last
- , const Pred& comp = Pred()
+ , const Compare& comp = Compare()
, const allocator_type& a = allocator_type())
: m_tree(ordered_range, first, last, comp, a)
{}
@@ -781,20 +808,6 @@
multiset& operator=(BOOST_RV_REF(multiset) x)
{ m_tree = boost::move(x.m_tree); return *this; }
- //! <b>Effects</b>: Returns the comparison object out
- //! of which a was constructed.
- //!
- //! <b>Complexity</b>: Constant.
- key_compare key_comp() const
- { return m_tree.key_comp(); }
-
- //! <b>Effects</b>: Returns an object of value_compare constructed out
- //! of the comparison object.
- //!
- //! <b>Complexity</b>: Constant.
- value_compare value_comp() const
- { return m_tree.key_comp(); }
-
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
//!
@@ -822,6 +835,12 @@
const stored_allocator_type &get_stored_allocator() const
{ return m_tree.get_stored_allocator(); }
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
//!
//! <b>Throws</b>: Nothing.
@@ -924,6 +943,12 @@
const_reverse_iterator crend() const
{ return m_tree.crend(); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! <b>Effects</b>: Returns true if the container contains no elements.
//!
//! <b>Throws</b>: Nothing.
@@ -948,30 +973,62 @@
size_type max_size() const
{ return m_tree.max_size(); }
- //! <b>Effects</b>: Swaps the contents of *this and x.
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
+
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Inserts an object of type Key constructed with
+ //! std::forward<Args>(args)... and returns the iterator pointing to the
+ //! newly inserted element.
//!
- //! <b>Throws</b>: Nothing.
+ //! <b>Complexity</b>: Logarithmic.
+ template <class... Args>
+ iterator emplace(Args&&... args)
+ { return m_tree.emplace_equal(boost::forward<Args>(args)...); }
+
+ //! <b>Effects</b>: Inserts an object of type Key constructed with
+ //! std::forward<Args>(args)...
//!
- //! <b>Complexity</b>: Constant.
- void swap(multiset& x)
- { m_tree.swap(x.m_tree); }
+ //! <b>Returns</b>: An iterator pointing to the element with key equivalent
+ //! to the key of x.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
+ //! is inserted right before p.
+ template <class... Args>
+ iterator emplace_hint(const_iterator hint, Args&&... args)
+ { return m_tree.emplace_hint_equal(hint, boost::forward<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, >) \
+ iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_tree.emplace_equal(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(const_iterator hint \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { return m_tree.emplace_hint_equal(hint \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \
+ //!
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+
+ #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts x and returns the iterator pointing to the
//! newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(insert_const_ref_type x)
- { return priv_insert(x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(T &x)
- { return this->insert(const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert(const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(u); }
- #endif
+ iterator insert(const value_type &x);
//! <b>Effects</b>: Inserts a copy of x in the container.
//!
@@ -980,9 +1037,12 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(BOOST_RV_REF(value_type) x)
- { return m_tree.insert_equal(boost::move(x)); }
+ iterator insert(value_type &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
+ #endif
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts a copy of x in the container.
//! p is a hint pointing to where the insert should start to search.
//!
@@ -991,18 +1051,7 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(const_iterator p, insert_const_ref_type x)
- { return priv_insert(p, x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(const_iterator position, T &x)
- { return this->insert(position, const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert( const_iterator position, const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_insert(position, u); }
- #endif
+ iterator insert(const_iterator p, const value_type &x);
//! <b>Effects</b>: Inserts a value move constructed from x in the container.
//! p is a hint pointing to where the insert should start to search.
@@ -1012,8 +1061,10 @@
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
- { return m_tree.insert_equal(p, boost::move(x)); }
+ iterator insert(const_iterator position, value_type &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator)
+ #endif
//! <b>Requires</b>: first, last are not iterators into *this.
//!
@@ -1024,47 +1075,6 @@
void insert(InputIterator first, InputIterator last)
{ m_tree.insert_equal(first, last); }
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... and returns the iterator pointing to the
- //! newly inserted element.
- //!
- //! <b>Complexity</b>: Logarithmic.
- template <class... Args>
- iterator emplace(Args&&... args)
- { return m_tree.emplace_equal(boost::forward<Args>(args)...); }
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)...
- //!
- //! <b>Returns</b>: An iterator pointing to the element with key equivalent
- //! to the key of x.
- //!
- //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
- //! is inserted right before p.
- template <class... Args>
- iterator emplace_hint(const_iterator hint, Args&&... args)
- { return m_tree.emplace_hint_equal(hint, boost::forward<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, >) \
- iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_tree.emplace_equal(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(const_iterator hint \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { return m_tree.emplace_hint_equal(hint \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
//! <b>Effects</b>: Erases the element pointed to by p.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
@@ -1091,6 +1101,14 @@
iterator erase(const_iterator first, const_iterator last)
{ return m_tree.erase(first, last); }
+ //! <b>Effects</b>: Swaps the contents of *this and x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ void swap(multiset& x)
+ { m_tree.swap(x.m_tree); }
+
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
@@ -1099,6 +1117,32 @@
void clear()
{ m_tree.clear(); }
+ //////////////////////////////////////////////
+ //
+ // observers
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns the comparison object out
+ //! of which a was constructed.
+ //!
+ //! <b>Complexity</b>: Constant.
+ key_compare key_comp() const
+ { return m_tree.key_comp(); }
+
+ //! <b>Effects</b>: Returns an object of value_compare constructed out
+ //! of the comparison object.
+ //!
+ //! <b>Complexity</b>: Constant.
+ value_compare value_comp() const
+ { return m_tree.key_comp(); }
+
+ //////////////////////////////////////////////
+ //
+ // set operations
+ //
+ //////////////////////////////////////////////
+
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
@@ -1106,7 +1150,7 @@
iterator find(const key_type& x)
{ return m_tree.find(x); }
- //! <b>Returns</b>: A const iterator pointing to an element with the key
+ //! <b>Returns</b>: Allocator const iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
@@ -1126,7 +1170,7 @@
iterator lower_bound(const key_type& x)
{ return m_tree.lower_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1140,7 +1184,7 @@
iterator upper_bound(const key_type& x)
{ return m_tree.upper_bound(x); }
- //! <b>Returns</b>: A const iterator pointing to the first element with key not
+ //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
@@ -1150,15 +1194,13 @@
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<iterator,iterator>
- equal_range(const key_type& x)
+ std::pair<iterator,iterator> equal_range(const key_type& x)
{ return m_tree.equal_range(x); }
//! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
//!
//! <b>Complexity</b>: Logarithmic
- std::pair<const_iterator, const_iterator>
- equal_range(const key_type& x) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
{ return m_tree.equal_range(x); }
/// @cond
@@ -1169,47 +1211,49 @@
friend bool operator< (const multiset<K1,C1,A1>&,
const multiset<K1,C1,A1>&);
private:
- iterator priv_insert(const T &x)
- { return m_tree.insert_equal(x); }
-
- iterator priv_insert(const_iterator p, const T &x)
- { return m_tree.insert_equal(p, x); }
+ template <class KeyType>
+ iterator priv_insert(BOOST_FWD_REF(KeyType) x)
+ { return m_tree.insert_equal(::boost::forward<KeyType>(x)); }
+
+ template <class KeyType>
+ iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
+ { return m_tree.insert_equal(p, ::boost::forward<KeyType>(x)); }
/// @endcond
};
-template <class T, class Pred, class A>
-inline bool operator==(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator==(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y)
{ return x.m_tree == y.m_tree; }
-template <class T, class Pred, class A>
-inline bool operator<(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y)
{ return x.m_tree < y.m_tree; }
-template <class T, class Pred, class A>
-inline bool operator!=(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator!=(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y)
{ return !(x == y); }
-template <class T, class Pred, class A>
-inline bool operator>(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y)
{ return y < x; }
-template <class T, class Pred, class A>
-inline bool operator<=(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator<=(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y)
{ return !(y < x); }
-template <class T, class Pred, class A>
-inline bool operator>=(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline bool operator>=(const multiset<Key,Compare,Allocator>& x,
+ const multiset<Key,Compare,Allocator>& y)
{ return !(x < y); }
-template <class T, class Pred, class A>
-inline void swap(multiset<T,Pred,A>& x, multiset<T,Pred,A>& y)
+template <class Key, class Compare, class Allocator>
+inline void swap(multiset<Key,Compare,Allocator>& x, multiset<Key,Compare,Allocator>& y)
{ x.swap(y); }
/// @cond
@@ -1218,10 +1262,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class C, class A>
-struct has_trivial_destructor_after_move<boost::container::multiset<T, C, A> >
+template <class Key, class C, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::multiset<Key, C, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value && has_trivial_destructor<C>::value;
};
*/
namespace container {
Modified: trunk/boost/container/slist.hpp
==============================================================================
--- trunk/boost/container/slist.hpp (original)
+++ trunk/boost/container/slist.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -44,17 +44,12 @@
#include <functional>
#include <algorithm>
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
namespace boost {
namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
/// @cond
-template <class T, class A>
+template <class T, class Allocator>
class slist;
namespace container_detail {
@@ -78,10 +73,10 @@
T m_data;
};
-template<class A>
+template<class Allocator>
struct intrusive_slist_type
{
- typedef boost::container::allocator_traits<A> allocator_traits_type;
+ typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
typedef typename allocator_traits_type::value_type value_type;
typedef typename boost::intrusive::pointer_traits
<typename allocator_traits_type::pointer>::template
@@ -230,18 +225,18 @@
//! needs, and that you often need to use insert and erase in the middle of the list,
//! then you should probably use list instead of slist.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class A = std::allocator<T> >
+template <class T, class Allocator = std::allocator<T> >
#else
-template <class T, class A>
+template <class T, class Allocator>
#endif
class slist
: protected container_detail::node_alloc_holder
- <A, typename container_detail::intrusive_slist_type<A>::type>
+ <Allocator, typename container_detail::intrusive_slist_type<Allocator>::type>
{
/// @cond
typedef typename
- container_detail::intrusive_slist_type<A>::type Icont;
- typedef container_detail::node_alloc_holder<A, Icont> AllocHolder;
+ container_detail::intrusive_slist_type<Allocator>::type Icont;
+ typedef container_detail::node_alloc_holder<Allocator, Icont> AllocHolder;
typedef typename AllocHolder::NodePtr NodePtr;
typedef typename AllocHolder::NodeAlloc NodeAlloc;
typedef typename AllocHolder::ValAlloc ValAlloc;
@@ -250,7 +245,7 @@
typedef typename AllocHolder::allocator_v1 allocator_v1;
typedef typename AllocHolder::allocator_v2 allocator_v2;
typedef typename AllocHolder::alloc_version alloc_version;
- typedef boost::container::allocator_traits<A> allocator_traits_type;
+ typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
class equal_to_value
{
@@ -294,13 +289,13 @@
//////////////////////////////////////////////
typedef T value_type;
- typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
- typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits<A>::reference reference;
- typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
- typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
- typedef A allocator_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator 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;
@@ -1607,14 +1602,14 @@
/// @endcond
};
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator==(const slist<T,A>& x, const slist<T,A>& y)
+operator==(const slist<T,Allocator>& x, const slist<T,Allocator>& y)
{
if(x.size() != y.size()){
return false;
}
- typedef typename slist<T,A>::const_iterator const_iterator;
+ typedef typename slist<T,Allocator>::const_iterator const_iterator;
const_iterator end1 = x.end();
const_iterator i1 = x.begin();
@@ -1626,36 +1621,36 @@
return i1 == end1;
}
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator<(const slist<T,A>& sL1, const slist<T,A>& sL2)
+operator<(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
{
return std::lexicographical_compare
(sL1.begin(), sL1.end(), sL2.begin(), sL2.end());
}
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator!=(const slist<T,A>& sL1, const slist<T,A>& sL2)
+operator!=(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
{ return !(sL1 == sL2); }
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator>(const slist<T,A>& sL1, const slist<T,A>& sL2)
+operator>(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
{ return sL2 < sL1; }
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator<=(const slist<T,A>& sL1, const slist<T,A>& sL2)
+operator<=(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
{ return !(sL2 < sL1); }
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator>=(const slist<T,A>& sL1, const slist<T,A>& sL2)
+operator>=(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
{ return !(sL1 < sL2); }
-template <class T, class A>
-inline void swap(slist<T,A>& x, slist<T,A>& y)
+template <class T, class Allocator>
+inline void swap(slist<T,Allocator>& x, slist<T,Allocator>& y)
{ x.swap(y); }
}}
@@ -1666,10 +1661,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class A>
-struct has_trivial_destructor_after_move<boost::container::slist<T, A> >
+template <class T, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::slist<T, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value;
};
*/
namespace container {
@@ -1687,11 +1682,11 @@
//there is no other way
namespace std {
-template <class T, class A>
-class insert_iterator<boost::container::slist<T, A> >
+template <class T, class Allocator>
+class insert_iterator<boost::container::slist<T, Allocator> >
{
protected:
- typedef boost::container::slist<T, A> Container;
+ typedef boost::container::slist<T, Allocator> Container;
Container* container;
typename Container::iterator iter;
public:
@@ -1724,4 +1719,4 @@
#include <boost/container/detail/config_end.hpp>
-#endif /* BOOST_CONTAINER_SLIST_HPP */
+#endif // BOOST_CONTAINER_SLIST_HPP
Modified: trunk/boost/container/stable_vector.hpp
==============================================================================
--- trunk/boost/container/stable_vector.hpp (original)
+++ trunk/boost/container/stable_vector.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -275,26 +275,6 @@
node_ptr pn;
};
-template<class A, unsigned int Version>
-struct select_multiallocation_chain
-{
- typedef typename A::multiallocation_chain type;
-};
-
-template<class A>
-struct select_multiallocation_chain<A, 1>
-{
- typedef typename boost::intrusive::pointer_traits
- <typename allocator_traits<A>::pointer>::
- template rebind_pointer<void>::type void_ptr;
- typedef container_detail::basic_multiallocation_chain
- <void_ptr> multialloc_cached_counted;
- typedef boost::container::container_detail::
- transform_multiallocation_chain
- < multialloc_cached_counted
- , typename allocator_traits<A>::value_type> type;
-};
-
template<class VoidPtr, class VoidAllocator>
struct index_traits
{
@@ -386,6 +366,89 @@
#endif //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
};
+template<class Allocator, unsigned Version = boost::container::container_detail::version<Allocator>::value>
+struct allocator_version_wrapper
+{
+ typedef ::boost::container::container_detail::integral_constant
+ <unsigned, Version> alloc_version;
+
+ typedef typename Allocator::multiallocation_chain multiallocation_chain;
+
+ typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
+
+ static pointer allocate_one(Allocator &a)
+ { return a.allocate_one(); }
+
+ static void deallocate_one(Allocator &a, const pointer &p)
+ { a.deallocate_one(p); }
+
+ static multiallocation_chain allocate_individual(Allocator &a, size_type n)
+ { return a.allocate_individual(n); }
+
+ static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
+ { a.deallocate_individual(::boost::move(holder)); }
+};
+
+template<class Allocator>
+struct allocator_version_wrapper<Allocator, 1>
+{
+ typedef ::boost::container::container_detail::integral_constant
+ <unsigned, 1> alloc_version;
+
+ typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename boost::container::allocator_traits<Allocator>::value_type value_type;
+
+ typedef typename boost::intrusive::pointer_traits<pointer>::
+ template rebind_pointer<void>::type void_ptr;
+ typedef container_detail::basic_multiallocation_chain
+ <void_ptr> multialloc_cached_counted;
+ typedef boost::container::container_detail::
+ transform_multiallocation_chain
+ < multialloc_cached_counted, value_type> multiallocation_chain;
+
+ static pointer allocate_one(Allocator &a)
+ { return a.allocate(1); }
+
+ static void deallocate_one(Allocator &a, const pointer &p)
+ { a.deallocate(p, 1); }
+
+ static void deallocate_individual(Allocator &a, multiallocation_chain &holder)
+ {
+ while(!holder.empty()){
+ a.deallocate(holder.pop_front(), 1);
+ }
+ }
+
+ struct allocate_individual_rollback
+ {
+ allocate_individual_rollback(Allocator &a, multiallocation_chain &chain)
+ : mr_a(a), mr_chain(chain)
+ {}
+
+ ~allocate_individual_rollback()
+ {
+ allocator_version_wrapper::deallocate_individual(mr_a, mr_chain);
+ }
+
+ Allocator &mr_a;
+ multiallocation_chain &mr_chain;
+ };
+
+ static multiallocation_chain allocate_individual(Allocator &a, size_type n)
+ {
+ multiallocation_chain m;
+ multiallocation_chain m_ret;
+ allocate_individual_rollback rollback(a, m);
+ while(n--){
+ m.push_front(a.allocate(1));
+ }
+ m.swap(m_ret);
+ return ::boost::move(m_ret);
+ }
+};
+
} //namespace stable_vector_detail
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -438,14 +501,14 @@
//! Exception safety: As stable_vector does not internally copy elements around, some
//! operations provide stronger exception safety guarantees than in std::vector.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class A = std::allocator<T> >
+template <class T, class Allocator = std::allocator<T> >
#else
-template <class T, class A>
+template <class T, class Allocator>
#endif
class stable_vector
{
///@cond
- typedef allocator_traits<A> allocator_traits_type;
+ typedef allocator_traits<Allocator> allocator_traits_type;
typedef typename boost::intrusive::pointer_traits
<typename allocator_traits_type::pointer>::
template rebind_pointer<void>::type void_ptr;
@@ -487,125 +550,35 @@
integral_constant<unsigned, 2> allocator_v2;
typedef ::boost::container::container_detail::integral_constant
<unsigned, boost::container::container_detail::
- version<A>::value> alloc_version;
+ version<Allocator>::value> alloc_version;
typedef typename allocator_traits_type::
template portable_rebind_alloc
<node_type>::type node_allocator_type;
- typedef typename stable_vector_detail::
- select_multiallocation_chain
- < node_allocator_type
- , alloc_version::value
- >::type multiallocation_chain;
+
+ typedef stable_vector_detail::allocator_version_wrapper<node_allocator_type> allocator_version_wrapper_t;
+ typedef typename allocator_version_wrapper_t::multiallocation_chain multiallocation_chain;
node_ptr allocate_one()
- { return this->allocate_one(alloc_version()); }
+ { return allocator_version_wrapper_t::allocate_one(this->priv_node_alloc()); }
- template<class AllocatorVersion>
- node_ptr allocate_one(AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- { return this->priv_node_alloc().allocate(1); }
-
- template<class AllocatorVersion>
- node_ptr allocate_one(AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- { return this->priv_node_alloc().allocate_one(); }
-
- void deallocate_one(node_ptr p)
- { return this->deallocate_one(p, alloc_version()); }
-
- template<class AllocatorVersion>
- void deallocate_one(node_ptr p, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- { this->priv_node_alloc().deallocate(p, 1); }
-
- template<class AllocatorVersion>
- void deallocate_one(node_ptr p, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- { this->priv_node_alloc().deallocate_one(p); }
+ void deallocate_one(const node_ptr &p)
+ { allocator_version_wrapper_t::deallocate_one(this->priv_node_alloc(), p); }
multiallocation_chain allocate_individual(typename allocator_traits_type::size_type n)
- { return this->allocate_individual(n, alloc_version()); }
-
- struct allocate_individual_rollback
- {
- allocate_individual_rollback(stable_vector &sv, multiallocation_chain &chain)
- : mr_sv(sv), mr_chain(chain)
- {}
-
- ~allocate_individual_rollback()
- {
- if(!mr_chain.empty()){
- mr_sv.deallocate_individual(mr_chain);
- }
- }
-
- stable_vector &mr_sv;
- multiallocation_chain &mr_chain;
- };
-
- template<class AllocatorVersion>
- multiallocation_chain allocate_individual
- (typename allocator_traits_type::size_type n, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- {
- multiallocation_chain m;
- multiallocation_chain m_ret;
- allocate_individual_rollback rollback(*this, m);
- while(n--){
- m.push_front(this->allocate_one());
- }
- m.swap(m_ret);
- return ::boost::move(m_ret);
- }
-
- template<class AllocatorVersion>
- multiallocation_chain allocate_individual
- (typename allocator_traits_type::size_type n, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- { return this->priv_node_alloc().allocate_individual(n); }
+ { return allocator_version_wrapper_t::allocate_individual(this->priv_node_alloc(), n); }
void deallocate_individual(multiallocation_chain &holder)
- { this->deallocate_individual(holder, alloc_version()); }
-
- template<class AllocatorVersion>
- void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- {
- while(!holder.empty()){
- this->deallocate_one(holder.pop_front());
- }
- }
-
- template<class AllocatorVersion>
- void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- { this->priv_node_alloc().deallocate_individual(boost::move(holder)); }
+ { allocator_version_wrapper_t::deallocate_individual(this->priv_node_alloc(), holder); }
friend class stable_vector_detail::clear_on_destroy<stable_vector>;
typedef stable_vector_detail::iterator
< T
- , typename allocator_traits<A>::reference
- , typename allocator_traits<A>::pointer> iterator_impl;
+ , typename allocator_traits<Allocator>::reference
+ , typename allocator_traits<Allocator>::pointer> iterator_impl;
typedef stable_vector_detail::iterator
< T
- , typename allocator_traits<A>::const_reference
- , typename allocator_traits<A>::const_pointer> const_iterator_impl;
+ , typename allocator_traits<Allocator>::const_reference
+ , typename allocator_traits<Allocator>::const_pointer> const_iterator_impl;
///@endcond
public:
@@ -614,19 +587,19 @@
// types
//
//////////////////////////////////////////////
- typedef T value_type;
- typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
- typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits<A>::reference reference;
- typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
- typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
- typedef A 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;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator 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;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
///@cond
private:
@@ -1863,46 +1836,46 @@
/// @endcond
};
-template <typename T,typename A>
-bool operator==(const stable_vector<T,A>& x,const stable_vector<T,A>& y)
+template <typename T,typename Allocator>
+bool operator==(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
{
return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin());
}
-template <typename T,typename A>
-bool operator< (const stable_vector<T,A>& x,const stable_vector<T,A>& y)
+template <typename T,typename Allocator>
+bool operator< (const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
{
return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
}
-template <typename T,typename A>
-bool operator!=(const stable_vector<T,A>& x,const stable_vector<T,A>& y)
+template <typename T,typename Allocator>
+bool operator!=(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
{
return !(x==y);
}
-template <typename T,typename A>
-bool operator> (const stable_vector<T,A>& x,const stable_vector<T,A>& y)
+template <typename T,typename Allocator>
+bool operator> (const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
{
return y<x;
}
-template <typename T,typename A>
-bool operator>=(const stable_vector<T,A>& x,const stable_vector<T,A>& y)
+template <typename T,typename Allocator>
+bool operator>=(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
{
return !(x<y);
}
-template <typename T,typename A>
-bool operator<=(const stable_vector<T,A>& x,const stable_vector<T,A>& y)
+template <typename T,typename Allocator>
+bool operator<=(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
{
return !(x>y);
}
// specialized algorithms:
-template <typename T, typename A>
-void swap(stable_vector<T,A>& x,stable_vector<T,A>& y)
+template <typename T, typename Allocator>
+void swap(stable_vector<T,Allocator>& x,stable_vector<T,Allocator>& y)
{
x.swap(y);
}
Modified: trunk/boost/container/string.hpp
==============================================================================
--- trunk/boost/container/string.hpp (original)
+++ trunk/boost/container/string.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -84,14 +84,14 @@
// memory. The destructor assumes that the memory either is the internal buffer,
// or else points to a block of memory that was allocated using _String_base's
// allocator and whose size is this->m_storage.
-template <class A>
+template <class Allocator>
class basic_string_base
{
BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_string_base)
- typedef allocator_traits<A> allocator_traits_type;
+ typedef allocator_traits<Allocator> allocator_traits_type;
public:
- typedef A allocator_type;
+ typedef Allocator allocator_type;
//! The stored allocator type
typedef allocator_type stored_allocator_type;
typedef typename allocator_traits_type::pointer pointer;
@@ -211,24 +211,24 @@
};
struct members_holder
- : public A
+ : public Allocator
{
members_holder()
- : A()
+ : Allocator()
{}
template<class AllocatorConvertible>
explicit members_holder(BOOST_FWD_REF(AllocatorConvertible) a)
- : A(boost::forward<AllocatorConvertible>(a))
+ : Allocator(boost::forward<AllocatorConvertible>(a))
{}
repr_t m_repr;
} members_;
- const A &alloc() const
+ const Allocator &alloc() const
{ return members_; }
- A &alloc()
+ Allocator &alloc()
{ return members_; }
static const size_type InternalBufferChars = (sizeof(repr_t) - ShortDataOffset)/sizeof(value_type);
@@ -272,7 +272,7 @@
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<A>::value> alloc_version;
+ boost::container::container_detail::version<Allocator>::value> alloc_version;
std::pair<pointer, bool>
allocation_command(allocation_type command,
@@ -521,22 +521,22 @@
//! In this implementation, iterators are only invalidated by member functions that
//! explicitly change the string's contents.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class CharT, class Traits = std::char_traits<CharT>, class A = std::allocator<CharT> >
+template <class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT> >
#else
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
#endif
class basic_string
- : private container_detail::basic_string_base<A>
+ : private container_detail::basic_string_base<Allocator>
{
/// @cond
private:
- typedef allocator_traits<A> allocator_traits_type;
+ typedef allocator_traits<Allocator> allocator_traits_type;
BOOST_COPYABLE_AND_MOVABLE(basic_string)
- typedef container_detail::basic_string_base<A> base_t;
+ typedef container_detail::basic_string_base<Allocator> base_t;
static const typename base_t::size_type InternalBufferChars = base_t::InternalBufferChars;
protected:
- // A helper class to use a char_traits as a function object.
+ // Allocator helper class to use a char_traits as a function object.
template <class Tr>
struct Eq_traits
@@ -571,7 +571,7 @@
public:
//! The allocator type
- typedef A allocator_type;
+ typedef Allocator allocator_type;
//! The stored allocator type
typedef allocator_type stored_allocator_type;
//! The type of object, CharT, stored in the string
@@ -1892,7 +1892,7 @@
//! <b>Requires</b>: The program shall not alter any of the values stored in the character array.
//!
- //! <b>Returns</b>: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
+ //! <b>Returns</b>: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()].
//!
//! <b>Complexity</b>: constant time.
const CharT* c_str() const
@@ -1900,7 +1900,7 @@
//! <b>Requires</b>: The program shall not alter any of the values stored in the character array.
//!
- //! <b>Returns</b>: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
+ //! <b>Returns</b>: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()].
//!
//! <b>Complexity</b>: constant time.
const CharT* data() const
@@ -2483,10 +2483,10 @@
/// @cond
-template <class CharT, class Traits, class A>
-const typename basic_string<CharT,Traits,A>::size_type
-basic_string<CharT,Traits,A>::npos
- = (typename basic_string<CharT,Traits,A>::size_type) -1;
+template <class CharT, class Traits, class Allocator>
+const typename basic_string<CharT,Traits,Allocator>::size_type
+basic_string<CharT,Traits,Allocator>::npos
+ = (typename basic_string<CharT,Traits,Allocator>::size_type) -1;
/// @endcond
@@ -2495,273 +2495,212 @@
// Operator+
-template <class CharT, class Traits, class A>
-inline basic_string<CharT,Traits,A>
-operator+(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT,Traits,Allocator>
+ operator+(const basic_string<CharT,Traits,Allocator>& x
+ ,const basic_string<CharT,Traits,Allocator>& y)
{
- typedef basic_string<CharT,Traits,A> str_t;
+ typedef basic_string<CharT,Traits,Allocator> str_t;
typedef typename str_t::reserve_t reserve_t;
reserve_t reserve;
str_t result(reserve, x.size() + y.size(), x.get_stored_allocator());
result.append(x);
result.append(y);
- return boost::move(result);
+ return result;
}
-template <class CharT, class Traits, class A> inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
- operator+(
- BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
- , BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT, Traits, Allocator> operator+
+ ( BOOST_RV_REF_BEG basic_string<CharT, Traits, Allocator> BOOST_RV_REF_END mx
+ , BOOST_RV_REF_BEG basic_string<CharT, Traits, Allocator> BOOST_RV_REF_END my)
{
mx += my;
return boost::move(mx);
}
-template <class CharT, class Traits, class A> inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
- operator+(
- BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
- , const basic_string<CharT,Traits,A>& y)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT, Traits, Allocator> operator+
+ ( BOOST_RV_REF_BEG basic_string<CharT, Traits, Allocator> BOOST_RV_REF_END mx
+ , const basic_string<CharT,Traits,Allocator>& y)
{
mx += y;
return boost::move(mx);
}
-template <class CharT, class Traits, class A> inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
- operator+(const basic_string<CharT,Traits,A>& x,
- BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT, Traits, Allocator> operator+
+ (const basic_string<CharT,Traits,Allocator>& x
+ ,BOOST_RV_REF_BEG basic_string<CharT, Traits, Allocator> BOOST_RV_REF_END my)
{
- typedef typename basic_string<CharT,Traits,A>::size_type size_type;
- my.replace(size_type(0), size_type(0), x);
+ my.insert(my.begin(), x.begin(), x.end());
return boost::move(my);
}
-template <class CharT, class Traits, class A>
-inline basic_string<CharT,Traits,A>
-operator+(const CharT* s, const basic_string<CharT,Traits,A>& y)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT, Traits, Allocator> operator+
+ (const CharT* s, basic_string<CharT, Traits, Allocator> y)
{
- typedef basic_string<CharT, Traits, A> str_t;
- typedef typename str_t::reserve_t reserve_t;
- reserve_t reserve;
- const typename str_t::size_type n = Traits::length(s);
- str_t result(reserve, n + y.size());
- result.append(s, s + n);
- result.append(y);
- return boost::move(result);
-}
-
-template <class CharT, class Traits, class A> inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+(const CharT* s,
- BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
-{
- typedef typename basic_string<CharT,Traits,A>::size_type size_type;
- return boost::move(my.replace(size_type(0), size_type(0), s));
-}
-
-template <class CharT, class Traits, class A>
-inline basic_string<CharT,Traits,A>
-operator+(CharT c, const basic_string<CharT,Traits,A>& y)
-{
- typedef basic_string<CharT,Traits,A> str_t;
- typedef typename str_t::reserve_t reserve_t;
- reserve_t reserve;
- str_t result(reserve, 1 + y.size());
- result.push_back(c);
- result.append(y);
- return boost::move(result);
-}
-
-template <class CharT, class Traits, class A> inline
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+(CharT c,
- BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my)
-{
- typedef typename basic_string<CharT,Traits,A>::size_type size_type;
- return boost::move(my.replace(size_type(0), size_type(0), &c, &c + 1));
+ y.insert(y.begin(), s, s + Traits::length(s));
+ return y;
}
-template <class CharT, class Traits, class A>
-inline basic_string<CharT,Traits,A>
-operator+(const basic_string<CharT,Traits,A>& x, const CharT* s)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT,Traits,Allocator> operator+
+ (basic_string<CharT,Traits,Allocator> x, const CharT* s)
{
- typedef basic_string<CharT,Traits,A> str_t;
- typedef typename str_t::reserve_t reserve_t;
- reserve_t reserve;
- const typename str_t::size_type n = Traits::length(s);
- str_t result(reserve, x.size() + n, x.get_stored_allocator());
- result.append(x);
- result.append(s, s + n);
- return boost::move(result);
+ x += s;
+ return x;
}
-template <class CharT, class Traits, class A>
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+(BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
- , const CharT* s)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT,Traits,Allocator> operator+
+ (CharT c, basic_string<CharT,Traits,Allocator> y)
{
- mx += s;
- return boost::move(mx);
+ y.insert(y.begin(), c);
+ return y;
}
-template <class CharT, class Traits, class A>
-inline basic_string<CharT,Traits,A>
-operator+(const basic_string<CharT,Traits,A>& x, const CharT c)
+template <class CharT, class Traits, class Allocator> inline
+ basic_string<CharT,Traits,Allocator> operator+
+ (basic_string<CharT,Traits,Allocator> x, const CharT c)
{
- typedef basic_string<CharT,Traits,A> str_t;
- typedef typename str_t::reserve_t reserve_t;
- reserve_t reserve;
- str_t result(reserve, x.size() + 1, x.get_stored_allocator());
- result.append(x);
- result.push_back(c);
- return boost::move(result);
-}
-
-template <class CharT, class Traits, class A>
-BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
-operator+( BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
- , const CharT c)
-{
- mx += c;
- return boost::move(mx);
+ x += c;
+ return x;
}
// Operator== and operator!=
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator==(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+operator==(const basic_string<CharT,Traits,Allocator>& x,
+ const basic_string<CharT,Traits,Allocator>& y)
{
return x.size() == y.size() &&
Traits::compare(x.data(), y.data(), x.size()) == 0;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator==(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator==(const CharT* s, const basic_string<CharT,Traits,Allocator>& y)
{
- typename basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
+ typename basic_string<CharT,Traits,Allocator>::size_type n = Traits::length(s);
return n == y.size() && Traits::compare(s, y.data(), n) == 0;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator==(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator==(const basic_string<CharT,Traits,Allocator>& x, const CharT* s)
{
- typename basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
+ typename basic_string<CharT,Traits,Allocator>::size_type n = Traits::length(s);
return x.size() == n && Traits::compare(x.data(), s, n) == 0;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator!=(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+operator!=(const basic_string<CharT,Traits,Allocator>& x,
+ const basic_string<CharT,Traits,Allocator>& y)
{ return !(x == y); }
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator!=(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator!=(const CharT* s, const basic_string<CharT,Traits,Allocator>& y)
{ return !(s == y); }
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator!=(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator!=(const basic_string<CharT,Traits,Allocator>& x, const CharT* s)
{ return !(x == s); }
// Operator< (and also >, <=, and >=).
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator<(const basic_string<CharT,Traits,A>& x, const basic_string<CharT,Traits,A>& y)
+operator<(const basic_string<CharT,Traits,Allocator>& x, const basic_string<CharT,Traits,Allocator>& y)
{
return x.compare(y) < 0;
-// return basic_string<CharT,Traits,A>
+// return basic_string<CharT,Traits,Allocator>
// ::s_compare(x.begin(), x.end(), y.begin(), y.end()) < 0;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator<(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator<(const CharT* s, const basic_string<CharT,Traits,Allocator>& y)
{
return y.compare(s) > 0;
-// basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
-// return basic_string<CharT,Traits,A>
+// basic_string<CharT,Traits,Allocator>::size_type n = Traits::length(s);
+// return basic_string<CharT,Traits,Allocator>
// ::s_compare(s, s + n, y.begin(), y.end()) < 0;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator<(const basic_string<CharT,Traits,A>& x,
+operator<(const basic_string<CharT,Traits,Allocator>& x,
const CharT* s)
{
return x.compare(s) < 0;
-// basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
-// return basic_string<CharT,Traits,A>
+// basic_string<CharT,Traits,Allocator>::size_type n = Traits::length(s);
+// return basic_string<CharT,Traits,Allocator>
// ::s_compare(x.begin(), x.end(), s, s + n) < 0;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator>(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y) {
+operator>(const basic_string<CharT,Traits,Allocator>& x,
+ const basic_string<CharT,Traits,Allocator>& y) {
return y < x;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator>(const CharT* s, const basic_string<CharT,Traits,A>& y) {
+operator>(const CharT* s, const basic_string<CharT,Traits,Allocator>& y) {
return y < s;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator>(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator>(const basic_string<CharT,Traits,Allocator>& x, const CharT* s)
{
return s < x;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator<=(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+operator<=(const basic_string<CharT,Traits,Allocator>& x,
+ const basic_string<CharT,Traits,Allocator>& y)
{
return !(y < x);
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator<=(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator<=(const CharT* s, const basic_string<CharT,Traits,Allocator>& y)
{ return !(y < s); }
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator<=(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator<=(const basic_string<CharT,Traits,Allocator>& x, const CharT* s)
{ return !(s < x); }
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator>=(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+operator>=(const basic_string<CharT,Traits,Allocator>& x,
+ const basic_string<CharT,Traits,Allocator>& y)
{ return !(x < y); }
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator>=(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator>=(const CharT* s, const basic_string<CharT,Traits,Allocator>& y)
{ return !(s < y); }
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline bool
-operator>=(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator>=(const basic_string<CharT,Traits,Allocator>& x, const CharT* s)
{ return !(x < s); }
// Swap.
-template <class CharT, class Traits, class A>
-inline void swap(basic_string<CharT,Traits,A>& x, basic_string<CharT,Traits,A>& y)
+template <class CharT, class Traits, class Allocator>
+inline void swap(basic_string<CharT,Traits,Allocator>& x, basic_string<CharT,Traits,Allocator>& y)
{ x.swap(y); }
/// @cond
@@ -2786,17 +2725,17 @@
} //namespace container_detail {
/// @endcond
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
std::basic_ostream<CharT, Traits>&
-operator<<(std::basic_ostream<CharT, Traits>& os, const basic_string<CharT,Traits,A>& s)
+operator<<(std::basic_ostream<CharT, Traits>& os, const basic_string<CharT,Traits,Allocator>& s)
{
typename std::basic_ostream<CharT, Traits>::sentry sentry(os);
bool ok = false;
if (sentry) {
ok = true;
- typename basic_string<CharT,Traits,A>::size_type n = s.size();
- typename basic_string<CharT,Traits,A>::size_type pad_len = 0;
+ typename basic_string<CharT,Traits,Allocator>::size_type n = s.size();
+ typename basic_string<CharT,Traits,Allocator>::size_type pad_len = 0;
const bool left = (os.flags() & std::ios::left) != 0;
const std::size_t w = os.width(0);
std::basic_streambuf<CharT, Traits>* buf = os.rdbuf();
@@ -2821,9 +2760,9 @@
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
std::basic_istream<CharT, Traits>&
-operator>>(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,A>& s)
+operator>>(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,Allocator>& s)
{
typename std::basic_istream<CharT, Traits>::sentry sentry(is);
@@ -2868,11 +2807,11 @@
return is;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
std::basic_istream<CharT, Traits>&
-getline(std::istream& is, basic_string<CharT,Traits,A>& s,CharT delim)
+getline(std::istream& is, basic_string<CharT,Traits,Allocator>& s,CharT delim)
{
- typename basic_string<CharT,Traits,A>::size_type nread = 0;
+ typename basic_string<CharT,Traits,Allocator>::size_type nread = 0;
typename std::basic_istream<CharT, Traits>::sentry sentry(is, true);
if (sentry) {
std::basic_streambuf<CharT, Traits>* buf = is.rdbuf();
@@ -2900,15 +2839,15 @@
return is;
}
-template <class CharT, class Traits, class A>
+template <class CharT, class Traits, class Allocator>
inline std::basic_istream<CharT, Traits>&
-getline(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,A>& s)
+getline(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,Allocator>& s)
{
return getline(is, s, '\n');
}
-template <class Ch, class A>
-inline std::size_t hash_value(basic_string<Ch, std::char_traits<Ch>, A> const& v)
+template <class Ch, class Allocator>
+inline std::size_t hash_value(basic_string<Ch, std::char_traits<Ch>, Allocator> const& v)
{
return hash_range(v.begin(), v.end());
}
@@ -2921,10 +2860,10 @@
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class C, class T, class A>
-struct has_trivial_destructor_after_move<boost::container::basic_string<C, T, A> >
+template <class C, class T, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::basic_string<C, T, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value;
};
*/
}
Modified: trunk/boost/container/vector.hpp
==============================================================================
--- trunk/boost/container/vector.hpp (original)
+++ trunk/boost/container/vector.hpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -207,11 +207,11 @@
{ return static_cast<const vector_const_iterator<Pointer>&>(*this) - right; }
};
-template <class T, class A>
+template <class T, class Allocator>
struct vector_value_traits
{
typedef T value_type;
- typedef A allocator_type;
+ typedef Allocator allocator_type;
static const bool trivial_dctr = boost::has_trivial_destructor<value_type>::value;
static const bool trivial_dctr_after_move = trivial_dctr;
//::boost::has_trivial_destructor_after_move<value_type>::value || trivial_dctr;
@@ -229,37 +229,37 @@
//to deallocate values already constructed
typedef typename container_detail::if_c
<trivial_dctr
- ,container_detail::null_scoped_destructor_n<A>
- ,container_detail::scoped_destructor_n<A>
+ ,container_detail::null_scoped_destructor_n<Allocator>
+ ,container_detail::scoped_destructor_n<Allocator>
>::type OldArrayDestructor;
//This is the anti-exception array destructor
//to destroy objects created with copy construction
typedef typename container_detail::if_c
<nothrow_copy
- ,container_detail::null_scoped_destructor_n<A>
- ,container_detail::scoped_destructor_n<A>
+ ,container_detail::null_scoped_destructor_n<Allocator>
+ ,container_detail::scoped_destructor_n<Allocator>
>::type ArrayDestructor;
//This is the anti-exception array deallocator
typedef typename container_detail::if_c
<nothrow_copy
- ,container_detail::null_scoped_array_deallocator<A>
- ,container_detail::scoped_array_deallocator<A>
+ ,container_detail::null_scoped_array_deallocator<Allocator>
+ ,container_detail::scoped_array_deallocator<Allocator>
>::type ArrayDeallocator;
};
//!This struct deallocates and allocated memory
-template <class A>
+template <class Allocator>
struct vector_alloc_holder
{
- typedef boost::container::allocator_traits<A> allocator_traits_type;
+ typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
typedef typename allocator_traits_type::pointer pointer;
typedef typename allocator_traits_type::size_type size_type;
typedef typename allocator_traits_type::value_type value_type;
- typedef vector_value_traits<value_type, A> value_traits;
+ typedef vector_value_traits<value_type, Allocator> value_traits;
//Constructor, does not throw
vector_alloc_holder()
- BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor<A>::value)
+ BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor<Allocator>::value)
: members_()
{}
@@ -279,7 +279,7 @@
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<A>::value> alloc_version;
+ boost::container::container_detail::version<Allocator>::value> alloc_version;
std::pair<pointer, bool>
allocation_command(allocation_type command,
size_type limit_size,
@@ -325,7 +325,7 @@
}
struct members_holder
- : public A
+ : public Allocator
{
private:
members_holder(const members_holder&);
@@ -333,11 +333,11 @@
public:
template<class Alloc>
explicit members_holder(BOOST_FWD_REF(Alloc) alloc)
- : A(boost::forward<Alloc>(alloc)), m_start(0), m_size(0), m_capacity(0)
+ : Allocator(boost::forward<Alloc>(alloc)), m_start(0), m_size(0), m_capacity(0)
{}
members_holder()
- : A(), m_start(0), m_size(0), m_capacity(0)
+ : Allocator(), m_start(0), m_size(0), m_capacity(0)
{}
pointer m_start;
@@ -352,10 +352,10 @@
container_detail::do_swap(this->members_.m_capacity, x.members_.m_capacity);
}
- A &alloc()
+ Allocator &alloc()
{ return members_; }
- const A &alloc() const
+ const Allocator &alloc() const
{ return members_; }
protected:
@@ -401,15 +401,15 @@
//! boost::container::vector is similar to std::vector but it's compatible
//! with shared memory and memory mapped files.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class T, class A = std::allocator<T> >
+template <class T, class Allocator = std::allocator<T> >
#else
-template <class T, class A>
+template <class T, class Allocator>
#endif
-class vector : private container_detail::vector_alloc_holder<A>
+class vector : private container_detail::vector_alloc_holder<Allocator>
{
/// @cond
- typedef container_detail::vector_alloc_holder<A> base_t;
- typedef allocator_traits<A> allocator_traits_type;
+ typedef container_detail::vector_alloc_holder<Allocator> base_t;
+ typedef allocator_traits<Allocator> allocator_traits_type;
/// @endcond
public:
//////////////////////////////////////////////
@@ -418,25 +418,25 @@
//
//////////////////////////////////////////////
- typedef T value_type;
- typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
- typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits<A>::reference reference;
- typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
- typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
- typedef A allocator_type;
- typedef allocator_type stored_allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator<pointer>) iterator;
- typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator<pointer>) const_iterator;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef Allocator stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator<pointer>) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator<pointer>) const_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(vector)
typedef container_detail::advanced_insert_aux_int<T*> advanced_insert_aux_int_t;
- typedef container_detail::vector_value_traits<value_type, A> value_traits;
+ typedef container_detail::vector_value_traits<value_type, Allocator> value_traits;
typedef typename base_t::allocator_v1 allocator_v1;
typedef typename base_t::allocator_v2 allocator_v2;
@@ -460,7 +460,7 @@
//!
//! <b>Complexity</b>: Constant.
vector()
- BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor<A>::value)
+ BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor<Allocator>::value)
: base_t()
{}
@@ -469,7 +469,7 @@
//! <b>Throws</b>: Nothing
//!
//! <b>Complexity</b>: Constant.
- explicit vector(const A& a) BOOST_CONTAINER_NOEXCEPT
+ explicit vector(const Allocator& a) BOOST_CONTAINER_NOEXCEPT
: base_t(a)
{}
@@ -857,7 +857,7 @@
else{
const size_type n = new_size - this->size();
this->reserve(new_size);
- container_detail::default_construct_aux_proxy<A, T*> proxy(this->alloc(), n);
+ container_detail::default_construct_aux_proxy<Allocator, T*> proxy(this->alloc(), n);
this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
}
}
@@ -921,7 +921,7 @@
else{
//We will reuse insert code, so create a dummy input iterator
T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start));
- container_detail::advanced_insert_aux_proxy<A, boost::move_iterator<T*>, T*>
+ container_detail::advanced_insert_aux_proxy<Allocator, boost::move_iterator<T*>, T*>
proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it));
//Backwards (and possibly forward) expansion
if(ret.second){
@@ -1060,7 +1060,7 @@
//
//////////////////////////////////////////////
- //! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
+ //! <b>Returns</b>: Allocator pointer such that [data(),data() + size()) is a valid range.
//! For a non-empty vector, data() == &front().
//!
//! <b>Throws</b>: Nothing.
@@ -1069,7 +1069,7 @@
T* data() BOOST_CONTAINER_NOEXCEPT
{ return container_detail::to_raw_pointer(this->members_.m_start); }
- //! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
+ //! <b>Returns</b>: Allocator pointer such that [data(),data() + size()) is a valid range.
//! For a non-empty vector, data() == &front().
//!
//! <b>Throws</b>: Nothing.
@@ -1102,7 +1102,7 @@
++this->members_.m_size;
}
else{
- typedef container_detail::advanced_insert_aux_emplace<A, T*, Args...> type;
+ typedef container_detail::advanced_insert_aux_emplace<Allocator, T*, Args...> type;
type &&proxy = type(this->alloc(), ::boost::forward<Args>(args)...);
this->priv_forward_range_insert(back_pos, 1, proxy);
}
@@ -1123,7 +1123,7 @@
{
//Just call more general insert(pos, size, value) and return iterator
size_type pos_n = position - cbegin();
- typedef container_detail::advanced_insert_aux_emplace<A, T*, Args...> type;
+ typedef container_detail::advanced_insert_aux_emplace<Allocator, T*, Args...> type;
type &&proxy = type(this->alloc(), ::boost::forward<Args>(args)...);
this->priv_forward_range_insert(position.get_ptr(), 1, proxy);
return iterator(this->members_.m_start + pos_n);
@@ -1144,7 +1144,7 @@
} \
else{ \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
- <A, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
+ <Allocator, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
(this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
this->priv_forward_range_insert(back_pos, 1, proxy); \
} \
@@ -1156,7 +1156,7 @@
{ \
size_type pos_n = pos - cbegin(); \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
- <A, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
+ <Allocator, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
(this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
this->priv_forward_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1,proxy);\
return iterator(this->members_.m_start + pos_n); \
@@ -1264,7 +1264,7 @@
{
const size_type n_pos = pos - this->cbegin();
const size_type n = std::distance(first, last);
- container_detail::advanced_insert_aux_proxy<A, FwdIt, T*> proxy(this->alloc(), first, last);
+ container_detail::advanced_insert_aux_proxy<Allocator, FwdIt, T*> proxy(this->alloc(), first, last);
this->priv_forward_range_insert(pos.get_ptr(), n, proxy);
return this->begin() + n_pos;
}
@@ -1395,10 +1395,7 @@
}
}
- template<class AllocVersion>
- void priv_shrink_to_fit( AllocVersion
- , typename container_detail::enable_if_c<
- container_detail::is_same<AllocVersion, allocator_v1>::value >::type * = 0)
+ void priv_shrink_to_fit(allocator_v1)
{
if(this->members_.m_capacity){
if(!this->size()){
@@ -1413,7 +1410,7 @@
if(real_cap < this->capacity()){
//We will reuse insert code, so create a dummy input iterator
T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start));
- container_detail::advanced_insert_aux_proxy<A, boost::move_iterator<T*>, T*>
+ container_detail::advanced_insert_aux_proxy<Allocator, boost::move_iterator<T*>, T*>
proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it));
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
++this->num_alloc;
@@ -1432,10 +1429,7 @@
}
}
- template<class AllocVersion>
- void priv_shrink_to_fit(AllocVersion
- , typename container_detail::enable_if_c<
- !container_detail::is_same<AllocVersion, allocator_v1>::value >::type * = 0)
+ void priv_shrink_to_fit(allocator_v2)
{
if(this->members_.m_capacity){
if(!size()){
@@ -1443,7 +1437,7 @@
}
else{
size_type received_size;
- if(this->alloc().allocation_command
+ if(this->allocation_command
( shrink_in_place | nothrow_allocation
, this->capacity(), this->size()
, received_size, this->members_.m_start).first){
@@ -1598,7 +1592,7 @@
//| prefix | range | suffix |raw_mem ~
//|____________|_______|__________________|_____________~
//
- //New situation in Case A (hole_size == 0):
+ //New situation in Case Allocator (hole_size == 0):
// range is moved through move assignments
//
// first_pos last_pos limit_pos
@@ -1642,7 +1636,7 @@
T* const last_ptr = begin_ptr + last_pos;
size_type hole_size = 0;
- //Case A:
+ //Case Allocator:
if((last_pos + shift_count) <= limit_pos){
//All move assigned
boost::move_backward(first_ptr, last_ptr, last_ptr + shift_count);
@@ -2056,31 +2050,31 @@
/// @endcond
};
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator==(const vector<T, A>& x, const vector<T, A>& y)
+operator==(const vector<T, Allocator>& x, const vector<T, Allocator>& y)
{
//Check first size and each element if needed
return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin());
}
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator!=(const vector<T, A>& x, const vector<T, A>& y)
+operator!=(const vector<T, Allocator>& x, const vector<T, Allocator>& y)
{
//Check first size and each element if needed
return x.size() != y.size() || !std::equal(x.begin(), x.end(), y.begin());
}
-template <class T, class A>
+template <class T, class Allocator>
inline bool
-operator<(const vector<T, A>& x, const vector<T, A>& y)
+operator<(const vector<T, Allocator>& x, const vector<T, Allocator>& y)
{
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
}
-template <class T, class A>
-inline void swap(vector<T, A>& x, vector<T, A>& y)
+template <class T, class Allocator>
+inline void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
{ x.swap(y); }
}}
@@ -2093,10 +2087,10 @@
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class T, class A>
-struct has_trivial_destructor_after_move<boost::container::vector<T, A> >
+template <class T, class Allocator>
+struct has_trivial_destructor_after_move<boost::container::vector<T, Allocator> >
{
- static const bool value = has_trivial_destructor<A>::value;
+ static const bool value = has_trivial_destructor<Allocator>::value;
};
*/
Modified: trunk/libs/container/doc/Jamfile.v2
==============================================================================
--- trunk/libs/container/doc/Jamfile.v2 (original)
+++ trunk/libs/container/doc/Jamfile.v2 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -29,12 +29,12 @@
\"BOOST_CONTAINER_DOXYGEN_INVOKED\" \\
\"BOOST_CONTAINER_IMPDEF(T)=implementation_defined\" \\
\"BOOST_CONTAINER_SEEDOC(T)=see_documentation\" \\
+ \"BOOST_CONTAINER_NOEXCEPT=noexcept\" \\
+ \"BOOST_CONTAINER_NOEXCEPT_IF(T)=noexcept(T)\" \\
\"BOOST_RV_REF(T)=T &&\" \\
\"BOOST_RV_REF_BEG=\" \\
\"BOOST_RV_REF_END=&&\" \\
\"BOOST_COPY_ASSIGN_REF(T)=const T &\" \\
- \"BOOST_RV_REF_2_TEMPL_ARGS(T,a,b)=T<a, b> &&\" \\
- \"BOOST_RV_REF_3_TEMPL_ARGS(T,a,b,c)=T<a,b,c>T<a,b,c> &&\" \\
\"BOOST_FWD_REF(a)=a &&\""
<xsl:param>"boost.doxygen.reftitle=Boost.Container Header Reference"
;
Modified: trunk/libs/container/proj/to-do.txt
==============================================================================
--- trunk/libs/container/proj/to-do.txt (original)
+++ trunk/libs/container/proj/to-do.txt 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -2,6 +2,9 @@
->Add an example with stateful allocators
->Add test to check convertible types in push_back/insert
->Add SCARY iterators.
+->Align with C++11 [multi]map::insert(P &&p) overload.
+->Unify all allocator version traits in one class (starting from stable_vector_detail::allocator_version_wrapper)
+ maybe in allocator_traits?
Review allocator traits
@@ -53,22 +56,10 @@
Add std:: hashing support
-Take out from class definition iterators in slist & list
-
Fix trivial destructor after move and other optimizing traits
-Define typedefs exactly like the standard to generate better documentation. for implementation defined types:
- #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- #define BOOST_CONTAINER_IMPLDEF(TYPE) TYPE
- #else
- #define BOOST_CONTAINER_IMPLDEF(TYPE) implementation_defined
- #endif
Mark previous() in slist/and forward_list as non-standard
-Replace all insert_const_ref_type with BOOST_MOVE_CONVERSION_AWARE_CATCH_XXX
-
-
-
Function order:
----------type------------
Modified: trunk/libs/container/test/string_test.cpp
==============================================================================
--- trunk/libs/container/test/string_test.cpp (original)
+++ trunk/libs/container/test/string_test.cpp 2012-09-30 16:38:04 EDT (Sun, 30 Sep 2012)
@@ -85,7 +85,8 @@
{ return "Suffix"; }
static const char *LongString()
{ return "LongLongLongLongLongLongLongLongLongLongLongLongLongString"; }
-
+ static char Char()
+ { return 'C'; }
static void sprintf_number(char *buf, int number)
{
std::sprintf(buf, "%i", number);
@@ -103,7 +104,8 @@
{ return L"Suffix"; }
static const wchar_t *LongString()
{ return L"LongLongLongLongLongLongLongLongLongLongLongLongLongString"; }
-
+ static wchar_t Char()
+ { return L'C'; }
static void sprintf_number(wchar_t *buffer, unsigned int number)
{
//For compilers without wsprintf, print it backwards
@@ -398,6 +400,22 @@
if(!StringEqual()(bs4, ss4)){
return 1;
}
+
+ bs2 = string_literals<CharType>::String();
+ ss2 = string_literals<CharType>::String();
+ bs4 = string_literals<CharType>::Char() + bs2;
+ ss4 = string_literals<CharType>::Char() + ss2;
+ if(!StringEqual()(bs4, ss4)){
+ return 1;
+ }
+
+ bs2 = string_literals<CharType>::String();
+ ss2 = string_literals<CharType>::String();
+ bs4 = bs2 + string_literals<CharType>::Char();
+ ss4 = ss2 + string_literals<CharType>::Char();
+ if(!StringEqual()(bs4, ss4)){
+ return 1;
+ }
}
//When done, delete vector
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk