forked from boostorg/container
Massive dependency reduction. Removed dependency on several boost libraries and standard C++ headers.
This commit is contained in:
1 parent
955248b739
commit
360957a797
97 files changed
+4315
-5030
No files matched your search
@@ -7,7 +7,6 @@
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_FLAT_MAP_HPP
|
||||
#define BOOST_CONTAINER_FLAT_MAP_HPP
|
||||
|
||||
@@ -17,23 +16,30 @@
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
// container
|
||||
#include <boost/container/allocator_traits.hpp>
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
|
||||
#include <boost/container/new_allocator.hpp> //new_allocator
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
// container/detail
|
||||
#include <boost/container/detail/flat_tree.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/algorithm.hpp> //equal()
|
||||
#include <boost/container/allocator_traits.hpp>
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
// move
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/detail/move_helpers.hpp>
|
||||
#include <boost/move/traits.hpp>
|
||||
// move/detail
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/move/detail/fwd_macros.hpp>
|
||||
#endif
|
||||
#include <boost/move/detail/move_helpers.hpp>
|
||||
// intrusive
|
||||
#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
|
||||
#include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
|
||||
//others
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#include <utility> //pair
|
||||
#include <functional> //less
|
||||
#include <memory> //allocator
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
@@ -72,7 +78,7 @@ static D force_copy(S s)
|
||||
//!
|
||||
//! 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.
|
||||
@@ -87,12 +93,12 @@ static D force_copy(S s)
|
||||
//! \tparam Key is the key_type of the map
|
||||
//! \tparam Value is the <code>mapped_type</code>
|
||||
//! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
|
||||
//! \tparam A is the allocator to allocate the <code>value_type</code>s
|
||||
//! \tparam Allocator is the allocator to allocate the <code>value_type</code>s
|
||||
//! (e.g. <i>allocator< std::pair<Key, T> > </i>).
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class T, class Compare = std::less<Key>, class A = std::allocator< std::pair< Key, T> > >
|
||||
template <class Key, class T, class Compare = std::less<Key>, class Allocator = new_allocator< std::pair< Key, T> > >
|
||||
#else
|
||||
template <class Key, class T, class Compare, class A>
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
#endif
|
||||
class flat_map
|
||||
{
|
||||
@@ -104,14 +110,14 @@ class flat_map
|
||||
std::pair<Key, T>,
|
||||
container_detail::select1st< std::pair<Key, T> >,
|
||||
Compare,
|
||||
A> tree_t;
|
||||
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> >,
|
||||
Compare,
|
||||
typename allocator_traits<A>::template portable_rebind_alloc
|
||||
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
|
||||
|
||||
@@ -124,13 +130,13 @@ class flat_map
|
||||
, container_detail::select1st< std::pair<Key, T> >
|
||||
, 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;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
public:
|
||||
@@ -143,22 +149,22 @@ class flat_map
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair<Key, T> value_type;
|
||||
typedef ::boost::container::allocator_traits<A> allocator_traits_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 ::boost::container::allocator_traits<Allocator> allocator_traits_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_MOVE_IMPDEF(Allocator) stored_allocator_type;
|
||||
typedef BOOST_MOVE_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;
|
||||
typedef BOOST_MOVE_IMPDEF(iterator_impl) iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(const_iterator_impl) const_iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(reverse_iterator_impl) reverse_iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(const_reverse_iterator_impl) const_reverse_iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(impl_value_type) movable_value_type;
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////
|
||||
@@ -174,7 +180,7 @@ class flat_map
|
||||
: m_flat_tree()
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_map using the specified
|
||||
@@ -185,7 +191,7 @@ class flat_map
|
||||
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_map using the specified allocator.
|
||||
@@ -195,7 +201,7 @@ class flat_map
|
||||
: m_flat_tree(container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
|
||||
@@ -209,7 +215,7 @@ class flat_map
|
||||
: m_flat_tree(true, first, last, comp, container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
|
||||
@@ -228,7 +234,7 @@ class flat_map
|
||||
: m_flat_tree(ordered_range, first, last, comp, a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
@@ -242,7 +248,7 @@ class flat_map
|
||||
: m_flat_tree(true, il.begin(), il.end(), comp, container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
|
||||
@@ -260,7 +266,7 @@ class flat_map
|
||||
: m_flat_tree(ordered_range, il.begin(), il.end(), comp, a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -271,7 +277,7 @@ class flat_map
|
||||
: m_flat_tree(x.m_flat_tree)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Move constructs a flat_map.
|
||||
@@ -284,7 +290,7 @@ class flat_map
|
||||
: m_flat_tree(boost::move(x.m_flat_tree))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Copy constructs a flat_map using the specified allocator.
|
||||
@@ -294,7 +300,7 @@ class flat_map
|
||||
: m_flat_tree(x.m_flat_tree, a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Move constructs a flat_map using the specified allocator.
|
||||
@@ -305,7 +311,7 @@ class flat_map
|
||||
: m_flat_tree(boost::move(x.m_flat_tree), a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Makes *this a copy of x.
|
||||
@@ -609,7 +615,7 @@ class flat_map
|
||||
//
|
||||
//////////////////////////////////////////////
|
||||
|
||||
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || 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
|
||||
@@ -624,7 +630,7 @@ class flat_map
|
||||
//!
|
||||
//! <b>Note</b>: If an element is inserted it might invalidate elements.
|
||||
template <class... Args>
|
||||
std::pair<iterator,bool> emplace(Args&&... args)
|
||||
std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args)
|
||||
{ return container_detail::force_copy< std::pair<iterator, bool> >(m_flat_tree.emplace_unique(boost::forward<Args>(args)...)); }
|
||||
|
||||
//! <b>Effects</b>: Inserts an object of type T constructed with
|
||||
@@ -640,32 +646,34 @@ class flat_map
|
||||
//!
|
||||
//! <b>Note</b>: If an element is inserted it might invalidate elements.
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator hint, Args&&... args)
|
||||
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return container_detail::force_copy<iterator>
|
||||
(m_flat_tree.emplace_hint_unique( container_detail::force_copy<impl_const_iterator>(hint)
|
||||
, boost::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
||||
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#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 container_detail::force_copy< std::pair<iterator, bool> > \
|
||||
(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 container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_unique \
|
||||
(container_detail::force_copy<impl_const_iterator>(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()
|
||||
#define BOOST_CONTAINER_FLAT_MAP_EMPLACE_CODE(N) \
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
return container_detail::force_copy< std::pair<iterator, bool> >\
|
||||
(m_flat_tree.emplace_unique(BOOST_MOVE_FWD##N));\
|
||||
}\
|
||||
\
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
return container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_unique\
|
||||
(container_detail::force_copy<impl_const_iterator>(hint) BOOST_MOVE_I##N BOOST_MOVE_FWD##N));\
|
||||
}\
|
||||
//
|
||||
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MAP_EMPLACE_CODE)
|
||||
#undef BOOST_CONTAINER_FLAT_MAP_EMPLACE_CODE
|
||||
|
||||
#endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
||||
#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
//! <b>Effects</b>: Inserts x if and only if there is no element in the container
|
||||
//! with key equivalent to the key of x.
|
||||
@@ -679,7 +687,7 @@ class flat_map
|
||||
//!
|
||||
//! <b>Note</b>: If an element is inserted it might invalidate elements.
|
||||
std::pair<iterator,bool> insert(const value_type& x)
|
||||
{ return container_detail::force_copy<std::pair<iterator,bool> >(
|
||||
{ return container_detail::force_copy<std::pair<iterator,bool> >(
|
||||
m_flat_tree.insert_unique(container_detail::force<impl_value_type>(x))); }
|
||||
|
||||
//! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and
|
||||
@@ -1039,10 +1047,13 @@ class flat_map
|
||||
|
||||
//!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 Key, class T, class Compare, class Allocator>
|
||||
struct has_trivial_destructor_after_move<boost::container::flat_map<Key, T, Compare, Allocator> >
|
||||
{
|
||||
static const bool value = has_trivial_destructor_after_move<A>::value && has_trivial_destructor_after_move<C>::value;
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
@@ -1061,7 +1072,7 @@ namespace container {
|
||||
//!
|
||||
//! 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_multimap is similar to std::multimap but it's implemented like an ordered vector.
|
||||
@@ -1076,12 +1087,12 @@ namespace container {
|
||||
//! \tparam Key is the key_type of the map
|
||||
//! \tparam Value is the <code>mapped_type</code>
|
||||
//! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
|
||||
//! \tparam A is the allocator to allocate the <code>value_type</code>s
|
||||
//! \tparam Allocator is the allocator to allocate the <code>value_type</code>s
|
||||
//! (e.g. <i>allocator< std::pair<Key, T> > </i>).
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class T, class Compare = std::less<Key>, class A = std::allocator< std::pair< Key, T> > >
|
||||
template <class Key, class T, class Compare = std::less<Key>, class Allocator = new_allocator< std::pair< Key, T> > >
|
||||
#else
|
||||
template <class Key, class T, class Compare, class A>
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
#endif
|
||||
class flat_multimap
|
||||
{
|
||||
@@ -1092,13 +1103,13 @@ class flat_multimap
|
||||
std::pair<Key, T>,
|
||||
container_detail::select1st< std::pair<Key, T> >,
|
||||
Compare,
|
||||
A> tree_t;
|
||||
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> >,
|
||||
Compare,
|
||||
typename allocator_traits<A>::template portable_rebind_alloc
|
||||
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
|
||||
|
||||
@@ -1111,13 +1122,13 @@ class flat_multimap
|
||||
, container_detail::select1st< std::pair<Key, T> >
|
||||
, 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;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
public:
|
||||
@@ -1130,22 +1141,22 @@ class flat_multimap
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair<Key, T> value_type;
|
||||
typedef ::boost::container::allocator_traits<A> allocator_traits_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 ::boost::container::allocator_traits<Allocator> allocator_traits_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_MOVE_IMPDEF(Allocator) stored_allocator_type;
|
||||
typedef BOOST_MOVE_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;
|
||||
typedef BOOST_MOVE_IMPDEF(iterator_impl) iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(const_iterator_impl) const_iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(reverse_iterator_impl) reverse_iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(const_reverse_iterator_impl) const_reverse_iterator;
|
||||
typedef BOOST_MOVE_IMPDEF(impl_value_type) movable_value_type;
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//
|
||||
@@ -1160,7 +1171,7 @@ class flat_multimap
|
||||
: m_flat_tree()
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison
|
||||
@@ -1172,7 +1183,7 @@ class flat_multimap
|
||||
: m_flat_tree(comp, container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified allocator.
|
||||
@@ -1182,7 +1193,7 @@ class flat_multimap
|
||||
: m_flat_tree(container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object
|
||||
@@ -1197,7 +1208,7 @@ class flat_multimap
|
||||
: m_flat_tree(false, first, last, comp, container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object and
|
||||
@@ -1216,7 +1227,7 @@ class flat_multimap
|
||||
: m_flat_tree(ordered_range, first, last, comp, a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
@@ -1229,7 +1240,7 @@ class flat_multimap
|
||||
: m_flat_tree(false, il.begin(), il.end(), comp, container_detail::force<impl_allocator_type>(a))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object and
|
||||
@@ -1246,7 +1257,7 @@ class flat_multimap
|
||||
: m_flat_tree(ordered_range, il.begin(), il.end(), comp, a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1257,7 +1268,7 @@ class flat_multimap
|
||||
: m_flat_tree(x.m_flat_tree)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Move constructs a flat_multimap. Constructs *this using x's resources.
|
||||
@@ -1269,7 +1280,7 @@ class flat_multimap
|
||||
: m_flat_tree(boost::move(x.m_flat_tree))
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Copy constructs a flat_multimap using the specified allocator.
|
||||
@@ -1279,7 +1290,7 @@ class flat_multimap
|
||||
: m_flat_tree(x.m_flat_tree, a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Move constructs a flat_multimap using the specified allocator.
|
||||
@@ -1290,7 +1301,7 @@ class flat_multimap
|
||||
: m_flat_tree(boost::move(x.m_flat_tree), a)
|
||||
{
|
||||
//A type must be std::pair<Key, T>
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename A::value_type>::value));
|
||||
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<Key, T>, typename Allocator::value_type>::value));
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Makes *this a copy of x.
|
||||
@@ -1529,7 +1540,7 @@ class flat_multimap
|
||||
size_type index_of(const_iterator p) const BOOST_CONTAINER_NOEXCEPT
|
||||
{ return m_flat_tree.index_of(container_detail::force_copy<impl_const_iterator>(p)); }
|
||||
|
||||
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || 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
|
||||
@@ -1540,7 +1551,7 @@ class flat_multimap
|
||||
//!
|
||||
//! <b>Note</b>: If an element is inserted it might invalidate elements.
|
||||
template <class... Args>
|
||||
iterator emplace(Args&&... args)
|
||||
iterator emplace(BOOST_FWD_REF(Args)... args)
|
||||
{ return container_detail::force_copy<iterator>(m_flat_tree.emplace_equal(boost::forward<Args>(args)...)); }
|
||||
|
||||
//! <b>Effects</b>: Inserts an object of type T constructed with
|
||||
@@ -1556,31 +1567,30 @@ class flat_multimap
|
||||
//!
|
||||
//! <b>Note</b>: If an element is inserted it might invalidate elements.
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator hint, Args&&... args)
|
||||
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_equal
|
||||
(container_detail::force_copy<impl_const_iterator>(hint), boost::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
||||
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#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 container_detail::force_copy<iterator>(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 container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_equal \
|
||||
(container_detail::force_copy<impl_const_iterator>(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()
|
||||
#define BOOST_CONTAINER_FLAT_MULTIMAP_EMPLACE_CODE(N) \
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
iterator emplace(BOOST_MOVE_UREF##N)\
|
||||
{ return container_detail::force_copy<iterator>(m_flat_tree.emplace_equal(BOOST_MOVE_FWD##N)); }\
|
||||
\
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
return container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_equal\
|
||||
(container_detail::force_copy<impl_const_iterator>(hint) BOOST_MOVE_I##N BOOST_MOVE_FWD##N));\
|
||||
}\
|
||||
//
|
||||
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MULTIMAP_EMPLACE_CODE)
|
||||
#undef BOOST_CONTAINER_FLAT_MULTIMAP_EMPLACE_CODE
|
||||
|
||||
#endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
||||
#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
//! <b>Effects</b>: Inserts x and returns the iterator pointing to the
|
||||
//! newly inserted element.
|
||||
@@ -1917,10 +1927,13 @@ namespace boost {
|
||||
|
||||
//!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 Key, class T, class Compare, class Allocator>
|
||||
struct has_trivial_destructor_after_move< boost::container::flat_multimap<Key, T, Compare, Allocator> >
|
||||
{
|
||||
static const bool value = has_trivial_destructor_after_move<A>::value && has_trivial_destructor_after_move<C>::value;
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
};
|
||||
|
||||
} //namespace boost {
|
||||
|
||||
Reference in new issue
Block a user