diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
index 58865b4..f0d1056 100644
--- a/doc/Jamfile.v2
+++ b/doc/Jamfile.v2
@@ -29,12 +29,12 @@ doxygen autodoc
\"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 &&\" \\
- \"BOOST_RV_REF_3_TEMPL_ARGS(T,a,b,c)=TT &&\" \\
\"BOOST_FWD_REF(a)=a &&\""
"boost.doxygen.reftitle=Boost.Container Header Reference"
;
diff --git a/doc/container.qbk b/doc/container.qbk
index 8b71c43..75f4a3f 100644
--- a/doc/container.qbk
+++ b/doc/container.qbk
@@ -623,7 +623,8 @@ use [*Boost.Container]? There are several reasons for that:
[@https://svn.boost.org/trac/boost/ticket/7139 #7139],
[@https://svn.boost.org/trac/boost/ticket/7215 #7215],
[@https://svn.boost.org/trac/boost/ticket/7232 #7232],
- [@https://svn.boost.org/trac/boost/ticket/7269 #7269].
+ [@https://svn.boost.org/trac/boost/ticket/7269 #7269],
+ [@https://svn.boost.org/trac/boost/ticket/7439 #7439].
* Implemented LWG Issue #149 (range insertion now returns an iterator) & cleaned up insertion code in most containers
* Corrected aliasing errors.
diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp
index c52b04a..bdefd81 100644
--- a/include/boost/container/container_fwd.hpp
+++ b/include/boost/container/container_fwd.hpp
@@ -49,85 +49,85 @@ namespace container {
//vector class
template >
+ ,class Allocator = std::allocator >
class vector;
//vector class
template >
+ ,class Allocator = std::allocator >
class stable_vector;
//vector class
template >
+ ,class Allocator = std::allocator >
class deque;
//list class
template >
+ ,class Allocator = std::allocator >
class list;
//slist class
template >
+ ,class Allocator = std::allocator >
class slist;
//set class
-template
- ,class A = std::allocator >
+template
+ ,class Allocator = std::allocator >
class set;
//multiset class
-template
- ,class A = std::allocator >
+template
+ ,class Allocator = std::allocator >
class multiset;
//map class
template
- ,class A = std::allocator > >
+ ,class Compare = std::less
+ ,class Allocator = std::allocator > >
class map;
//multimap class
template
- ,class A = std::allocator > >
+ ,class Compare = std::less
+ ,class Allocator = std::allocator > >
class multimap;
//flat_set class
-template
- ,class A = std::allocator >
+template
+ ,class Allocator = std::allocator >
class flat_set;
//flat_multiset class
-template
- ,class A = std::allocator >
+template
+ ,class Allocator = std::allocator >
class flat_multiset;
//flat_map class
template
- ,class A = std::allocator > >
+ ,class Compare = std::less
+ ,class Allocator = std::allocator > >
class flat_map;
//flat_multimap class
template
- ,class A = std::allocator > >
+ ,class Compare = std::less
+ ,class Allocator = std::allocator > >
class flat_multimap;
//basic_string class
template
- ,class A = std::allocator >
+ ,class Allocator = std::allocator >
class basic_string;
//! Type used to tag that the input range is
diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp
index 52b3b68..b63dab3 100644
--- a/include/boost/container/deque.hpp
+++ b/include/boost/container/deque.hpp
@@ -67,17 +67,17 @@ namespace container {
/// @cond
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template >
+template >
#else
-template
+template
#endif
class deque;
-template
+template
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;
static const bool trivial_dctr_after_move = false;
//::boost::has_trivial_destructor_after_move::value || trivial_dctr;
@@ -96,12 +96,12 @@ inline std::size_t deque_buf_size(std::size_t size)
// Deque base class. It has two purposes. First, its constructor
// and destructor allocate (but don't initialize) storage. This makes
// exception safety easier.
-template
+template
class deque_base
{
BOOST_COPYABLE_AND_MOVABLE(deque_base)
public:
- typedef allocator_traits val_alloc_traits_type;
+ typedef allocator_traits 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 @@ class deque_base
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 traits_t;
+ typedef deque_value_traits 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 @@ class deque_base
// [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
{
public:
- static size_type s_buffer_size() { return deque_base::s_buffer_size(); }
+ static size_type s_buffer_size() { return deque_base::s_buffer_size(); }
typedef std::random_access_iterator_tag iterator_category;
typedef val_alloc_val value_type;
@@ -182,8 +182,8 @@ class deque_base
typedef ptr_alloc_ptr index_pointer;
typedef const_iterator self_t;
- friend class deque;
- friend class deque_base;
+ friend class deque;
+ friend class deque_base;
protected:
val_alloc_ptr m_cur;
@@ -323,8 +323,8 @@ class deque_base
typedef ptr_alloc_ptr index_pointer;
typedef const_iterator self_t;
- friend class deque;
- friend class deque_base;
+ friend class deque;
+ friend class deque_base;
private:
explicit iterator(const const_iterator& x) : const_iterator(x){}
@@ -525,15 +525,15 @@ class deque_base
//! Deque class
//!
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template >
+template >
#else
-template
+template
#endif
-class deque : protected deque_base
+class deque : protected deque_base
{
/// @cond
private:
- typedef deque_base Base;
+ typedef deque_base Base;
/// @endcond
public:
@@ -544,19 +544,19 @@ class deque : protected deque_base
//
//////////////////////////////////////////////
- typedef T value_type;
- typedef typename ::boost::container::allocator_traits::pointer pointer;
- typedef typename ::boost::container::allocator_traits::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits::reference reference;
- typedef typename ::boost::container::allocator_traits::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits::size_type size_type;
- typedef typename ::boost::container::allocator_traits::difference_type difference_type;
- typedef 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) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator) const_reverse_iterator;
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits::pointer pointer;
+ typedef typename ::boost::container::allocator_traits::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits::reference reference;
+ typedef typename ::boost::container::allocator_traits::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits::size_type size_type;
+ typedef typename ::boost::container::allocator_traits::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef 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) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator) const_reverse_iterator;
/// @cond
@@ -568,7 +568,7 @@ class deque : protected deque_base
typedef container_detail::advanced_insert_aux_int advanced_insert_aux_int_t;
typedef repeat_iterator r_iterator;
typedef boost::move_iterator move_it;
- typedef allocator_traits allocator_traits_type;
+ typedef allocator_traits allocator_traits_type;
/// @endcond
@@ -607,7 +607,7 @@ class deque : protected deque_base
explicit deque(size_type n)
: Base(n, allocator_type())
{
- container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+ container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
proxy.uninitialized_copy_remaining_to(this->begin());
//deque_base will deallocate in case of exception...
}
@@ -1020,7 +1020,7 @@ class deque : protected deque_base
this->priv_erase_last_n(len - new_size);
else{
const size_type n = new_size - this->size();
- container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
+ container_detail::default_construct_aux_proxy proxy(this->alloc(), n);
priv_insert_back_aux_impl(n, proxy);
}
}
@@ -1176,7 +1176,7 @@ class deque : protected deque_base
this->priv_push_front_simple_commit();
}
else{
- typedef container_detail::advanced_insert_aux_non_movable_emplace type;
+ typedef container_detail::advanced_insert_aux_non_movable_emplace type;
type &&proxy = type(this->alloc(), boost::forward(args)...);
this->priv_insert_front_aux_impl(1, proxy);
}
@@ -1199,7 +1199,7 @@ class deque : protected deque_base
this->priv_push_back_simple_commit();
}
else{
- typedef container_detail::advanced_insert_aux_non_movable_emplace type;
+ typedef container_detail::advanced_insert_aux_non_movable_emplace type;
type &&proxy = type(this->alloc(), boost::forward(args)...);
this->priv_insert_back_aux_impl(1, proxy);
}
@@ -1226,7 +1226,7 @@ class deque : protected deque_base
return (this->end()-1);
}
else{
- typedef container_detail::advanced_insert_aux_emplace type;
+ typedef container_detail::advanced_insert_aux_emplace type;
type &&proxy = type(this->alloc(), boost::forward(args)...);
return this->priv_insert_aux_impl(p, 1, proxy);
}
@@ -1249,7 +1249,7 @@ class deque : protected deque_base
else{ \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT \
(advanced_insert_aux_non_movable_emplace, n), arg) \
- proxy \
+ proxy \
(this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
priv_insert_front_aux_impl(1, proxy); \
} \
@@ -1268,7 +1268,7 @@ class deque : protected deque_base
else{ \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT( \
advanced_insert_aux_non_movable_emplace, n), arg) \
- proxy \
+ proxy \
(this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
priv_insert_back_aux_impl(1, proxy); \
} \
@@ -1288,7 +1288,7 @@ class deque : protected deque_base
} \
else{ \
container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
- proxy \
+ 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 @@ class deque : protected deque_base
#endif
)
{
- container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
+ container_detail::advanced_insert_aux_proxy proxy(this->alloc(), first, last);
return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
}
#endif
@@ -1978,36 +1978,36 @@ class deque : protected deque_base
};
// Nonmember functions.
-template
-inline bool operator==(const deque& x, const deque& y)
+template
+inline bool operator==(const deque& x, const deque& y)
{
return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
}
-template
-inline bool operator<(const deque& x, const deque& y)
+template
+inline bool operator<(const deque& x, const deque& y)
{
return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
}
-template
-inline bool operator!=(const deque& x, const deque& y)
+template
+inline bool operator!=(const deque& x, const deque& y)
{ return !(x == y); }
-template
-inline bool operator>(const deque& x, const deque& y)
+template
+inline bool operator>(const deque& x, const deque& y)
{ return y < x; }
-template
-inline bool operator>=(const deque& x, const deque& y)
+template
+inline bool operator>=(const deque& x, const deque& y)
{ return !(x < y); }
-template
-inline bool operator<=(const deque& x, const deque& y)
+template
+inline bool operator<=(const deque& x, const deque& y)
{ return !(y < x); }
-template
-inline void swap(deque& x, deque& y)
+template
+inline void swap(deque& x, deque& y)
{ x.swap(y); }
}}
@@ -2018,10 +2018,10 @@ namespace boost {
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template
-struct has_trivial_destructor_after_move >
+template
+struct has_trivial_destructor_after_move >
{
- enum { value = has_trivial_destructor::value };
+ enum { value = has_trivial_destructor::value };
};
*/
}
diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp
index 55fac62..b6f9214 100644
--- a/include/boost/container/detail/flat_tree.hpp
+++ b/include/boost/container/detail/flat_tree.hpp
@@ -414,7 +414,8 @@ class flat_tree
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::value
+ < !container_detail::is_input_iterator::value &&
+ container_detail::is_forward_iterator::value
>::type * = 0
#endif
)
@@ -491,9 +492,9 @@ class flat_tree
const const_iterator beg(this->cbegin());
const_iterator pos(beg);
const value_compare &value_comp = this->m_data;
+ skips[0u] = 0u;
//Loop in burst sizes
while(len){
- skips[0u] = 0u;
const size_type burst = len < BurstSize ? len : BurstSize;
size_type unique_burst = 0u;
const const_iterator cend(this->cend());
@@ -503,20 +504,23 @@ class flat_tree
--len;
pos = const_cast(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
//Check if already present
- if(pos != cend && !value_comp(*pos, val)){
- ++skips[unique_burst];
+ if(pos != cend && !value_comp(val, *pos)){
+ if(unique_burst > 0){
+ ++skips[unique_burst-1];
+ }
continue;
}
//If not present, calculate position
positions[unique_burst] = static_cast(pos - beg);
- if(++unique_burst < burst)
- skips[unique_burst] = 0u;
+ skips[unique_burst++] = 0u;
+ }
+ if(unique_burst){
+ //Insert all in a single step in the precalculated positions
+ this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
+ //Next search position updated
+ pos += unique_burst;
}
- //Insert all in a single step in the precalculated positions
- this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
- //Next search position updated
- pos += unique_burst;
}
}
diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp
index 96db26f..12342a8 100644
--- a/include/boost/container/detail/tree.hpp
+++ b/include/boost/container/detail/tree.hpp
@@ -41,7 +41,7 @@ namespace container {
namespace container_detail {
template
-struct value_compare_impl
+struct tree_value_compare
: public KeyCompare
{
typedef Value value_type;
@@ -49,7 +49,7 @@ struct value_compare_impl
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 @@ class rbtree
: protected container_detail::node_alloc_holder
< A
, typename container_detail::intrusive_rbtree_type
-
+
>::type
, KeyCompare
>
{
typedef typename container_detail::intrusive_rbtree_type
- < A, value_compare_impl
+ < A, tree_value_compare
>::type Icont;
typedef container_detail::node_alloc_holder
@@ -315,7 +315,7 @@ class rbtree
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::pointer pointer;
diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp
index 152b5e1..ece9a2e 100644
--- a/include/boost/container/detail/utilities.hpp
+++ b/include/boost/container/detail/utilities.hpp
@@ -122,36 +122,6 @@ struct ct_rounded_size
{
enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo };
};
-/*
-template
-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
struct move_const_ref_type
diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp
index 27f1074..1422d31 100644
--- a/include/boost/container/flat_map.hpp
+++ b/include/boost/container/flat_map.hpp
@@ -28,27 +28,23 @@
#include
#include
#include
+#include
-#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
+template
class flat_map;
-template
-inline bool operator==(const flat_map& x,
- const flat_map& y);
+template
+inline bool operator==(const flat_map& x,
+ const flat_map& y);
-template
-inline bool operator<(const flat_map& x,
- const flat_map& y);
+template
+inline bool operator<(const flat_map& x,
+ const flat_map& y);
namespace container_detail{
@@ -78,9 +74,9 @@ static D force_copy(S s)
//! flat_map the key_type is Key and the value_type is std::pair
//! (unlike std::map which value_type is std::pair<const Key, T>).
//!
-//! Pred is the ordering function for Keys (e.g. std::less).
+//! Compare is the ordering function for Keys (e.g. std::less).
//!
-//! A is the allocator to allocate the value_types
+//! Allocator is the allocator to allocate the value_types
//! (e.g. allocator< std::pair >).
//!
//! flat_map is similar to std::map but it's implemented like an ordered vector.
@@ -90,9 +86,9 @@ static D force_copy(S s)
//! 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 A = std::allocator< std::pair< Key, T> > >
+template , class Allocator = std::allocator< std::pair< Key, T> > >
#else
-template
+template
#endif
class flat_map
{
@@ -103,72 +99,68 @@ class flat_map
typedef container_detail::flat_tree,
container_detail::select1st< std::pair >,
- 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,
container_detail::select1st >,
- Pred,
- typename allocator_traits::template portable_rebind_alloc
+ Compare,
+ typename allocator_traits::template portable_rebind_alloc
>::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 allocator_traits_type;
-
-
-
+ typedef container_detail::flat_tree_value_compare
+ < Compare
+ , container_detail::select1st< std::pair >
+ , std::pair > value_compare_impl;
+ typedef typename container_detail::get_flat_tree_iterators
+ ::pointer>::iterator iterator_impl;
+ typedef typename container_detail::get_flat_tree_iterators
+ ::pointer>::const_iterator const_iterator_impl;
+ typedef typename container_detail::get_flat_tree_iterators
+ ::pointer>::reverse_iterator reverse_iterator_impl;
+ typedef typename container_detail::get_flat_tree_iterators
+ ::pointer>::const_reverse_iterator const_reverse_iterator_impl;
/// @endcond
public:
- // typedefs:
- typedef Key key_type;
- typedef T mapped_type;
- typedef typename std::pair value_type;
- typedef typename allocator_traits_type::pointer pointer;
- typedef typename allocator_traits_type::const_pointer const_pointer;
- typedef typename allocator_traits_type::reference reference;
- typedef typename allocator_traits_type::const_reference const_reference;
- typedef typename impl_tree_t::size_type size_type;
- typedef typename impl_tree_t::difference_type difference_type;
-
- typedef container_detail::flat_tree_value_compare
- < Pred
- , container_detail::select1st< std::pair >
- , std::pair > value_compare;
- typedef Pred key_compare;
- typedef typename container_detail::
- get_flat_tree_iterators::iterator iterator;
- typedef typename container_detail::
- get_flat_tree_iterators::const_iterator const_iterator;
- typedef typename container_detail::
- get_flat_tree_iterators
- ::reverse_iterator reverse_iterator;
- typedef typename container_detail::
- get_flat_tree_iterators
- ::const_reverse_iterator const_reverse_iterator;
- typedef A allocator_type;
-
- //!Standard extension
- typedef A stored_allocator_type;
-
- //!Standard extension for C++03 compilers with non-movable std::pair
- typedef impl_value_type movable_value_type;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+ typedef Key key_type;
+ typedef T mapped_type;
+ typedef std::pair value_type;
+ typedef typename boost::container::allocator_traits::pointer pointer;
+ typedef typename boost::container::allocator_traits::const_pointer const_pointer;
+ typedef typename boost::container::allocator_traits::reference reference;
+ typedef typename boost::container::allocator_traits::const_reference const_reference;
+ typedef typename boost::container::allocator_traits::size_type size_type;
+ typedef typename boost::container::allocator_traits::difference_type difference_type;
+ typedef Allocator allocator_type;
+ typedef 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:
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
+
//! Effects: Default constructs an empty flat_map.
//!
//! Complexity: Constant.
@@ -179,7 +171,7 @@ class flat_map
//! comparison object and allocator.
//!
//! Complexity: 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(a)) {}
//! Effects: Constructs an empty flat_map using the specified comparison object and
@@ -188,7 +180,7 @@ class flat_map
//! Complexity: Linear in N if the range [first ,last ) is already sorted using
//! comp and otherwise N logN, where N is last - first.
template
- 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(a))
{}
@@ -205,7 +197,7 @@ class flat_map
//! Note: Non-standard extension.
template
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)
{}
@@ -255,20 +247,6 @@ class flat_map
flat_map& operator=(BOOST_RV_REF(flat_map) mx)
{ m_flat_tree = boost::move(mx.m_flat_tree); return *this; }
- //! Effects: Returns the comparison object out
- //! of which a was constructed.
- //!
- //! Complexity: Constant.
- key_compare key_comp() const
- { return container_detail::force_copy(m_flat_tree.key_comp()); }
-
- //! Effects: Returns an object of value_compare constructed out
- //! of the comparison object.
- //!
- //! Complexity: Constant.
- value_compare value_comp() const
- { return value_compare(container_detail::force_copy(m_flat_tree.key_comp())); }
-
//! Effects: Returns a copy of the Allocator that
//! was passed to the object's constructor.
//!
@@ -276,11 +254,31 @@ class flat_map
allocator_type get_allocator() const
{ return container_detail::force_copy(m_flat_tree.get_allocator()); }
+ //! Effects: Returns a reference to the internal allocator.
+ //!
+ //! Throws: Nothing
+ //!
+ //! Complexity: Constant.
+ //!
+ //! Note: Non-standard extension.
+ stored_allocator_type &get_stored_allocator()
+ { return container_detail::force(m_flat_tree.get_stored_allocator()); }
+
+ //! Effects: Returns a reference to the internal allocator.
+ //!
+ //! Throws: Nothing
+ //!
+ //! Complexity: Constant.
+ //!
+ //! Note: Non-standard extension.
const stored_allocator_type &get_stored_allocator() const
{ return container_detail::force(m_flat_tree.get_stored_allocator()); }
- stored_allocator_type &get_stored_allocator()
- { return container_detail::force(m_flat_tree.get_stored_allocator()); }
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
//! Effects: Returns an iterator to the first element contained in the container.
//!
@@ -384,6 +382,12 @@ class flat_map
const_reverse_iterator crend() const
{ return container_detail::force_copy(m_flat_tree.crend()); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
//! Effects: Returns true if the container contains no elements.
//!
//! Throws: Nothing.
@@ -408,11 +412,47 @@ class flat_map
size_type max_size() const
{ return m_flat_tree.max_size(); }
+ //! Effects: Number of elements for which memory has been allocated.
+ //! capacity() is always greater than or equal to size().
+ //!
+ //! Throws: Nothing.
+ //!
+ //! Complexity: Constant.
+ size_type capacity() const
+ { return m_flat_tree.capacity(); }
+
+ //! Effects: 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.
+ //!
+ //! Throws: If memory allocation allocation throws or T's copy constructor throws.
+ //!
+ //! Note: 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); }
+
+ //! Effects: Tries to deallocate the excess of memory created
+ // with previous allocations. The size of the vector is unchanged
+ //!
+ //! Throws: If memory allocation throws, or T's copy constructor throws.
+ //!
+ //! Complexity: Linear to size().
+ void shrink_to_fit()
+ { m_flat_tree.shrink_to_fit(); }
+
+ //////////////////////////////////////////////
+ //
+ // element access
+ //
+ //////////////////////////////////////////////
+
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! 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);
@@ -420,17 +460,19 @@ class flat_map
//! 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.
+ //!
//! Complexity: logarithmic.
T& at(const key_type& k)
{
@@ -441,8 +483,10 @@ class flat_map
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
{
@@ -453,13 +497,69 @@ class flat_map
return i->second;
}
- //! Effects: Swaps the contents of *this and x.
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
+
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! Effects: Inserts an object x of type T constructed with
+ //! std::forward(args)... if and only if there is no element in the container
+ //! with key equivalent to the key of x.
//!
- //! Throws: Nothing.
+ //! Returns: 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.
//!
- //! Complexity: Constant.
- void swap(flat_map& x)
- { m_flat_tree.swap(x.m_flat_tree); }
+ //! Complexity: Logarithmic search time plus linear insertion
+ //! to the elements with bigger keys than x.
+ //!
+ //! Note: If an element is inserted it might invalidate elements.
+ template
+ std::pair