[SVN r85167]
This commit is contained in:
Ion Gaztañaga
2013-07-29 21:32:23 +00:00
parent fa05d4447c
commit b1503a139e
7 changed files with 124 additions and 38 deletions

View File

@@ -115,7 +115,7 @@ class flat_tree
: value_compare(), m_vect()
{}
Data(const Data &d)
explicit Data(const Data &d)
: value_compare(static_cast<const value_compare&>(d)), m_vect(d.m_vect)
{}
@@ -131,15 +131,18 @@ class flat_tree
: value_compare(boost::move(static_cast<value_compare&>(d))), m_vect(boost::move(d.m_vect), a)
{}
Data(const Compare &comp)
explicit Data(const Compare &comp)
: value_compare(comp), m_vect()
{}
Data(const Compare &comp,
const allocator_t &alloc)
Data(const Compare &comp, const allocator_t &alloc)
: value_compare(comp), m_vect(alloc)
{}
explicit Data(const allocator_t &alloc)
: value_compare(), m_vect(alloc)
{}
Data& operator=(BOOST_COPY_ASSIGN_REF(Data) d)
{
this->value_compare::operator=(d);
@@ -203,6 +206,10 @@ class flat_tree
: m_data(comp, a)
{ }
explicit flat_tree(const allocator_type& a)
: m_data(a)
{ }
flat_tree(const flat_tree& x)
: m_data(x.m_data)
{ }

View File

@@ -53,10 +53,14 @@ struct node_compare
typedef typename ValueCompare::value_type value_type;
typedef typename ValueCompare::key_of_value key_of_value;
node_compare(const ValueCompare &pred)
explicit node_compare(const ValueCompare &pred)
: ValueCompare(pred)
{}
node_compare()
: ValueCompare()
{}
ValueCompare &value_comp()
{ return static_cast<ValueCompare &>(*this); }
@@ -67,11 +71,10 @@ struct node_compare
{ return ValueCompare::operator()(a.get_data(), b.get_data()); }
};
template<class A, class ICont, class Pred = container_detail::nat>
template<class A, class ICont, class ValPred = container_detail::nat>
struct node_alloc_holder
{
typedef allocator_traits<A> allocator_traits_type;
typedef node_alloc_holder<A, ICont> self_t;
typedef typename allocator_traits_type::value_type value_type;
typedef typename ICont::value_type Node;
typedef typename allocator_traits_type::template
@@ -116,20 +119,20 @@ struct node_alloc_holder
{ this->icont().swap(x.icont()); }
//Constructors for associative containers
explicit node_alloc_holder(const ValAlloc &a, const Pred &c)
explicit node_alloc_holder(const ValAlloc &a, const ValPred &c)
: members_(a, c)
{}
explicit node_alloc_holder(const node_alloc_holder &x, const Pred &c)
explicit node_alloc_holder(const node_alloc_holder &x, const ValPred &c)
: members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc()), c)
{}
explicit node_alloc_holder(const Pred &c)
explicit node_alloc_holder(const ValPred &c)
: members_(c)
{}
//helpers for move assignments
explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x, const Pred &c)
explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x, const ValPred &c)
: members_(boost::move(x.node_alloc()), c)
{ this->icont().swap(x.icont()); }
@@ -345,12 +348,12 @@ struct node_alloc_holder
{}
template<class ConvertibleToAlloc>
members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc, const Pred &c)
members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc, const ValPred &c)
: NodeAlloc(boost::forward<ConvertibleToAlloc>(c2alloc))
, m_icont(typename ICont::value_compare(c))
{}
explicit members_holder(const Pred &c)
explicit members_holder(const ValPred &c)
: NodeAlloc()
, m_icont(typename ICont::value_compare(c))
{}

View File

@@ -50,8 +50,12 @@ struct tree_value_compare
typedef KeyOfValue key_of_value;
typedef Key key_type;
tree_value_compare(const key_compare &kcomp)
: key_compare(kcomp)
explicit tree_value_compare(const key_compare &kcomp)
: KeyCompare(kcomp)
{}
tree_value_compare()
: KeyCompare()
{}
const key_compare &key_comp() const
@@ -212,15 +216,15 @@ class rbtree
, typename container_detail::intrusive_rbtree_type
<A, tree_value_compare<Key, Value, KeyCompare, KeyOfValue>
>::type
, KeyCompare
, tree_value_compare<Key, Value, KeyCompare, KeyOfValue>
>
{
typedef tree_value_compare
<Key, Value, KeyCompare, KeyOfValue> ValComp;
typedef typename container_detail::intrusive_rbtree_type
< A, tree_value_compare
<Key, Value, KeyCompare, KeyOfValue>
>::type Icont;
< A, ValComp>::type Icont;
typedef container_detail::node_alloc_holder
<A, Icont, KeyCompare> AllocHolder;
<A, Icont, ValComp> AllocHolder;
typedef typename AllocHolder::NodePtr NodePtr;
typedef rbtree < Key, Value, KeyOfValue
, KeyCompare, A> ThisType;
@@ -318,8 +322,7 @@ class rbtree
typedef Value value_type;
typedef A allocator_type;
typedef KeyCompare key_compare;
typedef tree_value_compare< Key, Value
, KeyCompare, KeyOfValue> value_compare;
typedef ValComp value_compare;
typedef typename boost::container::
allocator_traits<A>::pointer pointer;
typedef typename boost::container::
@@ -471,11 +474,15 @@ class rbtree
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
rbtree()
: AllocHolder(key_compare())
: AllocHolder(ValComp(key_compare()))
{}
rbtree(const key_compare& comp, const allocator_type& a = allocator_type())
: AllocHolder(a, comp)
explicit rbtree(const key_compare& comp, const allocator_type& a = allocator_type())
: AllocHolder(a, ValComp(comp))
{}
explicit rbtree(const allocator_type& a)
: AllocHolder(a)
{}
template <class InputIterator>
@@ -488,7 +495,7 @@ class rbtree
>::type * = 0
#endif
)
: AllocHolder(a, comp)
: AllocHolder(a, value_compare(comp))
{
if(unique_insertion){
this->insert_unique(first, last);
@@ -508,7 +515,7 @@ class rbtree
>::type * = 0
#endif
)
: AllocHolder(a, comp)
: AllocHolder(a, value_compare(comp))
{
if(unique_insertion){
this->insert_unique(first, last);
@@ -530,7 +537,7 @@ class rbtree
>::type * = 0
#endif
)
: AllocHolder(a, comp)
: AllocHolder(a, value_compare(comp))
{
this->insert_equal(first, last);
}
@@ -545,7 +552,7 @@ class rbtree
>::type * = 0
#endif
)
: AllocHolder(a, comp)
: AllocHolder(a, value_compare(comp))
{
//Optimized allocation and construction
this->allocate_many_and_construct
@@ -553,25 +560,25 @@ class rbtree
}
rbtree(const rbtree& x)
: AllocHolder(x, x.key_comp())
: AllocHolder(x, x.value_comp())
{
this->icont().clone_from
(x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
}
rbtree(BOOST_RV_REF(rbtree) x)
: AllocHolder(::boost::move(static_cast<AllocHolder&>(x)), x.key_comp())
: AllocHolder(::boost::move(static_cast<AllocHolder&>(x)), x.value_comp())
{}
rbtree(const rbtree& x, const allocator_type &a)
: AllocHolder(a, x.key_comp())
: AllocHolder(a, x.value_comp())
{
this->icont().clone_from
(x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
}
rbtree(BOOST_RV_REF(rbtree) x, const allocator_type &a)
: AllocHolder(a, x.key_comp())
: AllocHolder(a, x.value_comp())
{
if(this->node_alloc() == x.node_alloc()){
this->icont().swap(x.icont());

View File

@@ -173,7 +173,15 @@ class flat_map
//!
//! <b>Complexity</b>: Constant.
explicit flat_map(const Compare& comp, const allocator_type& a = allocator_type())
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a)) {}
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a))
{}
//! <b>Effects</b>: Constructs an empty flat_map using the specified allocator.
//!
//! <b>Complexity</b>: Constant.
explicit flat_map(const allocator_type& a)
: m_flat_tree(container_detail::force<impl_allocator_type>(a))
{}
//! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
@@ -1024,7 +1032,15 @@ class flat_multimap
//! <b>Complexity</b>: Constant.
explicit flat_multimap(const Compare& comp,
const allocator_type& a = allocator_type())
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a)) { }
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a))
{}
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified allocator.
//!
//! <b>Complexity</b>: Constant.
explicit flat_multimap(const allocator_type& a)
: m_flat_tree(container_detail::force<impl_allocator_type>(a))
{}
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object
//! and allocator, and inserts elements from the range [first ,last ).

View File

@@ -121,6 +121,13 @@ class flat_set
: m_flat_tree(comp, a)
{}
//! <b>Effects</b>: Constructs an empty flat_set using the specified allocator.
//!
//! <b>Complexity</b>: Constant.
explicit flat_set(const allocator_type& a)
: m_flat_tree(a)
{}
//! <b>Effects</b>: Constructs an empty set using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
//!
@@ -810,9 +817,21 @@ class flat_multiset
: m_flat_tree()
{}
//! <b>Effects</b>: Constructs an empty flat_multiset using the specified
//! comparison object and allocator.
//!
//! <b>Complexity</b>: Constant.
explicit flat_multiset(const Compare& comp,
const allocator_type& a = allocator_type())
: m_flat_tree(comp, a) {}
: m_flat_tree(comp, a)
{}
//! <b>Effects</b>: Constructs an empty flat_multiset using the specified allocator.
//!
//! <b>Complexity</b>: Constant.
explicit flat_multiset(const allocator_type& a)
: m_flat_tree(a)
{}
template <class InputIterator>
flat_multiset(InputIterator first, InputIterator last,

View File

@@ -138,6 +138,16 @@ class map
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 allocator.
//!
//! <b>Complexity</b>: Constant.
explicit map(const allocator_type& a)
: 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 Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty map using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
//!
@@ -918,8 +928,7 @@ class multimap
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>Effects</b>: Constructs an empty multimap using the specified allocator.
//!
//! <b>Complexity</b>: Constant.
explicit multimap(const Compare& comp, const allocator_type& a = allocator_type())
@@ -929,6 +938,17 @@ class multimap
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 allocator_type& a)
: 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 Allocator::value_type>::value));
}
//! <b>Effects</b>: Constructs an empty multimap using the specified comparison object
//! and allocator, and inserts elements from the range [first ,last ).
//!

View File

@@ -113,6 +113,13 @@ class set
: m_tree(comp, a)
{}
//! <b>Effects</b>: Constructs an empty set using the specified allocator object.
//!
//! <b>Complexity</b>: Constant.
explicit set(const allocator_type& a)
: m_tree(a)
{}
//! <b>Effects</b>: Constructs an empty set using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
//!
@@ -737,6 +744,13 @@ class multiset
: m_tree(comp, a)
{}
//! <b>Effects</b>: Constructs an empty multiset using the specified allocator.
//!
//! <b>Complexity</b>: Constant.
explicit multiset(const allocator_type& a)
: m_tree(a)
{}
//! <b>Effects</b>: Constructs an empty multiset using the specified comparison object
//! and allocator, and inserts elements from the range [first ,last ).
//!