- Modified relational operators to be friend inline definitions. This allows compilation checking when instantiating classes, avoids predeclarations and results in less verbose code.

- First to make associative containers' tree implementation configurable.
This commit is contained in:
Ion Gaztañaga
2013-12-23 23:34:28 +01:00
parent f2947c115e
commit 41c2056ec6
62 changed files with 17386 additions and 834 deletions
+40 -107
View File
@@ -35,17 +35,6 @@ namespace boost {
namespace container {
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
// Forward declarations of operators == and <, needed for friend declarations.
template <class Key, class T, class Compare, class Allocator>
class flat_map;
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{
@@ -62,7 +51,6 @@ static D force_copy(S s)
} //namespace container_detail{
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
//! A flat_map is a kind of associative container that supports unique keys (contains at
@@ -842,14 +830,28 @@ class flat_map
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)); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
template <class K1, class T1, class C1, class A1>
friend bool operator== (const flat_map<K1, T1, C1, A1>&,
const flat_map<K1, T1, C1, A1>&);
template <class K1, class T1, class C1, class A1>
friend bool operator< (const flat_map<K1, T1, C1, A1>&,
const flat_map<K1, T1, C1, A1>&);
friend bool operator==(const flat_map& x, const flat_map& y)
{ return x.m_flat_tree == y.m_flat_tree; }
friend bool operator<(const flat_map& x, const flat_map& y)
{ return x.m_flat_tree < y.m_flat_tree; }
friend bool operator!=(const flat_map& x, const flat_map& y)
{ return !(x == y); }
friend bool operator>(const flat_map& x, const flat_map& y)
{ return y < x; }
friend bool operator<=(const flat_map& x, const flat_map& y)
{ return !(y < x); }
friend bool operator>=(const flat_map& x, const flat_map& y)
{ return !(x < y); }
friend void swap(flat_map& x, flat_map& y)
{ x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
mapped_type &priv_subscript(const key_type& k)
{
@@ -875,41 +877,6 @@ class flat_map
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
};
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 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 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 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 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 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 Compare, class Allocator>
inline void swap(flat_map<Key,T,Compare,Allocator>& x,
flat_map<Key,T,Compare,Allocator>& y)
{ x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
} //namespace container {
@@ -924,17 +891,6 @@ struct has_trivial_destructor_after_move<boost::container::flat_map<K, T, C, All
namespace container {
// Forward declaration of operators < and ==, needed for friend declaration.
template <class Key, class T, class Compare, class Allocator>
class flat_multimap;
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);
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
//! A flat_multimap is a kind of associative container that supports equivalent keys
@@ -1637,51 +1593,28 @@ class flat_multimap
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)); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
template <class K1, class T1, class C1, class A1>
friend bool operator== (const flat_multimap<K1, T1, C1, A1>& x,
const flat_multimap<K1, T1, C1, A1>& y);
friend bool operator==(const flat_multimap& x, const flat_multimap& y)
{ return x.m_flat_tree == y.m_flat_tree; }
template <class K1, class T1, class C1, class A1>
friend bool operator< (const flat_multimap<K1, T1, C1, A1>& x,
const flat_multimap<K1, T1, C1, A1>& y);
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
friend bool operator<(const flat_multimap& x, const flat_multimap& y)
{ return x.m_flat_tree < y.m_flat_tree; }
friend bool operator!=(const flat_multimap& x, const flat_multimap& y)
{ return !(x == y); }
friend bool operator>(const flat_multimap& x, const flat_multimap& y)
{ return y < x; }
friend bool operator<=(const flat_multimap& x, const flat_multimap& y)
{ return !(y < x); }
friend bool operator>=(const flat_multimap& x, const flat_multimap& y)
{ return !(x < y); }
friend void swap(flat_multimap& x, flat_multimap& y)
{ x.swap(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 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 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 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 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 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 Compare, class Allocator>
inline void swap(flat_multimap<Key,T,Compare,Allocator>& x, flat_multimap<Key,T,Compare,Allocator>& y)
{ x.swap(y); }
}}
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED