summaryrefslogtreecommitdiff
path: root/boost/container
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2013-08-26 08:15:55 -0400
committerAnas Nashif <anas.nashif@intel.com>2013-08-26 08:15:55 -0400
commitbb4dd8289b351fae6b55e303f189127a394a1edd (patch)
tree77c9c35a31b1459dd7988c2448e797d142530c41 /boost/container
parent1a78a62555be32868418fe52f8e330c9d0f95d5a (diff)
downloadboost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.gz
boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.bz2
boost-bb4dd8289b351fae6b55e303f189127a394a1edd.zip
Imported Upstream version 1.51.0upstream/1.51.0
Diffstat (limited to 'boost/container')
-rw-r--r--boost/container/allocator/scoped_allocator.hpp651
-rw-r--r--boost/container/allocator_traits.hpp (renamed from boost/container/allocator/allocator_traits.hpp)131
-rw-r--r--boost/container/container_fwd.hpp32
-rw-r--r--boost/container/deque.hpp384
-rw-r--r--boost/container/detail/adaptive_node_pool_impl.hpp20
-rw-r--r--boost/container/detail/advanced_insert_int.hpp139
-rw-r--r--boost/container/detail/algorithms.hpp4
-rw-r--r--boost/container/detail/allocation_type.hpp4
-rw-r--r--boost/container/detail/config_begin.hpp3
-rw-r--r--boost/container/detail/config_end.hpp2
-rw-r--r--boost/container/detail/destroyers.hpp102
-rw-r--r--boost/container/detail/flat_tree.hpp353
-rw-r--r--boost/container/detail/function_detector.hpp6
-rw-r--r--boost/container/detail/iterators.hpp54
-rw-r--r--boost/container/detail/math_functions.hpp6
-rw-r--r--boost/container/detail/memory_util.hpp (renamed from boost/container/allocator/memory_util.hpp)2
-rw-r--r--boost/container/detail/mpl.hpp22
-rw-r--r--boost/container/detail/multiallocation_chain.hpp2
-rw-r--r--boost/container/detail/node_alloc_holder.hpp67
-rw-r--r--boost/container/detail/node_pool_impl.hpp22
-rw-r--r--boost/container/detail/pair.hpp121
-rw-r--r--boost/container/detail/pool_common.hpp2
-rw-r--r--boost/container/detail/preprocessor.hpp35
-rw-r--r--boost/container/detail/stored_ref.hpp2
-rw-r--r--boost/container/detail/transform_iterator.hpp8
-rw-r--r--boost/container/detail/tree.hpp254
-rw-r--r--boost/container/detail/type_traits.hpp13
-rw-r--r--boost/container/detail/utilities.hpp19
-rw-r--r--boost/container/detail/value_init.hpp8
-rw-r--r--boost/container/detail/variadic_templates_tools.hpp6
-rw-r--r--boost/container/detail/version_type.hpp4
-rw-r--r--boost/container/detail/workaround.hpp7
-rw-r--r--boost/container/flat_map.hpp823
-rw-r--r--boost/container/flat_set.hpp625
-rw-r--r--boost/container/list.hpp395
-rw-r--r--boost/container/map.hpp628
-rw-r--r--boost/container/scoped_allocator.hpp1466
-rw-r--r--boost/container/scoped_allocator_fwd.hpp83
-rw-r--r--boost/container/set.hpp560
-rw-r--r--boost/container/slist.hpp530
-rw-r--r--boost/container/stable_vector.hpp354
-rw-r--r--boost/container/string.hpp607
-rw-r--r--boost/container/vector.hpp484
43 files changed, 5444 insertions, 3596 deletions
diff --git a/boost/container/allocator/scoped_allocator.hpp b/boost/container/allocator/scoped_allocator.hpp
deleted file mode 100644
index 03e12d1d1c..0000000000
--- a/boost/container/allocator/scoped_allocator.hpp
+++ /dev/null
@@ -1,651 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Pablo Halpern 2009. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Ion Gaztanaga 2011-2011. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/container for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
-#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
-
-#if (defined _MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif
-
-#include <boost/container/detail/config_begin.hpp>
-#include <boost/container/detail/workaround.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
-#include <boost/type_traits.hpp>
-#include <utility>
-
-namespace boost { namespace container {
-
-template <typename OuterAlloc, typename... InnerAllocs>
-class scoped_allocator_adaptor;
-
-template <typename OuterAlloc, typename... InnerAllocs>
-scoped_allocator_adaptor<OuterAlloc, InnerAllocs...> make_scoped();
-
-template <typename OuterAlloc, typename... InnerAllocs>
-class scoped_allocator_adaptor_base : public OuterAlloc
-{
- typedef allocator_traits<OuterAlloc> OuterTraits;
-
-public:
- // Workaround for inability of gcc-4.4.1 to expand InnerAllocs...
-// typedef scoped_allocator_adaptor<InnerAllocs...> inner_allocator_type;
- typedef decltype(make_scoped<InnerAllocs...>()) inner_allocator_type;
-
- scoped_allocator_adaptor_base();
-
- template <typename OuterA2>
- scoped_allocator_adaptor_base(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs);
-
- template <typename OuterA2>
- scoped_allocator_adaptor_base(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other);
- template <typename OuterA2>
- scoped_allocator_adaptor_base(scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other);
-
- inner_allocator_type& inner_allocator()
- { return _M_inner_allocs; }
- inner_allocator_type const& inner_allocator() const
- { return _M_inner_allocs; }
-
- // Allocator propagation functions.
- scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>
- select_on_container_copy_construction() const;
-
- typedef std::integral_constant<
- bool,
- OuterTraits::propagate_on_container_copy_assignment::value ||
- inner_allocator_type::propagate_on_container_copy_assignment::value
- > propagate_on_container_copy_assignment;
- typedef std::integral_constant<
- bool,
- OuterTraits::propagate_on_container_move_assignment::value ||
- inner_allocator_type::propagate_on_container_move_assignment::value
- > propagate_on_container_move_assignment;
- typedef std::integral_constant<
- bool,
- OuterTraits::propagate_on_container_swap::value ||
- inner_allocator_type::propagate_on_container_swap::value
- > propagate_on_container_swap;
-
-private:
- inner_allocator_type _M_inner_allocs;
-};
-
-// Specialization with only one parameter.
-template <typename OuterAlloc>
-class scoped_allocator_adaptor_base<OuterAlloc> : public OuterAlloc
-{
- typedef allocator_traits<OuterAlloc> OuterTraits;
-public:
- typedef scoped_allocator_adaptor<OuterAlloc> inner_allocator_type;
-
- scoped_allocator_adaptor_base();
-
- template <typename OuterA2>
- scoped_allocator_adaptor_base(OuterA2&& outerAlloc);
-
- template <typename OuterA2>
- scoped_allocator_adaptor_base(const scoped_allocator_adaptor<OuterA2>& other);
- template <typename OuterA2>
- scoped_allocator_adaptor_base(scoped_allocator_adaptor<OuterA2>&& other);
-
- inner_allocator_type& inner_allocator()
- { return static_cast<inner_allocator_type&>(*this); }
-
- inner_allocator_type const& inner_allocator() const
- { return static_cast<const inner_allocator_type&>(*this); }
-
- // Allocator propagation functions.
- scoped_allocator_adaptor<OuterAlloc>
- select_on_container_copy_construction() const;
-
- typedef typename OuterTraits::propagate_on_container_copy_assignment propagate_on_container_copy_assignment;
- typedef typename OuterTraits::propagate_on_container_move_assignment propagate_on_container_move_assignment;
- typedef typename OuterTraits::propagate_on_container_swap propagate_on_container_swap;
-};
-
-template <typename OuterAlloc, typename... InnerAllocs>
-class scoped_allocator_adaptor
- : public scoped_allocator_adaptor_base<OuterAlloc, InnerAllocs...>
-{
- typedef scoped_allocator_adaptor_base<OuterAlloc, InnerAllocs...> _Base;
- typedef allocator_traits<OuterAlloc> _Traits;
-
-public:
- typedef OuterAlloc outer_allocator_type;
- typedef typename _Base::inner_allocator_type inner_allocator_type;
-
- typedef typename allocator_traits<OuterAlloc>::size_type size_type;
- typedef typename allocator_traits<OuterAlloc>::difference_type difference_type;
- typedef typename allocator_traits<OuterAlloc>::pointer pointer;
- typedef typename allocator_traits<OuterAlloc>::const_pointer const_pointer;
- typedef typename allocator_traits<OuterAlloc>::void_pointer void_pointer;
- typedef typename allocator_traits<OuterAlloc>::const_void_pointer const_void_pointer;
- typedef typename allocator_traits<OuterAlloc>::value_type value_type;
-
- template <typename Tp>
- struct rebind {
- typedef typename allocator_traits<OuterAlloc>::template rebind_traits<Tp> rebound_traits;
- typedef typename rebound_traits::allocator_type rebound_outer; // exposition only
- typedef scoped_allocator_adaptor<rebound_outer, InnerAllocs...> other;
- };
-
- scoped_allocator_adaptor();
- scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
-
- template <typename OuterA2>
- scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other);
- template <typename OuterA2>
- scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other);
-
- template <typename OuterA2>
- scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs);
-
- ~scoped_allocator_adaptor();
-
- inner_allocator_type & inner_allocator()
- { return _Base::inner_allocator(); }
- inner_allocator_type const& inner_allocator() const
- { return _Base::inner_allocator(); }
- outer_allocator_type & outer_allocator()
- { return *this; }
- outer_allocator_type const& outer_allocator() const
- { return *this; }
-
- pointer allocate(size_type n);
- pointer allocate(size_type n, const_void_pointer hint);
- void deallocate(pointer p, size_type n);
- size_type max_size() const;
-
- template <typename T, typename... Args>
- void construct(T* p, Args&&... args);
-
- // Specializations to pass inner_allocator to pair::first and pair::second
- template <class T1, class T2>
- void construct(std::pair<T1,T2>* p);
- template <class T1, class T2, class U, class V>
- void construct(std::pair<T1,T2>* p, U&& x, V&& y);
- template <class T1, class T2, class U, class V>
- void construct(std::pair<T1,T2>* p, const std::pair<U, V>& pr);
- template <class T1, class T2, class U, class V>
- void construct(std::pair<T1,T2>* p, std::pair<U, V>&& pr);
-
- template <typename T>
- void destroy(T* p);
-};
-
-template <typename OuterA1, typename OuterA2, typename... InnerAllocs>
-inline
-bool operator==(const scoped_allocator_adaptor<OuterA1,InnerAllocs...>& a,
- const scoped_allocator_adaptor<OuterA2,InnerAllocs...>& b);
-
-template <typename OuterA1, typename OuterA2, typename... InnerAllocs>
-inline
-bool operator!=(const scoped_allocator_adaptor<OuterA1,InnerAllocs...>& a,
- const scoped_allocator_adaptor<OuterA2,InnerAllocs...>& b);
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor_base<OuterAlloc, InnerAllocs...>
-///////////////////////////////////////////////////////////////////////////////
-
-template <typename OuterAlloc, typename... InnerAllocs>
-inline
-scoped_allocator_adaptor_base<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor_base()
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename OuterA2>
- scoped_allocator_adaptor_base<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor_base(OuterA2&& outerAlloc,
- const InnerAllocs&... innerAllocs)
- : OuterAlloc(std::forward<OuterA2>(outerAlloc))
- , _M_inner_allocs(innerAllocs...)
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename OuterA2>
- scoped_allocator_adaptor_base<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor_base(
- const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other)
- : OuterAlloc(other.outer_allocator())
- , _M_inner_allocs(other.inner_allocator())
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename OuterA2>
- scoped_allocator_adaptor_base<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor_base(
- scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other)
- : OuterAlloc(std::move(other.outer_allocator()))
- , _M_inner_allocs(std::move(other.inner_allocator()))
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
-inline
-scoped_allocator_adaptor<OuterAlloc,InnerAllocs...>
-scoped_allocator_adaptor_base<OuterAlloc,InnerAllocs...>::
- select_on_container_copy_construction() const
-{
- return scoped_allocator_adaptor<OuterAlloc,InnerAllocs...>(
- allocator_traits<OuterAlloc>::select_on_container_copy_construction(
- this->outer_allocator()),
- allocator_traits<inner_allocator_type>::select_on_container_copy_construction(
- this->inner_allocator()));
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor_base<OuterAlloc> specialization
-///////////////////////////////////////////////////////////////////////////////
-
-template <typename OuterAlloc>
-inline
-scoped_allocator_adaptor_base<OuterAlloc>::
- scoped_allocator_adaptor_base()
-{
-}
-
-template <typename OuterAlloc>
- template <typename OuterA2>
- scoped_allocator_adaptor_base<OuterAlloc>::
- scoped_allocator_adaptor_base(OuterA2&& outerAlloc)
- : OuterAlloc(std::forward<OuterA2>(outerAlloc))
-{
-}
-
-template <typename OuterAlloc>
- template <typename OuterA2>
- scoped_allocator_adaptor_base<OuterAlloc>::
- scoped_allocator_adaptor_base(
- const scoped_allocator_adaptor<OuterA2>& other)
- : OuterAlloc(other.outer_allocator())
-{
-}
-
-template <typename OuterAlloc>
- template <typename OuterA2>
- scoped_allocator_adaptor_base<OuterAlloc>::
- scoped_allocator_adaptor_base(
- scoped_allocator_adaptor<OuterA2>&& other)
- : OuterAlloc(std::move(other.outer_allocator()))
-{
-}
-
-// template <typename OuterAlloc>
-// inline
-// scoped_allocator_adaptor<OuterAlloc>&
-// scoped_allocator_adaptor_base<OuterAlloc>::inner_allocator()
-// {
-// return *this;
-// }
-
-// template <typename OuterAlloc>
-// inline
-// scoped_allocator_adaptor<OuterAlloc> const&
-// scoped_allocator_adaptor_base<OuterAlloc>::inner_allocator() cosnt
-// {
-// return *this;
-// }
-
-template <typename OuterAlloc>
-inline
-scoped_allocator_adaptor<OuterAlloc>
-scoped_allocator_adaptor_base<OuterAlloc>::
-select_on_container_copy_construction() const
-{
- return
- allocator_traits<OuterAlloc>::select_on_container_copy_construction(
- this->outer_allocator());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor details
-///////////////////////////////////////////////////////////////////////////////
-
-namespace __details {
-
- // Overload resolution for __has_ctor resolves to this function
- // when _Tp is constructible with _Args. Returns true_type().
-
- static void* __void_p; // Declared but not defined
-
- template <typename _Tp, typename... _Args>
- inline
- auto __has_ctor(int, _Args&&... __args) ->
- decltype((new (__void_p) _Tp(__args...), std::true_type()))
- { return std::true_type(); }
-
- // Overload resolution for __has_ctor resolves to this function
- // when _Tp is not constructible with _Args. Returns false_type().
- template <typename _Tp, typename... _Args>
- auto __has_ctor(_LowPriorityConversion<int>, _Args&&...) ->
- std::false_type
- { return std::false_type(); }
-
- template <typename _Alloc>
- struct __is_scoped_allocator_imp {
- template <typename T>
- static char test(int, typename T::outer_allocator_type*);
- template <typename T>
- static int test(_LowPriorityConversion<int>, void*);
- static const bool value = (1 == sizeof(test<_Alloc>(0, 0)));
- };
-
- template <typename _Alloc>
- struct __is_scoped_allocator
- : std::integral_constant<bool, __is_scoped_allocator_imp<_Alloc>::value>
- {
- };
-
-#if 0
- // Called when outer_allocator_type is not a scoped allocator
- // (recursion stop).
- template <typename _Alloc>
- inline
- auto __outermost_alloc(_LowPriorityConversion<int>, _Alloc& __a) ->
- _Alloc&
- {
- return __a;
- }
-
- // Called when outer_allocator_type is a scoped allocator to
- // return the outermost allocator type.
- template <typename _Alloc>
- inline auto __outermost_alloc(int, _Alloc& __a) ->
- decltype(__outermost_alloc(0,__a.outer_allocator()))
- {
- return __a.outer_allocator();
- }
-#endif
-
- template <typename _Ignore, typename _OuterAlloc,
- typename _InnerAlloc, typename _Tp, typename... _Args>
- inline void __dispatch_scoped_construct(std::false_type __uses_alloc,
- _Ignore __use_alloc_prefix,
- _OuterAlloc& __outer_alloc,
- _InnerAlloc& __inner_alloc,
- _Tp* __p, _Args&&... __args)
- {
- // _Tp doesn't use allocators. Construct without an
- // allocator argument.
- allocator_traits<_OuterAlloc>::construct(__outer_alloc, __p,
- std::forward<_Args>(__args)...);
- }
-
- template <typename _OuterAlloc,
- typename _InnerAlloc, typename _Tp, typename... _Args>
- inline void __dispatch_scoped_construct(std::true_type __uses_alloc,
- std::true_type __use_alloc_prefix,
- _OuterAlloc& __outer_alloc,
- _InnerAlloc& __inner_alloc,
- _Tp* __p, _Args&&... __args)
- {
- // _Tp doesn't use allocators. Construct without an
- // allocator argument.
- allocator_traits<_OuterAlloc>::construct(__outer_alloc, __p,
- allocator_arg, __inner_alloc,
- std::forward<_Args>(__args)...);
- }
-
- template <typename _OuterAlloc,
- typename _InnerAlloc, typename _Tp, typename... _Args>
- inline void __dispatch_scoped_construct(std::true_type __uses_alloc,
- std::false_type __use_alloc_prefix,
- _OuterAlloc& __outer_alloc,
- _InnerAlloc& __inner_alloc,
- _Tp* __p, _Args&&... __args)
- {
- // If _Tp uses an allocator compatible with _InnerAlloc,
- // but the specific constructor does not have a variant that
- // takes an allocator argument, then program is malformed.
-// static_assert(has_constructor<_Tp, _Args...>::value,
-// "Cannot pass inner allocator to this constructor");
-
- allocator_traits<_OuterAlloc>::construct(
- __outer_alloc, __p, std::forward<_Args>(__args)...,
- __inner_alloc);
- }
-
- template <typename _OuterAlloc, typename _InnerAlloc,
- typename _Tp, typename... _Args>
- inline void __do_scoped_construct(std::false_type __scoped_outer,
- _OuterAlloc& __outer_alloc,
- _InnerAlloc& __inner_alloc,
- _Tp* __p, _Args&&... __args)
- {
- // Dispatch construction to the correct __dispatch_scoped_construct()
- // function based on whether _Tp uses an allocator of type
- // _InnerAlloc and, if so, whether there exists the following
- // constructor:
- // _Tp(allocator_arg_t, _InnerAlloc, Args...).
- auto __uses_alloc = uses_allocator<_Tp, _InnerAlloc>();
- auto __use_alloc_prefix = __has_ctor<_Tp>(0, allocator_arg,
- __inner_alloc,
- std::forward<_Args>(__args)...);
- __dispatch_scoped_construct(__uses_alloc, __use_alloc_prefix,
- __outer_alloc,
- __inner_alloc,
- __p, std::forward<_Args>(__args)...);
- }
-
- template <typename _OuterAlloc, typename _InnerAlloc,
- typename _Tp, typename... _Args>
- void __do_scoped_construct(std::true_type __scoped_outer,
- _OuterAlloc& __outer_alloc,
- _InnerAlloc& __inner_alloc,
- _Tp* __p, _Args&&... __args)
- {
- // Use outermost allocator if __outer_alloc is scoped
- typedef typename _OuterAlloc::outer_allocator_type outerouter;
- __do_scoped_construct(__is_scoped_allocator<outerouter>(),
- __outer_alloc.outer_allocator(),
- __inner_alloc,
- __p, std::forward<_Args>(__args)...);
- }
-
-} // end namespace __details
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation of scoped_allocator_adaptor
-///////////////////////////////////////////////////////////////////////////////
-
-template <typename OuterAlloc, typename... InnerAllocs>
-scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor()
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
-scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor(const scoped_allocator_adaptor& other)
- : _Base(other)
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename OuterA2>
- scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
- InnerAllocs...>& other)
- : _Base(other)
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename OuterA2>
- scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other)
- : _Base(std::move(other))
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename OuterA2>
- scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs)
- : _Base(std::forward<OuterA2>(outerAlloc), innerAllocs...)
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
-scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- ~scoped_allocator_adaptor()
-{
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
-inline typename allocator_traits<OuterAlloc>::pointer
-scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- allocate(size_type n)
-{
- return allocator_traits<OuterAlloc>::allocate(outer_allocator(), n);
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
-inline typename allocator_traits<OuterAlloc>::pointer
-scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- allocate(size_type n, const_void_pointer hint)
-{
- return allocator_traits<OuterAlloc>::allocate(outer_allocator(), n, hint);
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
-inline void scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- deallocate(pointer p, size_type n)
-{
- allocator_traits<OuterAlloc>::deallocate(outer_allocator(), p, n);
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
-inline typename allocator_traits<OuterAlloc>::size_type
-scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::max_size() const
-{
- return allocator_traits<OuterAlloc>::max_size(outer_allocator());
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename T>
- inline void scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>::
- destroy(T* p)
-{
- allocator_traits<OuterAlloc>::destroy(outer_allocator(), p);
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <typename T, typename... Args>
- inline
- void scoped_allocator_adaptor<OuterAlloc,InnerAllocs...>::construct(T* p,
- Args&&... args)
-{
- __do_scoped_construct(__details::__is_scoped_allocator<OuterAlloc>(),
- this->outer_allocator(), this->inner_allocator(),
- p, std::forward<Args>(args)...);
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <class T1, class T2>
- void scoped_allocator_adaptor<OuterAlloc,InnerAllocs...>::construct(
- std::pair<T1,T2>* p)
-{
- construct(addressof(p->first));
- try {
- construct(addressof(p->second));
- }
- catch (...) {
- destroy(addressof(p->first));
- throw;
- }
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <class T1, class T2, class U, class V>
- void scoped_allocator_adaptor<OuterAlloc,InnerAllocs...>::construct(
- std::pair<T1,T2>* p, U&& x, V&& y)
-{
- construct(addressof(p->first), std::forward<U>(x));
- try {
- construct(addressof(p->second), std::forward<V>(y));
- }
- catch (...) {
- destroy(addressof(p->first));
- throw;
- }
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <class T1, class T2, class U, class V>
- void scoped_allocator_adaptor<OuterAlloc,InnerAllocs...>::construct(
- std::pair<T1,T2>* p, const std::pair<U, V>& pr)
-{
- construct(addressof(p->first), pr.first);
- try {
- construct(addressof(p->second), pr.second);
- }
- catch (...) {
- destroy(addressof(p->first));
- throw;
- }
-}
-
-template <typename OuterAlloc, typename... InnerAllocs>
- template <class T1, class T2, class U, class V>
- void scoped_allocator_adaptor<OuterAlloc,InnerAllocs...>::construct(
- std::pair<T1,T2>* p, std::pair<U, V>&& pr)
-{
- construct(addressof(p->first), std::move(pr.first));
- try {
- construct(addressof(p->second), std::move(pr.second));
- }
- catch (...) {
- destroy(addressof(p->first));
- throw;
- }
-}
-
-template <typename OuterA1, typename OuterA2, typename... InnerAllocs>
-inline
-bool operator==(const scoped_allocator_adaptor<OuterA1,InnerAllocs...>& a,
- const scoped_allocator_adaptor<OuterA2,InnerAllocs...>& b)
-{
- return a.outer_allocator() == b.outer_allocator()
- && a.inner_allocator() == b.inner_allocator();
-}
-
-template <typename OuterA1, typename OuterA2>
-inline
-bool operator==(const scoped_allocator_adaptor<OuterA1>& a,
- const scoped_allocator_adaptor<OuterA2>& b)
-{
- return a.outer_allocator() == b.outer_allocator();
-}
-
-template <typename OuterA1, typename OuterA2, typename... InnerAllocs>
-inline
-bool operator!=(const scoped_allocator_adaptor<OuterA1,InnerAllocs...>& a,
- const scoped_allocator_adaptor<OuterA2,InnerAllocs...>& b)
-{
- return ! (a == b);
-}
-
-}} // namespace boost { namespace container {
-
-#include <boost/container/detail/config_end.hpp>
-
-#endif // BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
diff --git a/boost/container/allocator/allocator_traits.hpp b/boost/container/allocator_traits.hpp
index 01921615cf..8e537ccf6f 100644
--- a/boost/container/allocator/allocator_traits.hpp
+++ b/boost/container/allocator_traits.hpp
@@ -6,7 +6,7 @@
//
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2011-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -24,7 +24,8 @@
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
#include <boost/intrusive/pointer_traits.hpp>
-#include <boost/container/allocator/memory_util.hpp>
+#include <boost/intrusive/detail/memory_util.hpp>
+#include <boost/container/detail/memory_util.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/move/move.hpp>
@@ -53,6 +54,8 @@ struct is_std_allocator< std::allocator<T> >
///@endcond
+//! The class template allocator_traits supplies a uniform interface to all allocator types.
+//! This class is a C++03-compatible implementation of std::allocator_traits
template <typename Alloc>
struct allocator_traits
{
@@ -62,54 +65,54 @@ struct allocator_traits
typedef typename Alloc::value_type value_type;
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //!Alloc::pointer if such a type exists; otherwise, value_type*
+ //! Alloc::pointer if such a type exists; otherwise, value_type*
//!
typedef unspecified pointer;
- //!Alloc::const_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<const
+ //! Alloc::const_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<const
//!
typedef unspecified const_pointer;
- //!Non-standard extension
- //!Alloc::reference if such a type exists; otherwise, value_type&
- typedef unspecified pointer;
- //!Non-standard extension
- //!Alloc::const_reference if such a type exists ; otherwise, const value_type&
- typedef unspecified const_pointer;
- //!Alloc::void_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<void>.
+ //! Non-standard extension
+ //! Alloc::reference if such a type exists; otherwise, value_type&
+ typedef unspecified reference;
+ //! Non-standard extension
+ //! Alloc::const_reference if such a type exists ; otherwise, const value_type&
+ typedef unspecified const_reference;
+ //! Alloc::void_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<void>.
//!
typedef unspecified void_pointer;
- //!Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits<pointer>::rebind<const
+ //! Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits<pointer>::rebind<const
//!
typedef unspecified const_void_pointer;
- //!Alloc::difference_type if such a type exists ; otherwise, pointer_traits<pointer>::difference_type.
+ //! Alloc::difference_type if such a type exists ; otherwise, pointer_traits<pointer>::difference_type.
//!
typedef unspecified difference_type;
- //!Alloc::size_type if such a type exists ; otherwise, make_unsigned<difference_type>::type
+ //! Alloc::size_type if such a type exists ; otherwise, make_unsigned<difference_type>::type
//!
typedef unspecified size_type;
- //!Alloc::propagate_on_container_copy_assignment if such a type exists, otherwise an integral_constant
- //!type with internal constant static member <pre>value</pre> == false.
+ //! Alloc::propagate_on_container_copy_assignment if such a type exists, otherwise an integral_constant
+ //! type with internal constant static member `value` == false.
typedef unspecified propagate_on_container_copy_assignment;
- //!Alloc::propagate_on_container_move_assignment if such a type exists, otherwise an integral_constant
- //!type with internal constant static member <pre>value</pre> == false.
+ //! Alloc::propagate_on_container_move_assignment if such a type exists, otherwise an integral_constant
+ //! type with internal constant static member `value` == false.
typedef unspecified propagate_on_container_move_assignment;
- //!Alloc::propagate_on_container_swap if such a type exists, otherwise an integral_constant
- //!type with internal constant static member <pre>value</pre> == false.
+ //! Alloc::propagate_on_container_swap if such a type exists, otherwise an integral_constant
+ //! type with internal constant static member `value` == false.
typedef unspecified propagate_on_container_swap;
- //!Defines an allocator: Alloc::rebind<T>::other if such a type exists; otherwise, Alloc<T, Args>
- //!if Alloc is a class template instantiation of the form Alloc<U, Args>, where Args is zero or
- //!more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
+ //! Defines an allocator: Alloc::rebind<T>::other if such a type exists; otherwise, Alloc<T, Args>
+ //! if Alloc is a class template instantiation of the form Alloc<U, Args>, where Args is zero or
+ //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
//!
- //!In C++03 compilers <pre>rebind_alloc</pre> is a struct derived from an allocator
- //!deduced by previously detailed rules.
+ //! In C++03 compilers `rebind_alloc` is a struct derived from an allocator
+ //! deduced by previously detailed rules.
template <class T> using rebind_alloc = unspecified;
- //!In C++03 compilers <pre>rebind_traits</pre> is a struct derived from
- //!<pre>allocator_traits<OtherAlloc><pre>, where `OtherAlloc` is
- //!the allocator deduced by rules explained in `rebind_alloc`.
+ //! In C++03 compilers `rebind_traits` is a struct derived from
+ //! `allocator_traits<OtherAlloc>`, where `OtherAlloc` is
+ //! the allocator deduced by rules explained in `rebind_alloc`.
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T> >;
- //!Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers.
- //!`type` is an allocator related to Alloc deduced deduced by rules explained in `rebind_alloc`.
+ //! Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers.
+ //! `type` is an allocator related to Alloc deduced deduced by rules explained in `rebind_alloc`.
template <class T>
struct portable_rebind_alloc
{ typedef unspecified_type type; };
@@ -119,7 +122,7 @@ struct allocator_traits
pointer, value_type*)
pointer;
//const_pointer
- typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc,
+ typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc,
const_pointer, typename boost::intrusive::pointer_traits<pointer>::template
rebind_pointer<const value_type>)
const_pointer;
@@ -128,11 +131,11 @@ struct allocator_traits
reference, typename container_detail::unvoid<value_type>::type&)
reference;
//const_reference
- typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
+ typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,
const_reference, const typename container_detail::unvoid<value_type>::type&)
const_reference;
//void_pointer
- typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc,
+ typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc,
void_pointer, typename boost::intrusive::pointer_traits<pointer>::template
rebind_pointer<void>)
void_pointer;
@@ -164,9 +167,9 @@ struct allocator_traits
#if !defined(BOOST_NO_TEMPLATE_ALIASES)
//C++11
- template <typename T> using rebind_alloc = boost::intrusive::detail::type_rebinder<Alloc, T>::type;
+ template <typename T> using rebind_alloc = typename boost::intrusive::detail::type_rebinder<Alloc, T>::type;
template <typename T> using rebind_traits = allocator_traits< rebind_alloc<T> >;
- #else //!defined(BOOST_NO_TEMPLATE_ALIASES)
+ #else // #if !defined(BOOST_NO_TEMPLATE_ALIASES)
//Some workaround for C++03 or C++11 compilers with no template aliases
template <typename T>
struct rebind_alloc : boost::intrusive::detail::type_rebinder<Alloc,T>::type
@@ -174,10 +177,10 @@ struct allocator_traits
typedef typename boost::intrusive::detail::type_rebinder<Alloc,T>::type Base;
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
template <typename... Args>
- rebind_alloc(Args&&... args)
+ rebind_alloc(BOOST_FWD_REF(Args)... args)
: Base(boost::forward<Args>(args)...)
{}
- #else //!defined(BOOST_NO_VARIADIC_TEMPLATES)
+ #else // #if !defined(BOOST_NO_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, >) \
rebind_alloc(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
@@ -186,32 +189,32 @@ struct allocator_traits
//
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
#include BOOST_PP_LOCAL_ITERATE()
- #endif //!defined(BOOST_NO_VARIADIC_TEMPLATES)
+ #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
};
template <typename T>
struct rebind_traits
: allocator_traits<typename boost::intrusive::detail::type_rebinder<Alloc, T>::type>
{};
- #endif //!defined(BOOST_NO_TEMPLATE_ALIASES)
+ #endif // #if !defined(BOOST_NO_TEMPLATE_ALIASES)
template <class T>
struct portable_rebind_alloc
{ typedef typename boost::intrusive::detail::type_rebinder<Alloc, T>::type type; };
#endif //BOOST_CONTAINER_DOXYGEN_INVOKED
- //!<b>Returns</b>: a.allocate(n)
+ //! <b>Returns</b>: `a.allocate(n)`
//!
static pointer allocate(Alloc &a, size_type n)
{ return a.allocate(n); }
- //!<b>Returns</b>: a.deallocate(p, n)
+ //! <b>Returns</b>: `a.deallocate(p, n)`
//!
- //!<b>Throws</b>: Nothing
+ //! <b>Throws</b>: Nothing
static void deallocate(Alloc &a, pointer p, size_type n)
{ return a.deallocate(p, n); }
- //!<b>Effects</b>: calls `a.construct(p, std::forward<Args>(args)...)` if that call is well-formed;
- //!otherwise, invokes `::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)`
+ //! <b>Effects</b>: calls `a.allocate(n, p)` if that call is well-formed;
+ //! otherwise, invokes `a.allocate(n)`
static pointer allocate(Alloc &a, size_type n, const_void_pointer p)
{
const bool value = boost::container::container_detail::
@@ -221,8 +224,8 @@ struct allocator_traits
return allocator_traits::priv_allocate(flag, a, n, p);
}
- //!<b>Effects</b>: calls a.destroy(p) if that call is well-formed;
- //!otherwise, invokes `p->~T()`.
+ //! <b>Effects</b>: calls `a.destroy(p)` if that call is well-formed;
+ //! otherwise, invokes `p->~T()`.
template<class T>
static void destroy(Alloc &a, T*p)
{
@@ -234,8 +237,8 @@ struct allocator_traits
allocator_traits::priv_destroy(flag, a, p);
}
- //!<b>Returns</b>: a.max_size() if that expression is well-formed; otherwise,
- //!`numeric_limits<size_type>::max()`.
+ //! <b>Returns</b>: `a.max_size()` if that expression is well-formed; otherwise,
+ //! `numeric_limits<size_type>::max()`.
static size_type max_size(const Alloc &a)
{
const bool value = boost::container::container_detail::
@@ -245,8 +248,8 @@ struct allocator_traits
return allocator_traits::priv_max_size(flag, a);
}
- //!<b>Returns</b>: a.select_on_container_copy_construction() if that expres sion is well- formed;
- //!otherwise, a.
+ //! <b>Returns</b>: `a.select_on_container_copy_construction()` if that expression is well-formed;
+ //! otherwise, a.
static Alloc select_on_container_copy_construction(const Alloc &a)
{
const bool value = boost::container::container_detail::
@@ -256,17 +259,17 @@ struct allocator_traits
return allocator_traits::priv_select_on_container_copy_construction(flag, a);
}
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //!Effects: calls a.construct(p, std::forward<Args>(args)...) if that call is well-formed;
- //!otherwise, invokes `::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)`
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: calls `a.construct(p, std::forward<Args>(args)...)` if that call is well-formed;
+ //! otherwise, invokes `::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)`
template <class T, class ...Args>
- static void construct(Alloc & a, T* p, Args&&... args)
+ static void construct(Alloc & a, T* p, BOOST_FWD_REF(Args)... args)
{
::boost::integral_constant<bool, container_detail::is_std_allocator<Alloc>::value> flag;
allocator_traits::priv_construct(flag, a, p, ::boost::forward<Args>(args)...);
}
#endif
-
+ ///@cond
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
private:
static pointer priv_allocate(boost::true_type, Alloc &a, size_type n, const_void_pointer p)
@@ -295,10 +298,10 @@ struct allocator_traits
static Alloc priv_select_on_container_copy_construction(boost::false_type, const Alloc &a)
{ return a; }
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING)
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
template<class T, class ...Args>
- static void priv_construct(boost::false_type, Alloc &a, T *p, Args && ...args)
- {
+ static void priv_construct(boost::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args)
+ {
const bool value = boost::container::container_detail::
has_member_function_callable_with_construct
< Alloc, T*, Args... >::value;
@@ -307,19 +310,19 @@ struct allocator_traits
}
template<class T, class ...Args>
- static void priv_construct(boost::true_type, Alloc &a, T *p, Args && ...args)
+ static void priv_construct(boost::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args)
{
priv_construct_dispatch2(boost::false_type(), a, p, ::boost::forward<Args>(args)...);
}
template<class T, class ...Args>
- static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p, Args && ...args)
+ static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args)
{ a.construct( p, ::boost::forward<Args>(args)...); }
template<class T, class ...Args>
- static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p, Args && ...args)
+ static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p, BOOST_FWD_REF(Args) ...args)
{ ::new((void*)p) T(::boost::forward<Args>(args)...); }
- #else
+ #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
public:
#define BOOST_PP_LOCAL_MACRO(n) \
template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \
@@ -333,7 +336,7 @@ struct allocator_traits
//
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
#include BOOST_PP_LOCAL_ITERATE()
-
+
private:
#define BOOST_PP_LOCAL_MACRO(n) \
template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \
@@ -368,7 +371,7 @@ struct allocator_traits
//
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
#include BOOST_PP_LOCAL_ITERATE()
- #endif //BOOST_CONTAINER_PERFECT_FORWARDING
+ #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
#endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
///@endcond
diff --git a/boost/container/container_fwd.hpp b/boost/container/container_fwd.hpp
index da325e4461..c52b04a1c9 100644
--- a/boost/container/container_fwd.hpp
+++ b/boost/container/container_fwd.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -21,8 +21,8 @@
/// @cond
-namespace boost{
-namespace intrusive{
+namespace boost{
+namespace intrusive{
//Create namespace to avoid compilation errors
}}
@@ -32,9 +32,9 @@ namespace bi = boost::intrusive;
}}}
-#include <utility>
-#include <memory>
-#include <functional>
+#include <utility>
+#include <memory>
+#include <functional>
#include <iosfwd>
#include <string>
@@ -127,31 +127,27 @@ class flat_multimap;
//basic_string class
template <class CharT
,class Traits = std::char_traits<CharT>
- ,class A = std::allocator<CharT> >
+ ,class A = std::allocator<CharT> >
class basic_string;
//! Type used to tag that the input range is
//! guaranteed to be ordered
-struct ordered_range_impl_t {};
+struct ordered_range_t
+{};
//! Type used to tag that the input range is
//! guaranteed to be ordered and unique
-struct ordered_unique_range_impl_t{};
-
-/// @cond
-
-typedef ordered_range_impl_t * ordered_range_t;
-typedef ordered_unique_range_impl_t *ordered_unique_range_t;
-
-/// @endcond
+struct ordered_unique_range_t
+ : public ordered_range_t
+{};
//! Value used to tag that the input range is
//! guaranteed to be ordered
-static const ordered_range_t ordered_range = 0;
+static const ordered_range_t ordered_range = ordered_range_t();
//! Value used to tag that the input range is
//! guaranteed to be ordered and unique
-static const ordered_unique_range_t ordered_unique_range = 0;
+static const ordered_unique_range_t ordered_unique_range = ordered_unique_range_t();
/// @cond
diff --git a/boost/container/deque.hpp b/boost/container/deque.hpp
index 9ee0ee1371..6a85ae9486 100644
--- a/boost/container/deque.hpp
+++ b/boost/container/deque.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -44,7 +44,7 @@
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/algorithms.hpp>
#include <boost/container/detail/mpl.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/container/container_fwd.hpp>
#include <cstddef>
#include <iterator>
@@ -90,7 +90,7 @@ struct deque_value_traits
// Note: this function is simply a kludge to work around several compilers'
// bugs in handling constant expressions.
-inline std::size_t deque_buf_size(std::size_t size)
+inline std::size_t deque_buf_size(std::size_t size)
{ return size < 512 ? std::size_t(512 / size) : std::size_t(1); }
// Deque base class. It has two purposes. First, its constructor
@@ -128,16 +128,16 @@ class deque_base
static size_type s_buffer_size() { return deque_buf_size(sizeof(T)); }
- val_alloc_ptr priv_allocate_node()
+ val_alloc_ptr priv_allocate_node()
{ return this->alloc().allocate(s_buffer_size()); }
- void priv_deallocate_node(val_alloc_ptr p)
+ void priv_deallocate_node(val_alloc_ptr p)
{ this->alloc().deallocate(p, s_buffer_size()); }
- ptr_alloc_ptr priv_allocate_map(size_type n)
+ ptr_alloc_ptr priv_allocate_map(size_type n)
{ return this->ptr_alloc().allocate(n); }
- void priv_deallocate_map(ptr_alloc_ptr p, size_type n)
+ void priv_deallocate_map(ptr_alloc_ptr p, size_type n)
{ this->ptr_alloc().deallocate(p, n); }
public:
@@ -145,7 +145,7 @@ class deque_base
// For any nonsingular iterator i:
// i.node is the address of an element in the map array. The
// contents of i.node is a pointer to the beginning of a node.
- // i.first == //(i.node)
+ // i.first == //(i.node)
// i.last == i.first + node_size
// i.cur is a pointer in the range [i.first, i.last). NOTE:
// the implication of this is that i.cur is always a dereferenceable
@@ -160,14 +160,14 @@ class deque_base
// [start.cur, start.last) and [finish.first, finish.cur) are initialized
// objects, and [start.first, start.cur) and [finish.cur, finish.last)
// are uninitialized storage.
- // [map, map + map_size) is a valid, non-empty range.
- // [start.node, finish.node] is a valid range contained within
- // [map, map + map_size).
+ // [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
// 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,
- val_alloc_val, val_alloc_diff,
+ class const_iterator
+ : public std::iterator<std::random_access_iterator_tag,
+ val_alloc_val, val_alloc_diff,
val_alloc_cptr, val_alloc_cref>
{
public:
@@ -185,30 +185,30 @@ class deque_base
friend class deque<T, A>;
friend class deque_base<T, A>;
- protected:
+ protected:
val_alloc_ptr m_cur;
val_alloc_ptr m_first;
val_alloc_ptr m_last;
index_pointer m_node;
- public:
- const_iterator(val_alloc_ptr x, index_pointer y)
+ public:
+ const_iterator(val_alloc_ptr x, index_pointer y)
: m_cur(x), m_first(*y),
m_last(*y + s_buffer_size()), m_node(y) {}
const_iterator() : m_cur(0), m_first(0), m_last(0), m_node(0) {}
const_iterator(const const_iterator& x)
- : m_cur(x.m_cur), m_first(x.m_first),
+ : m_cur(x.m_cur), m_first(x.m_first),
m_last(x.m_last), m_node(x.m_node) {}
- reference operator*() const
+ reference operator*() const
{ return *this->m_cur; }
- pointer operator->() const
+ pointer operator->() const
{ return this->m_cur; }
- difference_type operator-(const self_t& x) const
+ difference_type operator-(const self_t& x) const
{
if(!this->m_cur && !x.m_cur){
return 0;
@@ -217,24 +217,24 @@ class deque_base
(this->m_cur - this->m_first) + (x.m_last - x.m_cur);
}
- self_t& operator++()
+ self_t& operator++()
{
++this->m_cur;
if (this->m_cur == this->m_last) {
this->priv_set_node(this->m_node + 1);
this->m_cur = this->m_first;
}
- return *this;
+ return *this;
}
- self_t operator++(int)
+ self_t operator++(int)
{
self_t tmp = *this;
++*this;
return tmp;
}
- self_t& operator--()
+ self_t& operator--()
{
if (this->m_cur == this->m_first) {
this->priv_set_node(this->m_node - 1);
@@ -244,7 +244,7 @@ class deque_base
return *this;
}
- self_t operator--(int)
+ self_t operator--(int)
{
self_t tmp = *this;
--*this;
@@ -261,7 +261,7 @@ class deque_base
offset > 0 ? offset / difference_type(this->s_buffer_size())
: -difference_type((-offset - 1) / this->s_buffer_size()) - 1;
this->priv_set_node(this->m_node + node_offset);
- this->m_cur = this->m_first +
+ this->m_cur = this->m_first +
(offset - node_offset * difference_type(this->s_buffer_size()));
}
return *this;
@@ -270,37 +270,37 @@ class deque_base
self_t operator+(difference_type n) const
{ self_t tmp = *this; return tmp += n; }
- self_t& operator-=(difference_type n)
+ self_t& operator-=(difference_type n)
{ return *this += -n; }
-
- self_t operator-(difference_type n) const
+
+ self_t operator-(difference_type n) const
{ self_t tmp = *this; return tmp -= n; }
- reference operator[](difference_type n) const
+ reference operator[](difference_type n) const
{ return *(*this + n); }
- bool operator==(const self_t& x) const
+ bool operator==(const self_t& x) const
{ return this->m_cur == x.m_cur; }
- bool operator!=(const self_t& x) const
+ bool operator!=(const self_t& x) const
{ return !(*this == x); }
- bool operator<(const self_t& x) const
+ bool operator<(const self_t& x) const
{
- return (this->m_node == x.m_node) ?
+ return (this->m_node == x.m_node) ?
(this->m_cur < x.m_cur) : (this->m_node < x.m_node);
}
- bool operator>(const self_t& x) const
+ bool operator>(const self_t& x) const
{ return x < *this; }
- bool operator<=(const self_t& x) const
+ bool operator<=(const self_t& x) const
{ return !(x < *this); }
- bool operator>=(const self_t& x) const
+ bool operator>=(const self_t& x) const
{ return !(*this < x); }
- void priv_set_node(index_pointer new_node)
+ void priv_set_node(index_pointer new_node)
{
this->m_node = new_node;
this->m_first = *new_node;
@@ -343,12 +343,12 @@ class deque_base
reference operator[](difference_type n) const { return *(*this + n); }
//Increment / Decrement
- iterator& operator++()
+ iterator& operator++()
{ this->const_iterator::operator++(); return *this; }
iterator operator++(int)
{ iterator tmp = *this; ++*this; return tmp; }
-
+
iterator& operator--()
{ this->const_iterator::operator--(); return *this; }
@@ -379,7 +379,7 @@ class deque_base
: members_(a)
{ this->priv_initialize_map(num_elements); }
- explicit deque_base(const allocator_type& a)
+ explicit deque_base(const allocator_type& a)
: members_(a)
{}
@@ -402,7 +402,7 @@ class deque_base
private:
deque_base(const deque_base&);
-
+
protected:
void swap_members(deque_base &x)
@@ -423,7 +423,7 @@ class deque_base
ptr_alloc_ptr nstart = this->members_.m_map + (this->members_.m_map_size - num_nodes) / 2;
ptr_alloc_ptr nfinish = nstart + num_nodes;
-
+
BOOST_TRY {
this->priv_create_nodes(nstart, nfinish);
}
@@ -508,16 +508,16 @@ class deque_base
iterator m_finish;
} members_;
- ptr_alloc_t &ptr_alloc()
+ ptr_alloc_t &ptr_alloc()
{ return members_; }
-
- const ptr_alloc_t &ptr_alloc() const
+
+ const ptr_alloc_t &ptr_alloc() const
{ return members_; }
- allocator_type &alloc()
+ allocator_type &alloc()
{ return members_; }
-
- const allocator_type &alloc() const
+
+ const allocator_type &alloc() const
{ return members_; }
};
/// @endcond
@@ -574,7 +574,7 @@ class deque : protected deque_base<T, A>
private: // Internal typedefs
BOOST_COPYABLE_AND_MOVABLE(deque)
typedef ptr_alloc_ptr index_pointer;
- static size_type s_buffer_size()
+ static size_type s_buffer_size()
{ return Base::s_buffer_size(); }
typedef container_detail::advanced_insert_aux_int<iterator> advanced_insert_aux_int_t;
typedef repeat_iterator<T, difference_type> r_iterator;
@@ -586,175 +586,175 @@ class deque : protected deque_base<T, A>
public:
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
{ return Base::alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
{ return Base::alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
{ return Base::alloc(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator begin() BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start; }
//! <b>Effects</b>: Returns an iterator to the end of the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end() BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_finish; }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start; }
//! <b>Effects</b>: Returns a const_iterator to the end of the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator end() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_finish; }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed deque.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed deque.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
{ return reverse_iterator(this->members_.m_finish); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed deque.
- //!
+ //! of the reversed deque.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
{ return reverse_iterator(this->members_.m_start); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed deque.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed deque.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
{ return const_reverse_iterator(this->members_.m_finish); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed deque.
- //!
+ //! of the reversed deque.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
{ return const_reverse_iterator(this->members_.m_start); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start; }
//! <b>Effects</b>: Returns a const_iterator to the end of the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_finish; }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed deque.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed deque.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
{ return const_reverse_iterator(this->members_.m_finish); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed deque.
- //!
+ //! of the reversed deque.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
{ return const_reverse_iterator(this->members_.m_start); }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start[difference_type(n)]; }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start[difference_type(n)]; }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference at(size_type n)
{ this->priv_range_check(n); return (*this)[n]; }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference at(size_type n) const
{ this->priv_range_check(n); return (*this)[n]; }
@@ -763,20 +763,20 @@ class deque : protected deque_base<T, A>
//!
//! <b>Effects</b>: Returns a reference to the first
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference front() BOOST_CONTAINER_NOEXCEPT
{ return *this->members_.m_start; }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a const reference to the first element
+ //! <b>Effects</b>: Returns a const reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference front() const BOOST_CONTAINER_NOEXCEPT
{ return *this->members_.m_start; }
@@ -785,9 +785,9 @@ class deque : protected deque_base<T, A>
//!
//! <b>Effects</b>: Returns a reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference back() BOOST_CONTAINER_NOEXCEPT
{ return *(end()-1); }
@@ -796,52 +796,52 @@ class deque : protected deque_base<T, A>
//!
//! <b>Effects</b>: Returns a const reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference back() const BOOST_CONTAINER_NOEXCEPT
{ return *(cend()-1); }
//! <b>Effects</b>: Returns the number of the elements contained in the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type size() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_finish - this->members_.m_start; }
//! <b>Effects</b>: Returns the largest possible size of the deque.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type max_size() const BOOST_CONTAINER_NOEXCEPT
{ return allocator_traits_type::max_size(this->alloc()); }
//! <b>Effects</b>: Returns true if the deque contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
bool empty() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_finish == this->members_.m_start; }
//! <b>Effects</b>: Default constructors a deque.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- deque()
+ deque()
: Base()
{}
//! <b>Effects</b>: Constructs a deque taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- explicit deque(const allocator_type& a)
+ explicit deque(const allocator_type& a)
: Base(a)
{}
@@ -850,7 +850,7 @@ class deque : protected deque_base<T, A>
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
explicit deque(size_type n)
: Base(n, allocator_type())
@@ -865,7 +865,7 @@ class deque : protected deque_base<T, A>
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
deque(size_type n, const value_type& value,
const allocator_type& a = allocator_type())
@@ -875,7 +875,7 @@ class deque : protected deque_base<T, A>
//! <b>Effects</b>: Copy constructs a deque.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
deque(const deque& x)
: Base(allocator_traits_type::select_on_container_copy_construction(x.alloc()))
@@ -890,12 +890,52 @@ class deque : protected deque_base<T, A>
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- deque(BOOST_RV_REF(deque) x)
+ deque(BOOST_RV_REF(deque) x)
: Base(boost::move(static_cast<Base&>(x)))
{ this->swap_members(x); }
+ //! <b>Effects</b>: Copy constructs a vector using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Throws</b>: If allocation
+ //! throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ deque(const deque& x, const allocator_type &a)
+ : Base(a)
+ {
+ if(x.size()){
+ this->priv_initialize_map(x.size());
+ boost::container::uninitialized_copy_alloc
+ (this->alloc(), x.begin(), x.end(), this->members_.m_start);
+ }
+ }
+
+ //! <b>Effects</b>: Move constructor using the specified allocator.
+ //! Moves mx's resources to *this if a == allocator_type().
+ //! Otherwise copies values from x to *this.
+ //!
+ //! <b>Throws</b>: If allocation or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == mx.get_allocator(), linear otherwise.
+ deque(BOOST_RV_REF(deque) mx, const allocator_type &a)
+ : Base(a)
+ {
+ if(mx.alloc() == a){
+ this->swap_members(mx);
+ }
+ else{
+ if(mx.size()){
+ this->priv_initialize_map(mx.size());
+ boost::container::uninitialized_copy_alloc
+ (this->alloc(), mx.begin(), mx.end(), this->members_.m_start);
+ }
+ }
+ }
+
//! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the deque.
//!
@@ -905,7 +945,7 @@ class deque : protected deque_base<T, A>
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InpIt>
deque(InpIt first, InpIt last, const allocator_type& a = allocator_type())
- : Base(a)
+ : Base(a)
{
//Dispatch depending on integer/iterator
const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
@@ -926,13 +966,13 @@ class deque : protected deque_base<T, A>
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the number of elements in x.
- deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x)
+ deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x)
{
if (&x != this){
allocator_type &this_alloc = this->alloc();
@@ -1092,7 +1132,7 @@ class deque : protected deque_base<T, A>
);
++this->members_.m_start.m_cur;
}
- else
+ else
this->priv_pop_front_aux();
}
@@ -1140,7 +1180,7 @@ class deque : protected deque_base<T, A>
//!
//! <b>Complexity</b>: Linear to std::distance [first, last).
template <class InpIt>
- void insert(const_iterator pos, InpIt first, InpIt last)
+ void insert(const_iterator pos, InpIt first, InpIt last)
{
//Dispatch depending on integer/iterator
const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
@@ -1300,10 +1340,10 @@ class deque : protected deque_base<T, A>
//! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size, const value_type& x)
+ void resize(size_type new_size, const value_type& x)
{
const size_type len = size();
- if (new_size < len)
+ if (new_size < len)
this->erase(this->members_.m_start + new_size, this->members_.m_finish);
else
this->insert(this->members_.m_finish, new_size - len, x);
@@ -1315,10 +1355,10 @@ class deque : protected deque_base<T, A>
//! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size)
+ void resize(size_type new_size)
{
const size_type len = size();
- if (new_size < len)
+ if (new_size < len)
this->priv_erase_last_n(len - new_size);
else{
size_type n = new_size - this->size();
@@ -1331,7 +1371,7 @@ class deque : protected deque_base<T, A>
//!
//! <b>Throws</b>: Nothing.
//!
- //! <b>Complexity</b>: Linear to the elements between pos and the
+ //! <b>Complexity</b>: Linear to the elements between pos and the
//! last element (if pos is near the end) or the first element
//! if(pos is near the beginning).
//! Constant if pos is the first or the last element.
@@ -1356,7 +1396,7 @@ class deque : protected deque_base<T, A>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the distance between first and
- //! last plus the elements between pos and the
+ //! last plus the elements between pos and the
//! last element (if pos is near the end) or the first element
//! if(pos is near the beginning).
iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
@@ -1446,10 +1486,10 @@ class deque : protected deque_base<T, A>
/// @cond
private:
- void priv_range_check(size_type n) const
+ void priv_range_check(size_type n) const
{ if (n >= this->size()) BOOST_RETHROW std::out_of_range("deque"); }
- iterator priv_insert(const_iterator position, const value_type &x)
+ iterator priv_insert(const_iterator position, const value_type &x)
{
if (position == cbegin()){
this->push_front(x);
@@ -1466,7 +1506,7 @@ class deque : protected deque_base<T, A>
}
}
- iterator priv_insert(const_iterator position, BOOST_RV_REF(value_type) mx)
+ iterator priv_insert(const_iterator position, BOOST_RV_REF(value_type) mx)
{
if (position == cbegin()) {
this->push_front(boost::move(mx));
@@ -1569,7 +1609,7 @@ class deque : protected deque_base<T, A>
}
template <class FwdIt>
- void priv_insert_aux(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
+ void priv_insert_aux(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
{ this->priv_insert_aux(pos, first, last); }
// assign(), a generalized assignment member function. Two
@@ -1589,14 +1629,14 @@ class deque : protected deque_base<T, A>
}
template <class Integer>
- void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_)
+ void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_)
{
this->priv_initialize_map(n);
this->priv_fill_initialize(x);
}
template <class InpIt>
- void priv_initialize_dispatch(InpIt first, InpIt last, container_detail::false_)
+ void priv_initialize_dispatch(InpIt first, InpIt last, container_detail::false_)
{
typedef typename std::iterator_traits<InpIt>::iterator_category ItCat;
this->priv_range_initialize(first, last, ItCat());
@@ -1627,7 +1667,7 @@ class deque : protected deque_base<T, A>
{ this->priv_fill_assign((size_type) n, (value_type)val); }
template <class InpIt>
- void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_)
+ void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_)
{
typedef typename std::iterator_traits<InpIt>::iterator_category ItCat;
this->priv_assign_aux(first, last, ItCat());
@@ -1660,11 +1700,11 @@ class deque : protected deque_base<T, A>
}
template <class Integer>
- void priv_insert_dispatch(const_iterator pos, Integer n, Integer x, container_detail::true_)
+ void priv_insert_dispatch(const_iterator pos, Integer n, Integer x, container_detail::true_)
{ this->priv_fill_insert(pos, (size_type) n, (value_type)x); }
template <class InpIt>
- void priv_insert_dispatch(const_iterator pos,InpIt first, InpIt last, container_detail::false_)
+ void priv_insert_dispatch(const_iterator pos,InpIt first, InpIt last, container_detail::false_)
{
typedef typename std::iterator_traits<InpIt>::iterator_category ItCat;
this->priv_insert_aux(pos, first, last, ItCat());
@@ -1699,7 +1739,7 @@ class deque : protected deque_base<T, A>
iterator old_start = this->members_.m_start;
pos = this->members_.m_start + elemsbefore;
if (elemsbefore >= difference_type(n)) {
- iterator start_n = this->members_.m_start + difference_type(n);
+ iterator start_n = this->members_.m_start + difference_type(n);
::boost::container::uninitialized_move_alloc
(this->alloc(), this->members_.m_start, start_n, new_start);
this->members_.m_start = new_start;
@@ -1720,7 +1760,7 @@ class deque : protected deque_base<T, A>
else {
iterator new_finish = this->priv_reserve_elements_at_back(n);
iterator old_finish = this->members_.m_finish;
- const difference_type elemsafter =
+ const difference_type elemsafter =
difference_type(length) - elemsbefore;
pos = this->members_.m_finish - elemsafter;
if (elemsafter >= difference_type(n)) {
@@ -1774,7 +1814,7 @@ class deque : protected deque_base<T, A>
// Precondition: this->members_.m_start and this->members_.m_finish have already been initialized,
// but none of the deque's elements have yet been constructed.
- void priv_fill_initialize(const value_type& value)
+ void priv_fill_initialize(const value_type& value)
{
index_pointer cur;
BOOST_TRY {
@@ -1816,8 +1856,8 @@ class deque : protected deque_base<T, A>
index_pointer cur_node;
BOOST_TRY {
- for (cur_node = this->members_.m_start.m_node;
- cur_node < this->members_.m_finish.m_node;
+ for (cur_node = this->members_.m_start.m_node;
+ cur_node < this->members_.m_finish.m_node;
++cur_node) {
FwdIt mid = first;
std::advance(mid, this->s_buffer_size());
@@ -1847,9 +1887,9 @@ class deque : protected deque_base<T, A>
);
}
- // Called only if this->members_.m_start.m_cur == this->members_.m_start.m_last - 1. Note that
- // if the deque has at least one element (a precondition for this member
- // function), and if this->members_.m_start.m_cur == this->members_.m_start.m_last, then the deque
+ // Called only if this->members_.m_start.m_cur == this->members_.m_start.m_last - 1. Note that
+ // if the deque has at least one element (a precondition for this member
+ // function), and if this->members_.m_start.m_cur == this->members_.m_start.m_last, then the deque
// must have at least two nodes.
void priv_pop_front_aux()
{
@@ -1860,14 +1900,14 @@ class deque : protected deque_base<T, A>
this->priv_deallocate_node(this->members_.m_start.m_first);
this->members_.m_start.priv_set_node(this->members_.m_start.m_node + 1);
this->members_.m_start.m_cur = this->members_.m_start.m_first;
- }
+ }
- iterator priv_reserve_elements_at_front(size_type n)
+ iterator priv_reserve_elements_at_front(size_type n)
{
size_type vacancies = this->members_.m_start.m_cur - this->members_.m_start.m_first;
if (n > vacancies){
size_type new_elems = n-vacancies;
- size_type new_nodes = (new_elems + this->s_buffer_size() - 1) /
+ size_type new_nodes = (new_elems + this->s_buffer_size() - 1) /
this->s_buffer_size();
size_type s = (size_type)(this->members_.m_start.m_node - this->members_.m_map);
if (new_nodes > s){
@@ -1880,7 +1920,7 @@ class deque : protected deque_base<T, A>
}
BOOST_CATCH(...) {
for (size_type j = 1; j < i; ++j)
- this->priv_deallocate_node(*(this->members_.m_start.m_node - j));
+ this->priv_deallocate_node(*(this->members_.m_start.m_node - j));
BOOST_RETHROW
}
BOOST_CATCH_END
@@ -1888,7 +1928,7 @@ class deque : protected deque_base<T, A>
return this->members_.m_start - difference_type(n);
}
- iterator priv_reserve_elements_at_back(size_type n)
+ iterator priv_reserve_elements_at_back(size_type n)
{
size_type vacancies = (this->members_.m_finish.m_last - this->members_.m_finish.m_cur) - 1;
if (n > vacancies){
@@ -1905,7 +1945,7 @@ class deque : protected deque_base<T, A>
}
BOOST_CATCH(...) {
for (size_type j = 1; j < i; ++j)
- this->priv_deallocate_node(*(this->members_.m_finish.m_node + j));
+ this->priv_deallocate_node(*(this->members_.m_finish.m_node + j));
BOOST_RETHROW
}
BOOST_CATCH_END
@@ -1920,7 +1960,7 @@ class deque : protected deque_base<T, A>
index_pointer new_nstart;
if (this->members_.m_map_size > 2 * new_num_nodes) {
- new_nstart = this->members_.m_map + (this->members_.m_map_size - new_num_nodes) / 2
+ new_nstart = this->members_.m_map + (this->members_.m_map_size - new_num_nodes) / 2
+ (add_at_front ? nodes_to_add : 0);
if (new_nstart < this->members_.m_start.m_node)
boost::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
@@ -1929,7 +1969,7 @@ class deque : protected deque_base<T, A>
(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart + old_num_nodes);
}
else {
- size_type new_map_size =
+ size_type new_map_size =
this->members_.m_map_size + container_detail::max_value(this->members_.m_map_size, nodes_to_add) + 2;
index_pointer new_map = this->priv_allocate_map(new_map_size);
@@ -1958,29 +1998,29 @@ inline bool operator==(const deque<T, A>& x,
template <class T, class A>
inline bool operator<(const deque<T, A>& x,
- const deque<T, A>& y)
+ const deque<T, A>& 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)
+ const deque<T, A>& y)
{ return !(x == y); }
template <class T, class A>
inline bool operator>(const deque<T, A>& x,
- const deque<T, A>& y)
+ const deque<T, A>& y)
{ return y < x; }
template <class T, class A>
inline bool operator<=(const deque<T, A>& x,
- const deque<T, A>& y)
+ const deque<T, A>& y)
{ return !(y < x); }
template <class T, class A>
inline bool operator>=(const deque<T, A>& x,
- const deque<T, A>& y)
+ const deque<T, A>& y)
{ return !(x < y); }
diff --git a/boost/container/detail/adaptive_node_pool_impl.hpp b/boost/container/detail/adaptive_node_pool_impl.hpp
index 36495795fb..afba6b5f1b 100644
--- a/boost/container/detail/adaptive_node_pool_impl.hpp
+++ b/boost/container/detail/adaptive_node_pool_impl.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -51,11 +51,11 @@ struct adaptive_pool_types
, bi::optimize_size<true>
, bi::constant_time_size<false>
, bi::link_mode<bi::normal_link> >::type multiset_hook_t;
-
+
typedef hdr_offset_holder_t<SizeType> hdr_offset_holder;
struct block_info_t
- :
+ :
public hdr_offset_holder,
public multiset_hook_t
{
@@ -89,7 +89,7 @@ inline size_type calculate_alignment
const size_type divisor = overhead_percent*real_node_size;
const size_type dividend = hdr_offset_size*100;
size_type elements_per_subblock = (dividend - 1)/divisor + 1;
- size_type candidate_power_of_2 =
+ size_type candidate_power_of_2 =
upper_power_of_2(elements_per_subblock*real_node_size + hdr_offset_size);
bool overhead_satisfied = false;
//Now calculate the wors-case overhead for a subblock
@@ -228,7 +228,7 @@ class private_adaptive_node_pool_impl
{
priv_invariants();
//If there are no free nodes we allocate a new block
- if (m_block_multiset.empty()){
+ if (m_block_multiset.empty()){
priv_alloc_block(1);
}
//We take the first free node the multiset can't be empty
@@ -248,7 +248,7 @@ class private_adaptive_node_pool_impl
priv_invariants();
}
- //!Allocates n nodes.
+ //!Allocates n nodes.
//!Can throw
multiallocation_chain allocate_nodes(const size_type n)
{
@@ -448,7 +448,7 @@ class private_adaptive_node_pool_impl
#undef BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS
{
//We iterate through the block tree to free the memory
- block_iterator it(m_block_multiset.begin()),
+ block_iterator it(m_block_multiset.begin()),
itend(m_block_multiset.end()), to_deallocate;
if(it != itend){
for(++it; it != itend; ++it){
@@ -559,9 +559,9 @@ class private_adaptive_node_pool_impl
++m_totally_free_blocks;
block_info_t *c_info = new(mem_address)block_info_t();
m_block_multiset.insert(m_block_multiset.end(), *c_info);
-
+
mem_address += HdrSize;
- //We initialize all Nodes in Node Block to insert
+ //We initialize all Nodes in Node Block to insert
//them in the free Node list
typename free_nodes_t::iterator prev_insert_pos = c_info->free_nodes.before_begin();
for(size_type i = 0; i < m_real_num_node; ++i){
@@ -605,7 +605,7 @@ class private_adaptive_node_pool_impl
}
{
char *pNode = hdr_addr + HdrSize;
- //We initialize all Nodes in Node Block to insert
+ //We initialize all Nodes in Node Block to insert
//them in the free Node list
for(size_type i = 0; i < hdr_subblock_elements; ++i){
prev_insert_pos = c_info->free_nodes.insert_after(prev_insert_pos, *new (pNode) node_t);
diff --git a/boost/container/detail/advanced_insert_int.hpp b/boost/container/detail/advanced_insert_int.hpp
index 58199c7aa8..a97af282e0 100644
--- a/boost/container/detail/advanced_insert_int.hpp
+++ b/boost/container/detail/advanced_insert_int.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -17,7 +17,9 @@
#include "config_begin.hpp"
#include <boost/container/detail/workaround.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
+#include <boost/container/detail/destroyers.hpp>
+#include <boost/aligned_storage.hpp>
#include <boost/move/move.hpp>
#include <iterator> //std::iterator_traits
#include <boost/assert.hpp>
@@ -41,7 +43,6 @@ template<class A, class FwdIt, class Iterator>
struct advanced_insert_aux_proxy
: public advanced_insert_aux_int<Iterator>
{
- typedef boost::container::allocator_traits<A> alloc_traits;
typedef typename allocator_traits<A>::size_type size_type;
typedef typename allocator_traits<A>::value_type value_type;
typedef typename advanced_insert_aux_int<Iterator>::difference_type difference_type;
@@ -54,36 +55,36 @@ struct advanced_insert_aux_proxy
{}
virtual void copy_remaining_to(Iterator p)
- { ::boost::copy_or_move(first_, last_, p); }
+ { ::boost::copy_or_move(this->first_, this->last_, p); }
virtual void uninitialized_copy_remaining_to(Iterator p)
- { ::boost::container::uninitialized_copy_or_move_alloc(a_, first_, last_, p); }
+ { ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, this->last_, p); }
virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
{
- FwdIt mid = first_;
+ FwdIt mid = this->first_;
std::advance(mid, division_count);
if(first_n){
- ::boost::container::uninitialized_copy_or_move_alloc(a_, first_, mid, pos);
- first_ = mid;
+ ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, mid, pos);
+ this->first_ = mid;
}
else{
- ::boost::container::uninitialized_copy_or_move_alloc(a_, mid, last_, pos);
- last_ = mid;
+ ::boost::container::uninitialized_copy_or_move_alloc(this->a_, mid, this->last_, pos);
+ this->last_ = mid;
}
}
virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
{
- FwdIt mid = first_;
+ FwdIt mid = this->first_;
std::advance(mid, division_count);
if(first_n){
- ::boost::copy_or_move(first_, mid, pos);
- first_ = mid;
+ ::boost::copy_or_move(this->first_, mid, pos);
+ this->first_ = mid;
}
else{
- ::boost::copy_or_move(mid, last_, pos);
- last_ = mid;
+ ::boost::copy_or_move(mid, this->last_, pos);
+ this->last_ = mid;
}
}
A &a_;
@@ -95,7 +96,7 @@ template<class A, class Iterator>
struct default_construct_aux_proxy
: public advanced_insert_aux_int<Iterator>
{
- typedef boost::container::allocator_traits<A> alloc_traits;
+ typedef ::boost::container::allocator_traits<A> alloc_traits;
typedef typename allocator_traits<A>::size_type size_type;
typedef typename allocator_traits<A>::value_type value_type;
typedef typename advanced_insert_aux_int<Iterator>::difference_type difference_type;
@@ -109,11 +110,11 @@ struct default_construct_aux_proxy
virtual void copy_remaining_to(Iterator)
{ //This should never be called with any count
- BOOST_ASSERT(count_ == 0);
+ BOOST_ASSERT(this->count_ == 0);
}
virtual void uninitialized_copy_remaining_to(Iterator p)
- { this->priv_uninitialized_copy(p, count_); }
+ { this->priv_uninitialized_copy(p, this->count_); }
virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
{
@@ -122,22 +123,22 @@ struct default_construct_aux_proxy
new_count = division_count;
}
else{
- BOOST_ASSERT(difference_type(count_)>= division_count);
- new_count = count_ - division_count;
+ BOOST_ASSERT(difference_type(this->count_)>= division_count);
+ new_count = this->count_ - division_count;
}
this->priv_uninitialized_copy(pos, new_count);
}
virtual void copy_some_and_update(Iterator , difference_type division_count, bool first_n)
{
- BOOST_ASSERT(count_ == 0);
+ BOOST_ASSERT(this->count_ == 0);
size_type new_count;
if(first_n){
new_count = division_count;
}
else{
- BOOST_ASSERT(difference_type(count_)>= division_count);
- new_count = count_ - division_count;
+ BOOST_ASSERT(difference_type(this->count_)>= division_count);
+ new_count = this->count_ - division_count;
}
//This function should never called with a count different to zero
BOOST_ASSERT(new_count == 0);
@@ -147,21 +148,21 @@ struct default_construct_aux_proxy
private:
void priv_uninitialized_copy(Iterator p, const size_type n)
{
- BOOST_ASSERT(n <= count_);
+ BOOST_ASSERT(n <= this->count_);
Iterator orig_p = p;
size_type i = 0;
try{
for(; i < n; ++i, ++p){
- alloc_traits::construct(a_, container_detail::to_raw_pointer(&*p));
+ alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p));
}
}
catch(...){
while(i--){
- alloc_traits::destroy(a_, container_detail::to_raw_pointer(&*orig_p++));
+ alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++));
}
throw;
}
- count_ -= n;
+ this->count_ -= n;
}
A &a_;
size_type count_;
@@ -182,7 +183,7 @@ namespace container {
namespace container_detail {
-//This class template will adapt emplace construction insertions of movable types
+//This class template will adapt emplace construction insertions of movable types
//to advanced_insert_aux_int
template<class A, class Iterator, class ...Args>
struct advanced_insert_aux_non_movable_emplace
@@ -223,13 +224,13 @@ struct advanced_insert_aux_non_movable_emplace
{
BOOST_ASSERT(division_count <=1);
if((first_n && division_count == 1) || (!first_n && division_count == 0)){
- if(!used_){
- alloc_traits::construct( a_
+ if(!this->used_){
+ alloc_traits::construct( this->a_
, container_detail::to_raw_pointer(&*p)
, ::boost::container::container_detail::
- stored_ref<Args>::forward(get<IdxPack>(args_))...
+ stored_ref<Args>::forward(get<IdxPack>(this->args_))...
);
- used_ = true;
+ this->used_ = true;
}
}
}
@@ -237,13 +238,13 @@ struct advanced_insert_aux_non_movable_emplace
template<int ...IdxPack>
void priv_uninitialized_copy_remaining_to(const index_tuple<IdxPack...>&, Iterator p)
{
- if(!used_){
- alloc_traits::construct( a_
+ if(!this->used_){
+ alloc_traits::construct( this->a_
, container_detail::to_raw_pointer(&*p)
, ::boost::container::container_detail::
- stored_ref<Args>::forward(get<IdxPack>(args_))...
+ stored_ref<Args>::forward(get<IdxPack>(this->args_))...
);
- used_ = true;
+ this->used_ = true;
}
}
@@ -253,19 +254,20 @@ struct advanced_insert_aux_non_movable_emplace
bool used_;
};
-//This class template will adapt emplace construction insertions of movable types
+//This class template will adapt emplace construction insertions of movable types
//to advanced_insert_aux_int
template<class A, class Iterator, class ...Args>
struct advanced_insert_aux_emplace
: public advanced_insert_aux_non_movable_emplace<A, Iterator, Args...>
{
typedef advanced_insert_aux_non_movable_emplace<A, Iterator, Args...> base_t;
+ typedef boost::container::allocator_traits<A> alloc_traits;
typedef typename base_t::value_type value_type;
typedef typename base_t::difference_type difference_type;
typedef typename base_t::index_tuple_t index_tuple_t;
explicit advanced_insert_aux_emplace(A &a, Args&&... args)
- : base_t(a, boost::forward<Args>(args)...)
+ : base_t(a, ::boost::forward<Args>(args)...)
{}
~advanced_insert_aux_emplace()
@@ -283,8 +285,13 @@ struct advanced_insert_aux_emplace
void priv_copy_remaining_to(const index_tuple<IdxPack...>&, Iterator p)
{
if(!this->used_){
- *p = boost::move(value_type (
- ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...));
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
+ value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));
+ alloc_traits::construct(this->a_, vp,
+ ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...);
+ scoped_destructor<A> d(this->a_, vp);
+ *p = ::boost::move(*vp);
+ d.release();
this->used_ = true;
}
}
@@ -295,8 +302,17 @@ struct advanced_insert_aux_emplace
BOOST_ASSERT(division_count <=1);
if((first_n && division_count == 1) || (!first_n && division_count == 0)){
if(!this->used_){
- *p = boost::move(value_type(
- ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...));
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
+ value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));
+ alloc_traits::construct(this->a_, vp,
+ ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...);
+ try {
+ *p = ::boost::move(*vp);
+ } catch (...) {
+ alloc_traits::destroy(this->a_, vp);
+ throw;
+ }
+ alloc_traits::destroy(this->a_, vp);
this->used_ = true;
}
}
@@ -307,11 +323,11 @@ struct advanced_insert_aux_emplace
#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-#include <boost/container/detail/preprocessor.hpp>
+#include <boost/container/detail/preprocessor.hpp>
#include <boost/container/detail/value_init.hpp>
namespace boost {
-namespace container {
+namespace container {
namespace container_detail {
#define BOOST_PP_LOCAL_MACRO(n) \
@@ -337,13 +353,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), ar
\
virtual void uninitialized_copy_remaining_to(Iterator p) \
{ \
- if(!used_){ \
+ if(!this->used_){ \
alloc_traits::construct \
- ( a_ \
+ ( this->a_ \
, container_detail::to_raw_pointer(&*p) \
BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \
); \
- used_ = true; \
+ this->used_ = true; \
} \
} \
\
@@ -352,13 +368,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), ar
{ \
BOOST_ASSERT(division_count <=1); \
if((first_n && division_count == 1) || (!first_n && division_count == 0)){ \
- if(!used_){ \
+ if(!this->used_){ \
alloc_traits::construct \
- ( a_ \
+ ( this->a_ \
, container_detail::to_raw_pointer(&*p) \
BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \
); \
- used_ = true; \
+ this->used_ = true; \
} \
} \
} \
@@ -382,6 +398,7 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
<A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P) > base_t; \
typedef typename base_t::value_type value_type; \
typedef typename base_t::difference_type difference_type; \
+ typedef boost::container::allocator_traits<A> alloc_traits; \
\
BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \
@@ -391,10 +408,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
virtual void copy_remaining_to(Iterator p) \
{ \
if(!this->used_){ \
- value_type v BOOST_PP_LPAREN_IF(n) \
- BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \
- BOOST_PP_RPAREN_IF(n); \
- *p = boost::move(v); \
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \
+ value_type *vp = static_cast<value_type *>(static_cast<void *>(&v)); \
+ alloc_traits::construct(this->a_, vp \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)); \
+ scoped_destructor<A> d(this->a_, vp); \
+ *p = ::boost::move(*vp); \
+ d.release(); \
this->used_ = true; \
} \
} \
@@ -405,10 +425,13 @@ struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)
BOOST_ASSERT(division_count <=1); \
if((first_n && division_count == 1) || (!first_n && division_count == 0)){ \
if(!this->used_){ \
- value_type v BOOST_PP_LPAREN_IF(n) \
- BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \
- BOOST_PP_RPAREN_IF(n); \
- *p = boost::move(v); \
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \
+ value_type *vp = static_cast<value_type *>(static_cast<void *>(&v)); \
+ alloc_traits::construct(this->a_, vp \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)); \
+ scoped_destructor<A> d(this->a_, vp); \
+ *p = ::boost::move(*vp); \
+ d.release(); \
this->used_ = true; \
} \
} \
diff --git a/boost/container/detail/algorithms.hpp b/boost/container/detail/algorithms.hpp
index a2713f50f1..dc09575b24 100644
--- a/boost/container/detail/algorithms.hpp
+++ b/boost/container/detail/algorithms.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -51,7 +51,7 @@ inline void construct_in_place(A &a, T *dest, emplace_iterator<U, EF, D> ei)
ei.construct_in_place(a, dest);
}
-} //namespace container {
+} //namespace container {
} //namespace boost {
#include <boost/container/detail/config_end.hpp>
diff --git a/boost/container/detail/allocation_type.hpp b/boost/container/detail/allocation_type.hpp
index edad487c57..1ebf20ed70 100644
--- a/boost/container/detail/allocation_type.hpp
+++ b/boost/container/detail/allocation_type.hpp
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -23,7 +23,7 @@ namespace container {
/// @cond
enum allocation_type_v
-{
+{
// constants for allocation commands
allocate_new_v = 0x01,
expand_fwd_v = 0x02,
diff --git a/boost/container/detail/config_begin.hpp b/boost/container/detail/config_begin.hpp
index bd44daacfe..83c2cfe40c 100644
--- a/boost/container/detail/config_begin.hpp
+++ b/boost/container/detail/config_begin.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -45,4 +45,5 @@
// with /GR-; unpredictable behavior may result
#pragma warning (disable : 4673) // throwing '' the following types will not be considered at the catch site
#pragma warning (disable : 4671) // the copy constructor is inaccessible
+ #pragma warning (disable : 4584) // X is already a base-class of Y
#endif //BOOST_MSVC
diff --git a/boost/container/detail/config_end.hpp b/boost/container/detail/config_end.hpp
index b71fabcdae..34513718cc 100644
--- a/boost/container/detail/config_end.hpp
+++ b/boost/container/detail/config_end.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
diff --git a/boost/container/detail/destroyers.hpp b/boost/container/detail/destroyers.hpp
index 26ae089aa6..d1b118cdcc 100644
--- a/boost/container/detail/destroyers.hpp
+++ b/boost/container/detail/destroyers.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -21,10 +21,10 @@
#include <boost/container/detail/workaround.hpp>
#include <boost/container/detail/version_type.hpp>
#include <boost/container/detail/utilities.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
namespace boost {
-namespace container {
+namespace container {
namespace container_detail {
//!A deleter for scoped_ptr that deallocates the memory
@@ -65,6 +65,44 @@ struct null_scoped_array_deallocator
{}
};
+template <class Allocator>
+struct scoped_destroy_deallocator
+{
+ typedef boost::container::allocator_traits<Allocator> AllocTraits;
+ typedef typename AllocTraits::pointer pointer;
+ typedef typename AllocTraits::size_type size_type;
+ typedef container_detail::integral_constant<unsigned,
+ boost::container::container_detail::
+ version<Allocator>::value> alloc_version;
+ typedef container_detail::integral_constant<unsigned, 1> allocator_v1;
+ typedef container_detail::integral_constant<unsigned, 2> allocator_v2;
+
+ scoped_destroy_deallocator(pointer p, Allocator& a)
+ : m_ptr(p), m_alloc(a) {}
+
+ ~scoped_destroy_deallocator()
+ {
+ if(m_ptr){
+ AllocTraits::destroy(m_alloc, container_detail::to_raw_pointer(m_ptr));
+ priv_deallocate(m_ptr, alloc_version());
+ }
+ }
+
+ void release()
+ { m_ptr = 0; }
+
+ private:
+
+ void priv_deallocate(const pointer &p, allocator_v1)
+ { AllocTraits::deallocate(m_alloc, p, 1); }
+
+ void priv_deallocate(const pointer &p, allocator_v2)
+ { m_alloc.deallocate_one(p); }
+
+ pointer m_ptr;
+ Allocator& m_alloc;
+};
+
//!A deleter for scoped_ptr that destroys
//!an object using a STL allocator.
@@ -85,7 +123,10 @@ struct scoped_destructor_n
void increment_size(size_type inc)
{ m_n += inc; }
-
+
+ void increment_size_backwards(size_type inc)
+ { m_n += inc; m_p -= inc; }
+
~scoped_destructor_n()
{
if(!m_p) return;
@@ -115,8 +156,57 @@ struct null_scoped_destructor_n
void increment_size(size_type)
{}
+ void increment_size_backwards(size_type)
+ {}
+
+ void release()
+ {}
+};
+
+template<class A>
+class scoped_destructor
+{
+ typedef boost::container::allocator_traits<A> AllocTraits;
+ public:
+ typedef typename A::value_type value_type;
+ scoped_destructor(A &a, value_type *pv)
+ : pv_(pv), a_(a)
+ {}
+
+ ~scoped_destructor()
+ {
+ if(pv_){
+ AllocTraits::destroy(a_, pv_);
+ }
+ }
+
void release()
+ { pv_ = 0; }
+
+ private:
+ value_type *pv_;
+ A &a_;
+};
+
+
+template<class A>
+class value_destructor
+{
+ typedef boost::container::allocator_traits<A> AllocTraits;
+ public:
+ typedef typename A::value_type value_type;
+ value_destructor(A &a, value_type &rv)
+ : rv_(rv), a_(a)
{}
+
+ ~value_destructor()
+ {
+ AllocTraits::destroy(a_, &rv_);
+ }
+
+ private:
+ value_type &rv_;
+ A &a_;
};
template <class Allocator>
@@ -154,8 +244,8 @@ class allocator_destroyer
};
-} //namespace container_detail {
-} //namespace container {
+} //namespace container_detail {
+} //namespace container {
} //namespace boost {
#include <boost/container/detail/config_end.hpp>
diff --git a/boost/container/detail/flat_tree.hpp b/boost/container/detail/flat_tree.hpp
index 44438386a3..23be0bfd13 100644
--- a/boost/container/detail/flat_tree.hpp
+++ b/boost/container/detail/flat_tree.hpp
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -32,6 +32,8 @@
#include <boost/container/vector.hpp>
#include <boost/container/detail/value_init.hpp>
#include <boost/container/detail/destroyers.hpp>
+#include <boost/container/allocator_traits.hpp>
+#include <boost/aligned_storage.hpp>
namespace boost {
@@ -46,24 +48,24 @@ class flat_tree_value_compare
typedef Value first_argument_type;
typedef Value second_argument_type;
typedef bool return_type;
- public:
+ public:
flat_tree_value_compare()
: Compare()
{}
- flat_tree_value_compare(const Compare &pred)
+ flat_tree_value_compare(const Compare &pred)
: Compare(pred)
{}
bool operator()(const Value& lhs, const Value& rhs) const
- {
+ {
KeyOfValue key_extract;
- return Compare::operator()(key_extract(lhs), key_extract(rhs));
+ return Compare::operator()(key_extract(lhs), key_extract(rhs));
}
const Compare &get_comp() const
{ return *this; }
-
+
Compare &get_comp()
{ return *this; }
};
@@ -79,7 +81,7 @@ struct get_flat_tree_iterators
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
};
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
class flat_tree
{
@@ -90,7 +92,7 @@ class flat_tree
typedef flat_tree_value_compare<Compare, Value, KeyOfValue> value_compare;
private:
- struct Data
+ struct Data
//Inherit from value_compare to do EBO
: public value_compare
{
@@ -102,19 +104,27 @@ class flat_tree
{}
Data(const Data &d)
- : value_compare(d), m_vect(d.m_vect)
+ : value_compare(static_cast<const value_compare&>(d)), m_vect(d.m_vect)
{}
Data(BOOST_RV_REF(Data) d)
- : value_compare(boost::move(d)), m_vect(boost::move(d.m_vect))
+ : value_compare(boost::move(static_cast<value_compare&>(d))), m_vect(boost::move(d.m_vect))
+ {}
+
+ Data(const Data &d, const A &a)
+ : value_compare(static_cast<const value_compare&>(d)), m_vect(d.m_vect, a)
{}
- Data(const Compare &comp)
+ Data(BOOST_RV_REF(Data) d, const A &a)
+ : value_compare(boost::move(static_cast<value_compare&>(d))), m_vect(boost::move(d.m_vect), a)
+ {}
+
+ Data(const Compare &comp)
: value_compare(comp), m_vect()
{}
Data(const Compare &comp,
- const allocator_t &alloc)
+ const allocator_t &alloc)
: value_compare(comp), m_vect(alloc)
{}
@@ -165,6 +175,10 @@ class flat_tree
//!Standard extension
typedef allocator_type stored_allocator_type;
+ private:
+ typedef allocator_traits<stored_allocator_type> stored_allocator_traits;
+
+ public:
flat_tree()
: m_data()
{ }
@@ -177,7 +191,7 @@ class flat_tree
: m_data(comp, a)
{ }
- flat_tree(const flat_tree& x)
+ flat_tree(const flat_tree& x)
: m_data(x.m_data)
{ }
@@ -185,6 +199,14 @@ class flat_tree
: m_data(boost::move(x.m_data))
{ }
+ flat_tree(const flat_tree& x, const allocator_type &a)
+ : m_data(x.m_data, a)
+ { }
+
+ flat_tree(BOOST_RV_REF(flat_tree) x, const allocator_type &a)
+ : m_data(boost::move(x.m_data), a)
+ { }
+
template <class InputIterator>
flat_tree( ordered_range_t, InputIterator first, InputIterator last
, const Compare& comp = Compare()
@@ -201,66 +223,66 @@ class flat_tree
flat_tree& operator=(BOOST_RV_REF(flat_tree) mx)
{ m_data = boost::move(mx.m_data); return *this; }
- public:
+ public:
// accessors:
- Compare key_comp() const
+ Compare key_comp() const
{ return this->m_data.get_comp(); }
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return this->m_data.m_vect.get_allocator(); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return this->m_data.m_vect.get_stored_allocator(); }
stored_allocator_type &get_stored_allocator()
{ return this->m_data.m_vect.get_stored_allocator(); }
- iterator begin()
+ iterator begin()
{ return this->m_data.m_vect.begin(); }
- const_iterator begin() const
+ const_iterator begin() const
{ return this->cbegin(); }
- const_iterator cbegin() const
+ const_iterator cbegin() const
{ return this->m_data.m_vect.begin(); }
- iterator end()
+ iterator end()
{ return this->m_data.m_vect.end(); }
- const_iterator end() const
+ const_iterator end() const
{ return this->cend(); }
- const_iterator cend() const
+ const_iterator cend() const
{ return this->m_data.m_vect.end(); }
- reverse_iterator rbegin()
+ reverse_iterator rbegin()
{ return reverse_iterator(this->end()); }
- const_reverse_iterator rbegin() const
+ const_reverse_iterator rbegin() const
{ return this->crbegin(); }
- const_reverse_iterator crbegin() const
+ const_reverse_iterator crbegin() const
{ return const_reverse_iterator(this->cend()); }
- reverse_iterator rend()
+ reverse_iterator rend()
{ return reverse_iterator(this->begin()); }
- const_reverse_iterator rend() const
- { return this->crend(); }
+ const_reverse_iterator rend() const
+ { return this->crend(); }
- const_reverse_iterator crend() const
- { return const_reverse_iterator(this->cbegin()); }
+ const_reverse_iterator crend() const
+ { return const_reverse_iterator(this->cbegin()); }
- bool empty() const
+ bool empty() const
{ return this->m_data.m_vect.empty(); }
- size_type size() const
+ size_type size() const
{ return this->m_data.m_vect.size(); }
- size_type max_size() const
+ size_type max_size() const
{ return this->m_data.m_vect.max_size(); }
- void swap(flat_tree& other)
+ void swap(flat_tree& other)
{ this->m_data.swap(other.m_data); }
public:
@@ -285,7 +307,6 @@ class flat_tree
return ret;
}
-
iterator insert_equal(const value_type& val)
{
iterator i = this->upper_bound(KeyOfValue()(val));
@@ -323,14 +344,14 @@ class flat_tree
iterator insert_equal(const_iterator pos, const value_type& val)
{
insert_commit_data data;
- priv_insert_equal_prepare(pos, val, data);
+ this->priv_insert_equal_prepare(pos, val, data);
return priv_insert_commit(data, val);
}
iterator insert_equal(const_iterator pos, BOOST_RV_REF(value_type) mval)
{
insert_commit_data data;
- priv_insert_equal_prepare(pos, mval, data);
+ this->priv_insert_equal_prepare(pos, mval, data);
return priv_insert_commit(data, boost::move(mval));
}
@@ -344,9 +365,25 @@ class flat_tree
template <class InIt>
void insert_equal(InIt first, InIt last)
{
- typedef typename
+ typedef typename
std::iterator_traits<InIt>::iterator_category ItCat;
- priv_insert_equal(first, last, ItCat());
+ this->priv_insert_equal(first, last, ItCat());
+ }
+
+ template <class InIt>
+ void insert_equal(ordered_range_t, InIt first, InIt last)
+ {
+ typedef typename
+ std::iterator_traits<InIt>::iterator_category ItCat;
+ this->priv_insert_equal(ordered_range_t(), first, last, ItCat());
+ }
+
+ template <class InIt>
+ void insert_unique(ordered_unique_range_t, InIt first, InIt last)
+ {
+ typedef typename
+ std::iterator_traits<InIt>::iterator_category ItCat;
+ this->priv_insert_unique(ordered_unique_range_t(), first, last, ItCat());
}
#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -354,7 +391,11 @@ class flat_tree
template <class... Args>
std::pair<iterator, bool> emplace_unique(Args&&... args)
{
- value_type && val = value_type(boost::forward<Args>(args)...);
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
+ stored_allocator_type &a = this->get_stored_allocator();
+ stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type> d(a, val);
insert_commit_data data;
std::pair<iterator,bool> ret =
priv_insert_unique_prepare(val, data);
@@ -367,7 +408,11 @@ class flat_tree
template <class... Args>
iterator emplace_hint_unique(const_iterator hint, Args&&... args)
{
- value_type && val = value_type(boost::forward<Args>(args)...);
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
+ stored_allocator_type &a = this->get_stored_allocator();
+ stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type> d(a, val);
insert_commit_data data;
std::pair<iterator,bool> ret = priv_insert_unique_prepare(hint, val, data);
if(ret.second){
@@ -379,7 +424,11 @@ class flat_tree
template <class... Args>
iterator emplace_equal(Args&&... args)
{
- value_type &&val = value_type(boost::forward<Args>(args)...);
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
+ stored_allocator_type &a = this->get_stored_allocator();
+ stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type> d(a, val);
iterator i = this->upper_bound(KeyOfValue()(val));
i = this->m_data.m_vect.insert(i, boost::move(val));
return i;
@@ -388,10 +437,15 @@ class flat_tree
template <class... Args>
iterator emplace_hint_equal(const_iterator hint, Args&&... args)
{
- value_type &&val = value_type(boost::forward<Args>(args)...);
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
+ stored_allocator_type &a = this->get_stored_allocator();
+ stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type> d(a, val);
insert_commit_data data;
- priv_insert_equal_prepare(hint, val, data);
- return priv_insert_commit(data, boost::move(val));
+ this->priv_insert_equal_prepare(hint, val, data);
+ iterator i = priv_insert_commit(data, boost::move(val));
+ return i;
}
#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -401,10 +455,12 @@ class flat_tree
std::pair<iterator, bool> \
emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
{ \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \
- BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \
- value_type &val = vval; \
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \
+ stored_allocator_type &a = this->get_stored_allocator(); \
+ stored_allocator_traits::construct(a, &val \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \
+ value_destructor<stored_allocator_type> d(a, val); \
insert_commit_data data; \
std::pair<iterator,bool> ret = priv_insert_unique_prepare(val, data); \
if(ret.second){ \
@@ -417,10 +473,12 @@ class flat_tree
iterator emplace_hint_unique(const_iterator hint \
BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
{ \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \
- BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \
- value_type &val = vval; \
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \
+ stored_allocator_type &a = this->get_stored_allocator(); \
+ stored_allocator_traits::construct(a, &val \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \
+ value_destructor<stored_allocator_type> d(a, val); \
insert_commit_data data; \
std::pair<iterator,bool> ret = priv_insert_unique_prepare(hint, val, data); \
if(ret.second){ \
@@ -432,10 +490,12 @@ class flat_tree
BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
{ \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \
- BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \
- value_type &val = vval; \
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \
+ stored_allocator_type &a = this->get_stored_allocator(); \
+ stored_allocator_traits::construct(a, &val \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \
+ value_destructor<stored_allocator_type> d(a, val); \
iterator i = this->upper_bound(KeyOfValue()(val)); \
i = this->m_data.m_vect.insert(i, boost::move(val)); \
return i; \
@@ -445,14 +505,18 @@ class flat_tree
iterator emplace_hint_equal(const_iterator hint \
BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
{ \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), container_detail::value_init<) value_type \
- BOOST_PP_EXPR_IF(BOOST_PP_NOT(n), >) vval BOOST_PP_LPAREN_IF(n) \
- BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) BOOST_PP_RPAREN_IF(n); \
- value_type &val = vval; \
+ aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \
+ value_type &val = *static_cast<value_type *>(static_cast<void *>(&v)); \
+ stored_allocator_type &a = this->get_stored_allocator(); \
+ stored_allocator_traits::construct(a, &val \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \
+ value_destructor<stored_allocator_type> d(a, val); \
insert_commit_data data; \
- priv_insert_equal_prepare(hint, val, data); \
- return priv_insert_commit(data, boost::move(val)); \
+ this->priv_insert_equal_prepare(hint, val, data); \
+ iterator i = priv_insert_commit(data, boost::move(val)); \
+ return i; \
} \
+
//!
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
#include BOOST_PP_LOCAL_ITERATE()
@@ -493,8 +557,8 @@ class flat_tree
const Compare &key_comp = this->m_data.get_comp();
iterator i = this->lower_bound(k);
- if (i != this->end() && key_comp(k, KeyOfValue()(*i))){
- i = this->end();
+ if (i != this->end() && key_comp(k, KeyOfValue()(*i))){
+ i = this->end();
}
return i;
}
@@ -504,8 +568,8 @@ class flat_tree
const Compare &key_comp = this->m_data.get_comp();
const_iterator i = this->lower_bound(k);
- if (i != this->end() && key_comp(k, KeyOfValue()(*i))){
- i = this->end();
+ if (i != this->end() && key_comp(k, KeyOfValue()(*i))){
+ i = this->end();
}
return i;
}
@@ -535,10 +599,10 @@ class flat_tree
std::pair<const_iterator, const_iterator> equal_range(const key_type& k) const
{ return this->priv_equal_range(this->begin(), this->end(), k); }
- size_type capacity() const
+ size_type capacity() const
{ return this->m_data.m_vect.capacity(); }
- void reserve(size_type count)
+ void reserve(size_type count)
{ this->m_data.m_vect.reserve(count); }
private:
@@ -567,12 +631,12 @@ class flat_tree
data.position = pos;
}
else{
- data.position =
+ data.position =
this->priv_upper_bound(this->cbegin(), pos, KeyOfValue()(val));
}
}
else{
- data.position =
+ data.position =
this->priv_lower_bound(pos, this->cend(), KeyOfValue()(val));
}
}
@@ -692,7 +756,7 @@ class flat_tree
}
else{
first = ++middle;
- len = len - half - 1;
+ len = len - half - 1;
}
}
return first;
@@ -730,14 +794,97 @@ class flat_tree
return std::pair<RanIt, RanIt>(first, first);
}
- template <class FwdIt>
- void priv_insert_equal(FwdIt first, FwdIt last, std::forward_iterator_tag)
+ template <class BidirIt>
+ void priv_insert_equal(ordered_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
{
size_type len = static_cast<size_type>(std::distance(first, last));
+ const size_type BurstSize = 16;
+ size_type positions[BurstSize];
+
+ //Prereserve all memory so that iterators are not invalidated
this->reserve(this->size()+len);
- this->priv_insert_equal(first, last, std::input_iterator_tag());
+ const const_iterator beg(this->cbegin());
+ const_iterator pos(beg);
+ //Loop in burst sizes
+ while(len){
+ const size_type burst = len < BurstSize ? len : BurstSize;
+ const const_iterator cend(this->cend());
+ len -= burst;
+ for(size_type i = 0; i != burst; ++i){
+ //Get the insertion position for each key
+ pos = const_cast<const flat_tree&>(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
+ positions[i] = static_cast<size_type>(pos - beg);
+ ++first;
+ }
+ //Insert all in a single step in the precalculated positions
+ this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
+ //Next search position updated
+ pos += burst;
+ }
}
+ template <class BidirIt>
+ void priv_insert_unique(ordered_unique_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
+ {
+ size_type len = static_cast<size_type>(std::distance(first, last));
+ const size_type BurstSize = 16;
+ size_type positions[BurstSize];
+ size_type skips[BurstSize];
+
+ //Prereserve all memory so that iterators are not invalidated
+ this->reserve(this->size()+len);
+ const const_iterator beg(this->cbegin());
+ const_iterator pos(beg);
+ const value_compare &value_comp = this->m_data;
+ //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());
+ while(unique_burst < burst && len > 0){
+ //Get the insertion position for each key
+ const value_type & val = *first++;
+ --len;
+ pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
+ //Check if already present
+ if(pos != cend && !value_comp(*pos, val)){
+ ++skips[unique_burst];
+ continue;
+ }
+
+ //If not present, calculate position
+ positions[unique_burst] = static_cast<size_type>(pos - beg);
+ if(++unique_burst < burst)
+ skips[unique_burst] = 0u;
+ }
+ //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;
+ }
+ }
+/*
+ template <class FwdIt>
+ void priv_insert_equal_forward(ordered_range_t, FwdIt first, FwdIt last, std::forward_iterator_tag)
+ { this->priv_insert_equal(first, last, std::forward_iterator_tag()); }
+*/
+ template <class InIt>
+ void priv_insert_equal(ordered_range_t, InIt first, InIt last, std::input_iterator_tag)
+ { this->priv_insert_equal(first, last, std::input_iterator_tag()); }
+
+ template <class InIt>
+ void priv_insert_unique(ordered_unique_range_t, InIt first, InIt last, std::input_iterator_tag)
+ { this->priv_insert_unique(first, last, std::input_iterator_tag()); }
+/*
+ template <class FwdIt>
+ void priv_insert_equal_forward(FwdIt first, FwdIt last, std::forward_iterator_tag)
+ {
+ const size_type len = static_cast<size_type>(std::distance(first, last));
+ this->reserve(this->size()+len);
+ this->priv_insert_equal(first, last, std::input_iterator_tag());
+ }
+*/
template <class InIt>
void priv_insert_equal(InIt first, InIt last, std::input_iterator_tag)
{
@@ -746,59 +893,59 @@ class flat_tree
}
};
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
-inline bool
-operator==(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
+inline bool
+operator==(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
{
return x.size() == y.size() &&
std::equal(x.begin(), x.end(), y.begin());
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
-inline bool
-operator<(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
+inline bool
+operator<(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
{
- return std::lexicographical_compare(x.begin(), x.end(),
+ return std::lexicographical_compare(x.begin(), x.end(),
y.begin(), y.end());
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
-inline bool
-operator!=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
- const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
+inline bool
+operator!=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
+ const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
{ return !(x == y); }
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
-inline bool
-operator>(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
- const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
+inline bool
+operator>(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
+ const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
{ return y < x; }
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
-inline bool
-operator<=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
- const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
+inline bool
+operator<=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
+ const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
{ return !(y < x); }
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
-inline bool
-operator>=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
- const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
+inline bool
+operator>=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
+ const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
{ return !(x < y); }
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class Compare, class A>
-inline void
-swap(flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
+inline void
+swap(flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
{ x.swap(y); }
@@ -808,7 +955,7 @@ swap(flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class K, class V, class KOV,
+template <class K, class V, class KOV,
class C, class A>
struct has_trivial_destructor_after_move<boost::container::container_detail::flat_tree<K, V, KOV, C, A> >
{
diff --git a/boost/container/detail/function_detector.hpp b/boost/container/detail/function_detector.hpp
index c37c766844..5a5f6fd77d 100644
--- a/boost/container/detail/function_detector.hpp
+++ b/boost/container/detail/function_detector.hpp
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2009-2011.
+// (C) Copyright Ion Gaztanaga 2009-2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -15,7 +15,7 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright 2007 Alexandre Courpron
//
-// Permission to use, copy, modify, redistribute and sell this software,
+// Permission to use, copy, modify, redistribute and sell this software,
// provided that this copyright notice appears on all copies of the software.
///////////////////////////////////////////////////////////////////////////////
@@ -74,7 +74,7 @@ namespace function_detector {
public : \
static const int check = NotFound + (sizeof(Test<T>(0, 0)) - sizeof(NotFoundType));\
};\
-}}} //namespace boost::container::function_detector {
+}}} //namespace boost::container::function_detector {
#define BOOST_CONTAINER_DETECT_FUNCTION(Class, InstantiationKey, ReturnType, Identifier, Params) \
::boost::container::function_detector::DetectMember_##InstantiationKey_##Identifier< Class,\
diff --git a/boost/container/detail/iterators.hpp b/boost/container/detail/iterators.hpp
index 899cbe4349..374b55c836 100644
--- a/boost/container/detail/iterators.hpp
+++ b/boost/container/detail/iterators.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
// (C) Copyright Gennaro Prota 2003 - 2004.
//
// Distributed under the Boost Software License, Version 1.0.
@@ -21,7 +21,7 @@
#include "config_begin.hpp"
#include <boost/container/detail/workaround.hpp>
#include <boost/move/move.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
#include <boost/container/detail/variadic_templates_tools.hpp>
@@ -33,7 +33,7 @@
#include <iterator>
namespace boost {
-namespace container {
+namespace container {
template <class T, class Difference = std::ptrdiff_t>
class constant_iterator
@@ -50,9 +50,9 @@ class constant_iterator
constant_iterator()
: m_ptr(0), m_num(0){}
- constant_iterator& operator++()
+ constant_iterator& operator++()
{ increment(); return *this; }
-
+
constant_iterator operator++(int)
{
constant_iterator result (*this);
@@ -60,9 +60,9 @@ class constant_iterator
return result;
}
- constant_iterator& operator--()
+ constant_iterator& operator--()
{ decrement(); return *this; }
-
+
constant_iterator operator--(int)
{
constant_iterator result (*this);
@@ -161,9 +161,9 @@ class default_construct_iterator
default_construct_iterator()
: m_num(0){}
- default_construct_iterator& operator++()
+ default_construct_iterator& operator++()
{ increment(); return *this; }
-
+
default_construct_iterator operator++(int)
{
default_construct_iterator result (*this);
@@ -171,9 +171,9 @@ class default_construct_iterator
return result;
}
- default_construct_iterator& operator--()
+ default_construct_iterator& operator--()
{ decrement(); return *this; }
-
+
default_construct_iterator operator--(int)
{
default_construct_iterator result (*this);
@@ -247,7 +247,7 @@ class default_construct_iterator
{ return other.m_num < m_num; }
const T & dereference() const
- {
+ {
static T dummy;
return dummy;
}
@@ -273,9 +273,9 @@ class repeat_iterator
repeat_iterator()
: m_ptr(0), m_num(0){}
- this_type& operator++()
+ this_type& operator++()
{ increment(); return *this; }
-
+
this_type operator++(int)
{
this_type result (*this);
@@ -283,9 +283,9 @@ class repeat_iterator
return result;
}
- this_type& operator--()
+ this_type& operator--()
{ increment(); return *this; }
-
+
this_type operator--(int)
{
this_type result (*this);
@@ -384,9 +384,9 @@ class emplace_iterator
emplace_iterator()
: m_num(0), m_pe(0){}
- this_type& operator++()
+ this_type& operator++()
{ increment(); return *this; }
-
+
this_type operator++(int)
{
this_type result (*this);
@@ -394,9 +394,9 @@ class emplace_iterator
return result;
}
- this_type& operator--()
+ this_type& operator--()
{ decrement(); return *this; }
-
+
this_type operator--(int)
{
this_type result (*this);
@@ -475,7 +475,7 @@ class emplace_iterator
{ return other.m_num < m_num; }
const T & dereference() const
- {
+ {
static T dummy;
return dummy;
}
@@ -513,7 +513,7 @@ struct emplace_functor
container_detail::tuple<Args&...> args_;
};
-#else
+#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
#define BOOST_PP_LOCAL_MACRO(n) \
BOOST_PP_EXPR_IF(n, template <) \
@@ -522,16 +522,16 @@ struct emplace_functor
struct BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \
{ \
BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \
- ( BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \
- BOOST_PP_EXPR_IF(n, :) BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_INIT, _){} \
+ ( BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \
+ BOOST_PP_EXPR_IF(n, :) BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_INIT, _){} \
\
template<class A, class T> \
void operator()(A &a, T *ptr) \
{ \
allocator_traits<A>::construct \
- (a, ptr BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) );\
+ (a, ptr BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) ); \
} \
- BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \
+ BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \
}; \
//!
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
@@ -539,7 +539,7 @@ struct emplace_functor
#endif
-} //namespace container {
+} //namespace container {
} //namespace boost {
#include <boost/container/detail/config_end.hpp>
diff --git a/boost/container/detail/math_functions.hpp b/boost/container/detail/math_functions.hpp
index 4613573d48..fe8386be69 100644
--- a/boost/container/detail/math_functions.hpp
+++ b/boost/container/detail/math_functions.hpp
@@ -1,10 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Stephen Cleary 2000.
-// (C) Copyright Ion Gaztanaga 2007-2011.
+// (C) Copyright Ion Gaztanaga 2007-2012.
//
// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
+// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/container for documentation.
@@ -94,7 +94,7 @@ inline std::size_t floor_log2 (std::size_t x)
std::size_t n = x;
std::size_t log2 = 0;
-
+
for(std::size_t shift = Bits >> 1; shift; shift >>= 1){
std::size_t tmp = n >> shift;
if (tmp)
diff --git a/boost/container/allocator/memory_util.hpp b/boost/container/detail/memory_util.hpp
index ea4bc05548..c00172c60c 100644
--- a/boost/container/allocator/memory_util.hpp
+++ b/boost/container/detail/memory_util.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2011-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
diff --git a/boost/container/detail/mpl.hpp b/boost/container/detail/mpl.hpp
index c2d0ce41bb..74a1ce0e67 100644
--- a/boost/container/detail/mpl.hpp
+++ b/boost/container/detail/mpl.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -20,7 +20,7 @@
#include <cstddef>
namespace boost {
-namespace container {
+namespace container {
namespace container_detail {
template <class T, T val>
@@ -109,24 +109,24 @@ struct if_
template <class Pair>
-struct select1st
-// : public std::unary_function<Pair, typename Pair::first_type>
+struct select1st
+// : public std::unary_function<Pair, typename Pair::first_type>
{
template<class OtherPair>
- const typename Pair::first_type& operator()(const OtherPair& x) const
+ const typename Pair::first_type& operator()(const OtherPair& x) const
{ return x.first; }
- const typename Pair::first_type& operator()(const typename Pair::first_type& x) const
+ const typename Pair::first_type& operator()(const typename Pair::first_type& x) const
{ return x; }
};
// identity is an extension: it is not part of the standard.
template <class T>
-struct identity
-// : public std::unary_function<T,T>
+struct identity
+// : public std::unary_function<T,T>
{
typedef T type;
- const T& operator()(const T& x) const
+ const T& operator()(const T& x) const
{ return x; }
};
@@ -152,8 +152,8 @@ template <typename T> struct unvoid { typedef T type; };
template <> struct unvoid<void> { struct type { }; };
template <> struct unvoid<const void> { struct type { }; };
-} //namespace container_detail {
-} //namespace container {
+} //namespace container_detail {
+} //namespace container {
} //namespace boost {
#endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP
diff --git a/boost/container/detail/multiallocation_chain.hpp b/boost/container/detail/multiallocation_chain.hpp
index a67fd770bd..c9952535eb 100644
--- a/boost/container/detail/multiallocation_chain.hpp
+++ b/boost/container/detail/multiallocation_chain.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
diff --git a/boost/container/detail/node_alloc_holder.hpp b/boost/container/detail/node_alloc_holder.hpp
index 9b0a0a524b..9797f1fbd5 100644
--- a/boost/container/detail/node_alloc_holder.hpp
+++ b/boost/container/detail/node_alloc_holder.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -27,7 +27,7 @@
#include <boost/container/detail/version_type.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/container/detail/utilities.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/destroyers.hpp>
@@ -36,6 +36,7 @@
#endif
#include <boost/container/detail/algorithms.hpp>
+#include <new>
namespace boost {
@@ -188,11 +189,11 @@ struct node_alloc_holder
public:
//Constructors for sequence containers
- node_alloc_holder()
+ node_alloc_holder()
: members_()
{}
- explicit node_alloc_holder(const ValAlloc &a)
+ explicit node_alloc_holder(const ValAlloc &a)
: members_(a)
{}
@@ -205,7 +206,7 @@ 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 Pred &c)
: members_(a, c)
{}
@@ -223,7 +224,7 @@ struct node_alloc_holder
{ this->icont().swap(x.icont()); }
void copy_assign_alloc(const node_alloc_holder &x)
- {
+ {
container_detail::bool_<allocator_traits_type::propagate_on_container_copy_assignment::value> flag;
container_detail::assign_alloc( static_cast<NodeAlloc &>(this->members_)
, static_cast<const NodeAlloc &>(x.members_), flag);
@@ -259,47 +260,21 @@ struct node_alloc_holder
void deallocate_one(const NodePtr &p, allocator_v2)
{ this->node_alloc().deallocate_one(p); }
-/*
- template<class A, class Convertible1, class Convertible2>
- static void construct(A &a, const NodePtr &ptr,
- BOOST_RV_REF_2_TEMPL_ARGS(std::pair, Convertible1, Convertible2) value)
- {
- typedef typename Node::hook_type hook_type;
- typedef typename Node::value_type::first_type first_type;
- typedef typename Node::value_type::second_type second_type;
- Node *nodeptr = container_detail::to_raw_pointer(ptr);
-
- //Hook constructor does not throw
- allocator_traits<A>::construct(a, static_cast<hook_type*>(nodeptr));
-
- //Now construct pair members_holder
- value_type *valueptr = &nodeptr->get_data();
- allocator_traits<A>::construct(a, &valueptr->first, boost::move(value.first));
- BOOST_TRY{
- allocator_traits<A>::construct(a, &valueptr->second, boost::move(value.second));
- }
- BOOST_CATCH(...){
- allocator_traits<A>::destroy(a, &valueptr->first);
- BOOST_RETHROW
- }
- BOOST_CATCH_END
- }
-*/
+
#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-/*
- template<class A, class ...Args>
- static void construct(A &a, const NodePtr &ptr, Args &&...args)
- {
- }
-*/
+
template<class ...Args>
NodePtr create_node(Args &&...args)
{
NodePtr p = this->allocate_one();
Deallocator node_deallocator(p, this->node_alloc());
allocator_traits<NodeAlloc>::construct
- (this->node_alloc(), container_detail::to_raw_pointer(p), boost::forward<Args>(args)...);
+ ( this->node_alloc()
+ , container_detail::addressof(p->m_data), boost::forward<Args>(args)...);
node_deallocator.release();
+ //This does not throw
+ typedef typename Node::hook_type hook_type;
+ ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p))) hook_type;
return (p);
}
@@ -313,9 +288,11 @@ struct node_alloc_holder
NodePtr p = this->allocate_one(); \
Deallocator node_deallocator(p, this->node_alloc()); \
allocator_traits<NodeAlloc>::construct \
- (this->node_alloc(), container_detail::to_raw_pointer(p) \
+ (this->node_alloc(), container_detail::addressof(p->m_data) \
BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
node_deallocator.release(); \
+ typedef typename Node::hook_type hook_type; \
+ ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p))) hook_type; \
return (p); \
} \
//!
@@ -329,8 +306,11 @@ struct node_alloc_holder
{
NodePtr p = this->allocate_one();
Deallocator node_deallocator(p, this->node_alloc());
- ::boost::container::construct_in_place(this->node_alloc(), container_detail::to_raw_pointer(p), it);
+ ::boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), it);
node_deallocator.release();
+ //This does not throw
+ typedef typename Node::hook_type hook_type;
+ ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p))) hook_type;
return (p);
}
@@ -364,8 +344,11 @@ struct node_alloc_holder
mem.pop_front();
//This can throw
constructed = 0;
- boost::container::construct_in_place(this->node_alloc(), p, beg);
+ boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), beg);
++constructed;
+ //This does not throw
+ typedef typename Node::hook_type hook_type;
+ ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p))) hook_type;
//This can throw in some containers (predicate might throw)
inserter(*p);
}
diff --git a/boost/container/detail/node_pool_impl.hpp b/boost/container/detail/node_pool_impl.hpp
index 9ee9e311c0..63c1278238 100644
--- a/boost/container/detail/node_pool_impl.hpp
+++ b/boost/container/detail/node_pool_impl.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -86,12 +86,12 @@ class private_node_pool_impl
void *allocate_node()
{ return priv_alloc_node(); }
-
+
//!Deallocates an array pointed by ptr. Never throws
void deallocate_node(void *ptr)
{ priv_dealloc_node(ptr); }
- //!Allocates a singly linked list of n nodes ending in null pointer.
+ //!Allocates a singly linked list of n nodes ending in null pointer.
multiallocation_chain allocate_nodes(const size_type n)
{
//Preallocate all needed blocks to fulfill the request
@@ -238,7 +238,7 @@ class private_node_pool_impl
push_in_list(free_nodes_t &l, typename free_nodes_t::iterator &it)
: slist_(l), last_it_(it)
{}
-
+
void operator()(typename free_nodes_t::pointer p) const
{
slist_.push_front(*p);
@@ -258,10 +258,10 @@ class private_node_pool_impl
is_between(const void *addr, std::size_t size)
: beg_(static_cast<const char *>(addr)), end_(beg_+size)
{}
-
+
bool operator()(typename free_nodes_t::const_reference v) const
{
- return (beg_ <= reinterpret_cast<const char *>(&v) &&
+ return (beg_ <= reinterpret_cast<const char *>(&v) &&
end_ > reinterpret_cast<const char *>(&v));
}
private:
@@ -299,7 +299,7 @@ class private_node_pool_impl
{
if(!num_blocks)
return;
- size_type blocksize =
+ size_type blocksize =
get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of<node_t>::value);
try{
@@ -311,7 +311,7 @@ class private_node_pool_impl
char *pBlock = pNode;
m_blocklist.push_front(get_block_hook(pBlock, blocksize));
- //We initialize all Nodes in Node Block to insert
+ //We initialize all Nodes in Node Block to insert
//them in the free Node list
for(size_type i = 0; i < m_nodes_per_block; ++i, pNode += m_real_node_size){
m_freelist.push_front(*new (pNode) node_t);
@@ -335,13 +335,13 @@ class private_node_pool_impl
private:
//!Returns a reference to the block hook placed in the end of the block
static node_t & get_block_hook (void *block, size_type blocksize)
- {
- return *reinterpret_cast<node_t*>(reinterpret_cast<char*>(block) + blocksize);
+ {
+ return *reinterpret_cast<node_t*>(reinterpret_cast<char*>(block) + blocksize);
}
//!Returns the starting address of the block reference to the block hook placed in the end of the block
void *get_block_from_hook (node_t *hook, size_type blocksize)
- {
+ {
return (reinterpret_cast<char*>(hook) - blocksize);
}
diff --git a/boost/container/detail/pair.hpp b/boost/container/detail/pair.hpp
index 1aeff91137..2a20ed13ec 100644
--- a/boost/container/detail/pair.hpp
+++ b/boost/container/detail/pair.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -22,6 +22,8 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/type_traits.hpp>
+#include <boost/container/detail/mpl.hpp>
+#include <boost/container/detail/type_traits.hpp>
#include <utility> //std::pair
@@ -33,7 +35,7 @@
#endif
namespace boost {
-namespace container {
+namespace container {
namespace container_detail {
template <class T1, class T2>
@@ -62,6 +64,33 @@ struct pair_nat;
struct piecewise_construct_t { };
static const piecewise_construct_t piecewise_construct = piecewise_construct_t();
+/*
+template <class T1, class T2>
+struct pair
+{
+ template <class U, class V> pair(pair<U, V>&& p);
+ template <class... Args1, class... Args2>
+ pair(piecewise_construct_t, tuple<Args1...> first_args,
+ tuple<Args2...> second_args);
+
+ template <class U, class V> pair& operator=(const pair<U, V>& p);
+ pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
+ is_nothrow_move_assignable<T2>::value);
+ template <class U, class V> pair& operator=(pair<U, V>&& p);
+
+ void swap(pair& p) noexcept(noexcept(swap(first, p.first)) &&
+ noexcept(swap(second, p.second)));
+};
+
+template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
+template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
+template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
+template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
+template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
+template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
+*/
+
+
template <class T1, class T2>
struct pair
{
@@ -79,47 +108,40 @@ struct pair
pair()
: first(), second()
{}
-/*
- //pair from two values
- pair(const T1 &t1, const T2 &t2)
- : first(t1)
- , second(t2)
- {}
-
-
- //pair from two values
- pair(BOOST_RV_REF(T1) t1, BOOST_RV_REF(T2) t2)
- : first(::boost::move(t1))
- , second(::boost::move(t2))
- {}
-*/
- template<class U, class V>
- pair(BOOST_FWD_REF(U) u, BOOST_FWD_REF(V) v)
- : first(::boost::forward<U>(u))
- , second(::boost::forward<V>(v))
- {}
//pair copy assignment
pair(const pair& x)
: first(x.first), second(x.second)
{}
+ //pair move constructor
+ pair(BOOST_RV_REF(pair) p)
+ : first(::boost::move(p.first)), second(::boost::move(p.second))
+ {}
+
template <class D, class S>
pair(const pair<D, S> &p)
: first(p.first), second(p.second)
{}
- //pair move constructor
- pair(BOOST_RV_REF(pair) p)
+ template <class D, class S>
+ pair(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
: first(::boost::move(p.first)), second(::boost::move(p.second))
{}
- template <class D, class S>
- pair(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p)
- : first(::boost::move(p.first)), second(::boost::move(p.second))
+ //pair from two values
+ pair(const T1 &t1, const T2 &t2)
+ : first(t1)
+ , second(t2)
+ {}
+
+ template<class U, class V>
+ pair(BOOST_FWD_REF(U) u, BOOST_FWD_REF(V) v)
+ : first(::boost::forward<U>(u))
+ , second(::boost::forward<V>(v))
{}
- //std::pair copy constructor
+ //And now compatibility with std::pair
pair(const std::pair<T1, T2>& x)
: first(x.first), second(x.second)
{}
@@ -129,17 +151,20 @@ struct pair
: first(p.first), second(p.second)
{}
- //std::pair move constructor
- template <class D, class S>
- pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p)
+ pair(BOOST_RV_REF_BEG std::pair<T1, T2> BOOST_RV_REF_END p)
: first(::boost::move(p.first)), second(::boost::move(p.second))
{}
- pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p)
+ template <class D, class S>
+ pair(BOOST_RV_REF_BEG std::pair<D, S> BOOST_RV_REF_END p)
: first(::boost::move(p.first)), second(::boost::move(p.second))
{}
//piecewise_construct missing
+ //template <class U, class V> pair(pair<U, V>&& p);
+ //template <class... Args1, class... Args2>
+ // pair(piecewise_construct_t, tuple<Args1...> first_args,
+ // tuple<Args2...> second_args);
/*
//Variadic versions
template<class U>
@@ -179,14 +204,6 @@ struct pair
return *this;
}
- template <class D, class S>
- pair& operator=(const pair<D, S>&p)
- {
- first = p.first;
- second = p.second;
- return *this;
- }
-
//pair move assignment
pair& operator=(BOOST_RV_REF(pair) p)
{
@@ -196,7 +213,23 @@ struct pair
}
template <class D, class S>
- pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p)
+ typename ::boost::container::container_detail::enable_if_c
+ < !(::boost::container::container_detail::is_same<T1, D>::value &&
+ ::boost::container::container_detail::is_same<T2, S>::value)
+ , pair &>::type
+ operator=(const pair<D, S>&p)
+ {
+ first = p.first;
+ second = p.second;
+ return *this;
+ }
+
+ template <class D, class S>
+ typename ::boost::container::container_detail::enable_if_c
+ < !(::boost::container::container_detail::is_same<T1, D>::value &&
+ ::boost::container::container_detail::is_same<T2, S>::value)
+ , pair &>::type
+ operator=(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
{
first = ::boost::move(p.first);
second = ::boost::move(p.second);
@@ -220,7 +253,7 @@ struct pair
}
//std::pair move assignment
- pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p)
+ pair& operator=(BOOST_RV_REF_BEG std::pair<T1, T2> BOOST_RV_REF_END p)
{
first = ::boost::move(p.first);
second = ::boost::move(p.second);
@@ -228,7 +261,7 @@ struct pair
}
template <class D, class S>
- pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p)
+ pair& operator=(BOOST_RV_REF_BEG std::pair<D, S> BOOST_RV_REF_END p)
{
first = ::boost::move(p.first);
second = ::boost::move(p.second);
@@ -280,8 +313,8 @@ inline void swap(pair<T1, T2>& x, pair<T1, T2>& y)
swap(x.second, y.second);
}
-} //namespace container_detail {
-} //namespace container {
+} //namespace container_detail {
+} //namespace container {
//Without this specialization recursive flat_(multi)map instantiation fails
diff --git a/boost/container/detail/pool_common.hpp b/boost/container/detail/pool_common.hpp
index c66e2cd18c..500b9124d5 100644
--- a/boost/container/detail/pool_common.hpp
+++ b/boost/container/detail/pool_common.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
diff --git a/boost/container/detail/preprocessor.hpp b/boost/container/detail/preprocessor.hpp
index 9916fbac62..1818094be1 100644
--- a/boost/container/detail/preprocessor.hpp
+++ b/boost/container/detail/preprocessor.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -27,7 +27,7 @@
//#error "This file is not needed when perfect forwarding is available"
#endif //BOOST_CONTAINER_PERFECT_FORWARDING
-#include <boost/preprocessor/iteration/local.hpp>
+#include <boost/preprocessor/iteration/local.hpp>
#include <boost/preprocessor/punctuation/paren_if.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/control/expr_if.hpp>
@@ -62,6 +62,10 @@
//!
#endif //#ifndef BOOST_NO_RVALUE_REFERENCES
+#define BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q(z, n, Data) \
+const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
+//!
+
#ifndef BOOST_NO_RVALUE_REFERENCES
#define BOOST_CONTAINER_PP_PARAM(U, u) \
U && u \
@@ -74,17 +78,16 @@
#ifndef BOOST_NO_RVALUE_REFERENCES
- #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
+ #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
- #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
- BOOST_PP_CAT(m_p, n) (boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \
- //!
+ #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
+ BOOST_PP_CAT(m_p, n) (static_cast<BOOST_PP_CAT(P, n)>( BOOST_PP_CAT(p, n) )) \
- #else //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
+ #else //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
- #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
- BOOST_PP_CAT(m_p, n) (static_cast<BOOST_PP_CAT(P, n)>( BOOST_PP_CAT(p, n) )) \
- //!
+ #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
+ BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \
+ //!
#endif //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
@@ -127,7 +130,7 @@
#else //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \
- boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \
+ ::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \
//!
#endif //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
@@ -140,11 +143,11 @@
#define BOOST_CONTAINER_PP_PARAM_FORWARD(z, n, data) \
-boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \
+::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \
//!
#define BOOST_CONTAINER_PP_DECLVAL(z, n, data) \
-boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \
+::boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \
//!
#define BOOST_CONTAINER_PP_MEMBER_IT_FORWARD(z, n, data) \
@@ -152,7 +155,11 @@ BOOST_PP_CAT(*this->m_p, n) \
//!
#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_VOID_DEFAULT(z, n, data) \
- BOOST_PP_CAT(class P, n) = void \
+ BOOST_PP_CAT(class P, n) = void \
+//!
+
+#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT(z, n, default_type) \
+ BOOST_PP_CAT(class P, n) = default_type \
//!
#define BOOST_CONTAINER_PP_STATIC_PARAM_REF_DECLARE(z, n, data) \
diff --git a/boost/container/detail/stored_ref.hpp b/boost/container/detail/stored_ref.hpp
index df0faa85a0..80fda89615 100644
--- a/boost/container/detail/stored_ref.hpp
+++ b/boost/container/detail/stored_ref.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
diff --git a/boost/container/detail/transform_iterator.hpp b/boost/container/detail/transform_iterator.hpp
index 17eca9ef61..98f5c04d60 100644
--- a/boost/container/detail/transform_iterator.hpp
+++ b/boost/container/detail/transform_iterator.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
// (C) Copyright Gennaro Prota 2003 - 2004.
//
// Distributed under the Boost Software License, Version 1.0.
@@ -24,7 +24,7 @@
#include <iterator>
namespace boost {
-namespace container {
+namespace container {
template <class PseudoReference>
struct operator_arrow_proxy
@@ -74,7 +74,7 @@ class transform_iterator
{}
//Constructors
- transform_iterator& operator++()
+ transform_iterator& operator++()
{ increment(); return *this; }
transform_iterator operator++(int)
@@ -168,7 +168,7 @@ make_transform_iterator(Iterator it, UnaryFunc fun)
return transform_iterator<Iterator, UnaryFunc>(it, fun);
}
-} //namespace container {
+} //namespace container {
} //namespace boost {
#include <boost/container/detail/config_end.hpp>
diff --git a/boost/container/detail/tree.hpp b/boost/container/detail/tree.hpp
index 6cd91ed2a6..3ab1536204 100644
--- a/boost/container/detail/tree.hpp
+++ b/boost/container/detail/tree.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -27,7 +27,7 @@
#include <boost/container/detail/destroyers.hpp>
#include <boost/container/detail/pair.hpp>
#include <boost/container/detail/type_traits.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
#include <boost/container/detail/preprocessor.hpp>
#endif
@@ -45,7 +45,7 @@ struct value_compare_impl
: public KeyCompare
{
typedef Value value_type;
- typedef KeyCompare key_compare;
+ typedef KeyCompare key_compare;
typedef KeyOfValue key_of_value;
typedef Key key_type;
@@ -90,70 +90,38 @@ struct rbtree_hook
>::type type;
};
+//This trait is used to type-pun std::pair because in C++03
+//compilers std::pair is useless for C++11 features
template<class T>
-struct rbtree_type
+struct rbtree_internal_data_type
{
typedef T type;
};
template<class T1, class T2>
-struct rbtree_type< std::pair<T1, T2> >
+struct rbtree_internal_data_type< std::pair<T1, T2> >
{
typedef pair<T1, T2> type;
};
+
+//The node to be store in the tree
template <class T, class VoidPointer>
struct rbtree_node
: public rbtree_hook<VoidPointer>::type
{
private:
- BOOST_COPYABLE_AND_MOVABLE(rbtree_node)
+ //BOOST_COPYABLE_AND_MOVABLE(rbtree_node)
+ rbtree_node();
public:
typedef typename rbtree_hook<VoidPointer>::type hook_type;
typedef T value_type;
- typedef typename rbtree_type<T>::type internal_type;
+ typedef typename rbtree_internal_data_type<T>::type internal_type;
typedef rbtree_node<T, VoidPointer> node_type;
- rbtree_node()
- : m_data()
- {}
-
- rbtree_node(const rbtree_node &other)
- : m_data(other.m_data)
- {}
-
- rbtree_node(BOOST_RV_REF(rbtree_node) other)
- : m_data(boost::move(other.m_data))
- {}
-
- #ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
- #define BOOST_PP_LOCAL_MACRO(n) \
- template<BOOST_PP_ENUM_PARAMS(n, class P)> \
- rbtree_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- : m_data(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \
- {} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #else //#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
- template<class ...Args>
- rbtree_node(Args &&...args)
- : m_data(boost::forward<Args>(args)...)
- {}
- #endif//#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
- rbtree_node &operator=(const rbtree_node &other)
- { do_assign(other.m_data); return *this; }
-
- rbtree_node &operator=(BOOST_RV_REF(rbtree_node) other)
- { do_move(other.m_data); return *this; }
-
T &get_data()
{
T* ptr = reinterpret_cast<T*>(&this->m_data);
@@ -166,7 +134,6 @@ struct rbtree_node
return *ptr;
}
- private:
internal_type m_data;
template<class A, class B>
@@ -188,22 +155,22 @@ struct rbtree_node
{ m_data = v; }
template<class A, class B>
- void do_move(std::pair<const A, B> &p)
+ void do_move_assign(std::pair<const A, B> &p)
{
- const_cast<A&>(m_data.first) = boost::move(p.first);
- m_data.second = boost::move(p.second);
+ const_cast<A&>(m_data.first) = ::boost::move(p.first);
+ m_data.second = ::boost::move(p.second);
}
template<class A, class B>
- void do_move(pair<const A, B> &p)
+ void do_move_assign(pair<const A, B> &p)
{
- const_cast<A&>(m_data.first) = boost::move(p.first);
- m_data.second = boost::move(p.second);
+ const_cast<A&>(m_data.first) = ::boost::move(p.first);
+ m_data.second = ::boost::move(p.second);
}
template<class V>
- void do_move(V &v)
- { m_data = boost::move(v); }
+ void do_move_assign(V &v)
+ { m_data = ::boost::move(v); }
};
}//namespace container_detail {
@@ -236,13 +203,13 @@ struct intrusive_rbtree_type
namespace container_detail {
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
class rbtree
: protected container_detail::node_alloc_holder
< A
, typename container_detail::intrusive_rbtree_type
- <A, value_compare_impl<Key, Value, KeyCompare, KeyOfValue>
+ <A, value_compare_impl<Key, Value, KeyCompare, KeyOfValue>
>::type
, KeyCompare
>
@@ -251,7 +218,7 @@ class rbtree
< A, value_compare_impl
<Key, Value, KeyCompare, KeyOfValue>
>::type Icont;
- typedef container_detail::node_alloc_holder
+ typedef container_detail::node_alloc_holder
<A, Icont, KeyCompare> AllocHolder;
typedef typename AllocHolder::NodePtr NodePtr;
typedef rbtree < Key, Value, KeyOfValue
@@ -282,7 +249,7 @@ class rbtree
//First recycle a node (this can't throw)
try{
//This can throw
- *p = other;
+ p->do_assign(other.m_data);
return p;
}
catch(...){
@@ -295,7 +262,7 @@ class rbtree
}
}
else{
- return m_holder.create_node(other);
+ return m_holder.create_node(other.m_data);
}
}
@@ -319,7 +286,7 @@ class rbtree
//First recycle a node (this can't throw)
try{
//This can throw
- *p = boost::move(other);
+ p->do_move_assign(const_cast<Node &>(other).m_data);
return p;
}
catch(...){
@@ -332,7 +299,7 @@ class rbtree
}
}
else{
- return m_holder.create_node(other);
+ return m_holder.create_node(other.m_data);
}
}
@@ -431,17 +398,17 @@ class rbtree
{}
//Pointer like operators
- const_reference operator*() const
+ const_reference operator*() const
{ return m_it->get_data(); }
- const_pointer operator->() const
+ const_pointer operator->() const
{ return const_pointer(&m_it->get_data()); }
//Increment / Decrement
- const_iterator& operator++()
+ const_iterator& operator++()
{ prot_incr(); return *this; }
- const_iterator operator++(int)
+ const_iterator operator++(int)
{ iiterator tmp = m_it; ++*this; return const_iterator(tmp); }
const_iterator& operator--()
@@ -465,7 +432,7 @@ class rbtree
explicit iterator(iiterator it)
: const_iterator(it)
{}
-
+
iiterator get()
{ return this->m_it; }
@@ -478,16 +445,18 @@ class rbtree
iterator(){}
//Pointer like operators
- reference operator*() const { return this->m_it->get_data(); }
- pointer operator->() const { return pointer(&this->m_it->get_data()); }
+ reference operator*() const
+ { return this->m_it->get_data(); }
+ pointer operator->() const
+ { return boost::intrusive::pointer_traits<pointer>::pointer_to(this->m_it->get_data()); }
//Increment / Decrement
- iterator& operator++()
+ iterator& operator++()
{ this->prot_incr(); return *this; }
iterator operator++(int)
{ iiterator tmp = this->m_it; ++*this; return iterator(tmp); }
-
+
iterator& operator--()
{ this->prot_decr(); return *this; }
@@ -524,17 +493,36 @@ class rbtree
priv_create_and_insert_ordered_nodes(first, last, alloc_version(), ItCat());
}
- rbtree(const rbtree& x)
+ rbtree(const rbtree& x)
: AllocHolder(x, x.key_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())
+ rbtree(BOOST_RV_REF(rbtree) x)
+ : AllocHolder(::boost::move(static_cast<AllocHolder&>(x)), x.key_comp())
{}
+ rbtree(const rbtree& x, const allocator_type &a)
+ : AllocHolder(a, x.key_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())
+ {
+ if(this->node_alloc() == x.node_alloc()){
+ this->icont().swap(x.icont());
+ }
+ else{
+ this->icont().clone_from
+ (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
+ }
+ }
+
~rbtree()
{} //AllocHolder clears the tree
@@ -552,7 +540,7 @@ class rbtree
//Transfer all the nodes to a temporary tree
//If anything goes wrong, all the nodes will be destroyed
//automatically
- Icont other_tree(boost::move(this->icont()));
+ Icont other_tree(::boost::move(this->icont()));
//Now recreate the source tree reusing nodes stored by other_tree
this->icont().clone_from
@@ -578,7 +566,7 @@ class rbtree
if(this_alloc == x_alloc){
//Destroy and swap pointers
this->clear();
- this->icont() = boost::move(x.icont());
+ this->icont() = ::boost::move(x.icont());
//Move allocator if needed
this->AllocHolder::move_assign_alloc(x);
}
@@ -587,7 +575,7 @@ class rbtree
//Transfer all the nodes to a temporary tree
//If anything goes wrong, all the nodes will be destroyed
//automatically
- Icont other_tree(boost::move(this->icont()));
+ Icont other_tree(::boost::move(this->icont()));
//Now recreate the source tree reusing nodes stored by other_tree
this->icont().clone_from
@@ -605,18 +593,18 @@ class rbtree
return *this;
}
- public:
+ public:
// accessors:
- value_compare value_comp() const
+ value_compare value_comp() const
{ return this->icont().value_comp().value_comp(); }
- key_compare key_comp() const
+ key_compare key_comp() const
{ return this->icont().value_comp().value_comp().key_comp(); }
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return allocator_type(this->node_alloc()); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return this->node_alloc(); }
stored_allocator_type &get_stored_allocator()
@@ -647,46 +635,46 @@ class rbtree
{ 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
+ const_iterator cbegin() const
{ return const_iterator(this->non_const_icont().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
+ const_iterator cend() const
{ return const_iterator(this->non_const_icont().end()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 const_reverse_iterator(cend()); }
+ const_reverse_iterator crbegin() const
+ { return const_reverse_iterator(cend()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const
+ const_reverse_iterator crend() const
{ return const_reverse_iterator(cbegin()); }
- bool empty() const
+ bool empty() const
{ return !this->size(); }
- size_type size() const
+ size_type size() const
{ return this->icont().size(); }
- size_type max_size() const
+ size_type max_size() const
{ return AllocHolder::max_size(); }
void swap(ThisType& x)
@@ -700,7 +688,7 @@ class rbtree
std::pair<iterator,bool> insert_unique_check
(const key_type& key, insert_commit_data &data)
{
- std::pair<iiterator, bool> ret =
+ std::pair<iiterator, bool> ret =
this->icont().insert_unique_check(key, KeyNodeCompare(value_comp()), data);
return std::pair<iterator, bool>(iterator(ret.first), ret.second);
}
@@ -708,7 +696,7 @@ class rbtree
std::pair<iterator,bool> insert_unique_check
(const_iterator hint, const key_type& key, insert_commit_data &data)
{
- std::pair<iiterator, bool> ret =
+ std::pair<iiterator, bool> ret =
this->icont().insert_unique_check(hint.get(), key, KeyNodeCompare(value_comp()), data);
return std::pair<iterator, bool>(iterator(ret.first), ret.second);
}
@@ -757,12 +745,14 @@ class rbtree
{
value_type &v = p->get_data();
insert_commit_data data;
+ scoped_destroy_deallocator<NodeAlloc> destroy_deallocator(p, this->node_alloc());
std::pair<iterator,bool> ret =
this->insert_unique_check(KeyOfValue()(v), data);
if(!ret.second){
- Destroyer(this->node_alloc())(p);
return ret;
}
+ //No throw insertion part, release rollback
+ destroy_deallocator.release();
return std::pair<iterator,bool>
( iterator(iiterator(this->icont().insert_unique_commit(*p, data)))
, true );
@@ -872,9 +862,9 @@ class rbtree
if(this->empty()){
//Insert with end hint, to achieve linear
//complexity if [first, last) is ordered
- const_iterator end(this->end());
+ const_iterator hint(this->cend());
for( ; first != last; ++first)
- this->insert_unique(end, *first);
+ hint = this->insert_unique(hint, *first);
}
else{
for( ; first != last; ++first)
@@ -913,9 +903,9 @@ class rbtree
{
//Insert with end hint, to achieve linear
//complexity if [first, last) is ordered
- const_iterator end(this->cend());
+ const_iterator hint(this->cend());
for( ; first != last; ++first)
- this->insert_equal(end, *first);
+ hint = this->insert_equal(hint, *first);
}
iterator erase(const_iterator position)
@@ -927,7 +917,7 @@ class rbtree
iterator erase(const_iterator first, const_iterator last)
{ return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); }
- void clear()
+ void clear()
{ AllocHolder::clear(alloc_version()); }
// set operations:
@@ -953,14 +943,14 @@ class rbtree
{ return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(value_comp()))); }
std::pair<iterator,iterator> equal_range(const key_type& k)
- {
+ {
std::pair<iiterator, iiterator> ret =
this->icont().equal_range(k, KeyNodeCompare(value_comp()));
return std::pair<iterator,iterator>(iterator(ret.first), iterator(ret.second));
}
std::pair<const_iterator, const_iterator> equal_range(const key_type& k) const
- {
+ {
std::pair<iiterator, iiterator> ret =
this->non_const_icont().equal_range(k, KeyNodeCompare(value_comp()));
return std::pair<const_iterator,const_iterator>
@@ -1072,63 +1062,63 @@ class rbtree
}
};
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
-inline bool
-operator==(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
+inline bool
+operator==(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y)
{
return x.size() == y.size() &&
std::equal(x.begin(), x.end(), y.begin());
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
-inline bool
-operator<(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
+inline bool
+operator<(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y)
{
- return std::lexicographical_compare(x.begin(), x.end(),
+ return std::lexicographical_compare(x.begin(), x.end(),
y.begin(), y.end());
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
-inline bool
-operator!=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
+inline bool
+operator!=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
return !(x == y);
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
-inline bool
-operator>(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
+inline bool
+operator>(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
return y < x;
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
-inline bool
-operator<=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
+inline bool
+operator<=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
return !(y < x);
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
-inline bool
-operator>=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
+inline bool
+operator>=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
return !(x < y);
}
-template <class Key, class Value, class KeyOfValue,
+template <class Key, class Value, class KeyOfValue,
class KeyCompare, class A>
-inline void
-swap(rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
+inline void
+swap(rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y)
{
x.swap(y);
@@ -1139,7 +1129,7 @@ swap(rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
/*
//!has_trivial_destructor_after_move<> == true_type
//!specialization for optimizations
-template <class K, class V, class KOV,
+template <class K, class V, class KOV,
class C, class A>
struct has_trivial_destructor_after_move
<boost::container::container_detail::rbtree<K, V, KOV, C, A> >
diff --git a/boost/container/detail/type_traits.hpp b/boost/container/detail/type_traits.hpp
index 6a0b3ed58d..0e096e54e3 100644
--- a/boost/container/detail/type_traits.hpp
+++ b/boost/container/detail/type_traits.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
// (C) Copyright John Maddock 2000.
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -24,11 +24,18 @@
#include <boost/move/move.hpp>
namespace boost {
-namespace container {
+namespace container {
namespace container_detail {
struct nat{};
+template <typename U>
+struct LowPriorityConversion
+{
+ // Convertible from T with user-defined-conversion rank.
+ LowPriorityConversion(const U&) { }
+};
+
//boost::alignment_of yields to 10K lines of preprocessed code, so we
//need an alternative
template <typename T> struct alignment_of;
@@ -195,7 +202,7 @@ struct remove_ref_const
};
} // namespace container_detail
-} //namespace container {
+} //namespace container {
} //namespace boost {
#include <boost/container/detail/config_end.hpp>
diff --git a/boost/container/detail/utilities.hpp b/boost/container/detail/utilities.hpp
index ee0fe993b2..152b5e162e 100644
--- a/boost/container/detail/utilities.hpp
+++ b/boost/container/detail/utilities.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -21,13 +21,23 @@
#include <boost/move/move.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/type_traits.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <algorithm>
namespace boost {
namespace container {
namespace container_detail {
+template <typename T>
+inline T* addressof(T& obj)
+{
+ return static_cast<T*>(
+ static_cast<void*>(
+ const_cast<char*>(
+ &reinterpret_cast<const char&>(obj)
+ )));
+}
+
template<class T>
const T &max_value(const T &a, const T &b)
{ return a > b ? a : b; }
@@ -140,7 +150,7 @@ enum {
&& !::boost::is_fundamental<_TypeT>::value
};
-};
+};
*/
template<class T>
@@ -223,7 +233,7 @@ F uninitialized_copy_alloc(A &a, I f, I l, F r)
template
<typename A,
typename F, // F models ForwardIterator
- typename T>
+ typename T>
void uninitialized_fill_alloc(A &a, F f, F l, const T &t)
{
while (f != l) {
@@ -262,6 +272,7 @@ F uninitialized_copy_or_move_alloc
return ::boost::container::uninitialized_copy_alloc(a, f, l, r);
}
+
} //namespace container {
} //namespace boost {
diff --git a/boost/container/detail/value_init.hpp b/boost/container/detail/value_init.hpp
index afbc9c1e34..ec1a99c56d 100644
--- a/boost/container/detail/value_init.hpp
+++ b/boost/container/detail/value_init.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -21,7 +21,7 @@
#include <boost/container/detail/workaround.hpp>
namespace boost {
-namespace container {
+namespace container {
namespace container_detail {
template<class T>
@@ -36,8 +36,8 @@ struct value_init
T m_t;
};
-} //namespace container_detail {
-} //namespace container {
+} //namespace container_detail {
+} //namespace container {
} //namespace boost {
#include <boost/container/detail/config_end.hpp>
diff --git a/boost/container/detail/variadic_templates_tools.hpp b/boost/container/detail/variadic_templates_tools.hpp
index f21f972ab1..d903dfa04c 100644
--- a/boost/container/detail/variadic_templates_tools.hpp
+++ b/boost/container/detail/variadic_templates_tools.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -21,7 +21,7 @@
#include <cstddef> //std::size_t
namespace boost {
-namespace container {
+namespace container {
namespace container_detail {
template<typename... Values>
@@ -136,7 +136,7 @@ struct index_tuple{};
template<std::size_t Num, typename Tuple = index_tuple<> >
struct build_number_seq;
-template<std::size_t Num, int... Indexes>
+template<std::size_t Num, int... Indexes>
struct build_number_seq<Num, index_tuple<Indexes...> >
: build_number_seq<Num - 1, index_tuple<Indexes..., sizeof...(Indexes)> >
{};
diff --git a/boost/container/detail/version_type.hpp b/boost/container/detail/version_type.hpp
index 46344faca0..e47ba26f12 100644
--- a/boost/container/detail/version_type.hpp
+++ b/boost/container/detail/version_type.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -38,7 +38,7 @@ struct version_type
namespace impl{
-template <class T,
+template <class T,
bool = container_detail::is_convertible<version_type<T, 0>, typename T::version>::value>
struct extract_version
{
diff --git a/boost/container/detail/workaround.hpp b/boost/container/detail/workaround.hpp
index 45ab2f2c4d..c4440743fc 100644
--- a/boost/container/detail/workaround.hpp
+++ b/boost/container/detail/workaround.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -26,6 +26,11 @@
#define BOOST_CONTAINER_NOEXCEPT_IF(x) noexcept(x)
#endif
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES) && defined(__GXX_EXPERIMENTAL_CXX0X__)\
+ && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40700)
+ #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST
+#endif
+
#include <boost/container/detail/config_end.hpp>
#endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP
diff --git a/boost/container/flat_map.hpp b/boost/container/flat_map.hpp
index 2d4515b4a4..0142500860 100644
--- a/boost/container/flat_map.hpp
+++ b/boost/container/flat_map.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -26,7 +26,7 @@
#include <boost/container/detail/flat_tree.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/container/detail/mpl.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/move/move.hpp>
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -47,11 +47,11 @@ template <class Key, class T, class Pred, class A>
class flat_map;
template <class Key, class T, class Pred, class A>
-inline bool operator==(const flat_map<Key,T,Pred,A>& x,
+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,
+inline bool operator<(const flat_map<Key,T,Pred,A>& x,
const flat_map<Key,T,Pred,A>& y);
namespace container_detail{
@@ -73,12 +73,12 @@ static D force_copy(S s)
/// @endcond
//! A flat_map is a kind of associative container that supports unique keys (contains at
-//! most one of each key value) and provides for fast retrieval of values of another
+//! most one of each key value) and provides for fast retrieval of values of another
//! type T based on the keys. The flat_map class supports random-access iterators.
-//!
-//! A flat_map satisfies all of the requirements of a container and of a reversible
-//! container and of an associative container. A flat_map also provides
-//! most operations described for unique keys. For a
+//!
+//! A flat_map satisfies all of the requirements of a container and of a reversible
+//! container and of an associative container. A flat_map also provides
+//! most operations described for unique keys. For a
//! 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>).
//!
@@ -86,35 +86,35 @@ static D force_copy(S s)
//!
//! A 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.
//! This means that inserting a new element into a flat_map invalidates
//! previous iterators and references
//!
-//! Erasing an element of a flat_map invalidates iterators and references
+//! 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< std::pair< Key, T> >, class A = std::allocator<T> >
#else
template <class Key, class T, class Pred, class A>
#endif
-class flat_map
+class flat_map
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(flat_map)
//This is the tree that we should store if pair was movable
- typedef container_detail::flat_tree<Key,
- std::pair<Key, T>,
- container_detail::select1st< std::pair<Key, T> >,
- Pred,
+ typedef container_detail::flat_tree<Key,
+ std::pair<Key, T>,
+ container_detail::select1st< std::pair<Key, T> >,
+ Pred,
A> 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,
+ 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
<container_detail::pair<Key, T> >::type> impl_tree_t;
impl_tree_t m_flat_tree; // flat tree representing flat_map
@@ -165,245 +165,267 @@ class flat_map
get_flat_tree_iterators
<pointer>::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;
+
public:
//! <b>Effects</b>: Default constructs an empty flat_map.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- flat_map()
+ flat_map()
: m_flat_tree() {}
//! <b>Effects</b>: Constructs an empty flat_map using the specified
//! comparison object and allocator.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- explicit flat_map(const Pred& comp, const allocator_type& a = allocator_type())
+ explicit flat_map(const Pred& 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
+ //! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
- //!
- //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
+ //!
+ //! <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(),
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))
{ m_flat_tree.insert_unique(first, last); }
- //! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
//! allocator, and inserts elements from the ordered unique range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
//! unique values.
- //!
+ //!
//! <b>Complexity</b>: Linear in N.
+ //!
+ //! <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())
- : m_flat_tree(ordered_range, first, last, comp, a)
+ : m_flat_tree(ordered_range, first, last, comp, a)
{}
//! <b>Effects</b>: Copy constructs a flat_map.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- flat_map(const flat_map<Key,T,Pred,A>& x)
+ flat_map(const flat_map& x)
: m_flat_tree(x.m_flat_tree) {}
//! <b>Effects</b>: Move constructs a flat_map.
//! Constructs *this using x's resources.
- //!
- //! <b>Complexity</b>: Construct.
- //!
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
//! <b>Postcondition</b>: x is emptied.
- flat_map(BOOST_RV_REF(flat_map) x)
+ flat_map(BOOST_RV_REF(flat_map) x)
: m_flat_tree(boost::move(x.m_flat_tree))
{}
+ //! <b>Effects</b>: Copy constructs a flat_map using the specified allocator.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ flat_map(const flat_map& x, const allocator_type &a)
+ : m_flat_tree(x.m_flat_tree, a)
+ {}
+
+ //! <b>Effects</b>: Move constructs a flat_map using the specified allocator.
+ //! Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant if x.get_allocator() == a, linear otherwise.
+ flat_map(BOOST_RV_REF(flat_map) x, const allocator_type &a)
+ : m_flat_tree(boost::move(x.m_flat_tree), a)
+ {}
+
//! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- flat_map<Key,T,Pred,A>& operator=(BOOST_COPY_ASSIGN_REF(flat_map) x)
+ flat_map& operator=(BOOST_COPY_ASSIGN_REF(flat_map) x)
{ m_flat_tree = x.m_flat_tree; return *this; }
//! <b>Effects</b>: Move constructs a flat_map.
//! Constructs *this using x's resources.
- //!
+ //!
//! <b>Complexity</b>: Construct.
- //!
+ //!
//! <b>Postcondition</b>: x is emptied.
- flat_map<Key,T,Pred,A>& operator=(BOOST_RV_REF(flat_map) mx)
+ flat_map& operator=(BOOST_RV_REF(flat_map) 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 container_detail::force<key_compare>(m_flat_tree.key_comp()); }
+ key_compare key_comp() const
+ { return container_detail::force_copy<key_compare>(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 value_compare(container_detail::force<key_compare>(m_flat_tree.key_comp())); }
+ value_compare value_comp() const
+ { return value_compare(container_detail::force_copy<key_compare>(m_flat_tree.key_comp())); }
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
- { return container_detail::force<allocator_type>(m_flat_tree.get_allocator()); }
+ allocator_type get_allocator() const
+ { return container_detail::force_copy<allocator_type>(m_flat_tree.get_allocator()); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return container_detail::force<stored_allocator_type>(m_flat_tree.get_stored_allocator()); }
stored_allocator_type &get_stored_allocator()
{ return container_detail::force<stored_allocator_type>(m_flat_tree.get_stored_allocator()); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ return container_detail::force_copy<iterator>(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 begin() const
- { return container_detail::force<const_iterator>(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 container_detail::force<const_iterator>(m_flat_tree.cbegin()); }
+ const_iterator begin() const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.begin()); }
//! <b>Effects</b>: Returns an iterator to the end of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ return container_detail::force_copy<iterator>(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 end() const
- { return container_detail::force<const_iterator>(m_flat_tree.end()); }
+ const_iterator end() const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.end()); }
- //! <b>Effects</b>: Returns a const_iterator to the end of the container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_iterator cend() const
- { return container_detail::force<const_iterator>(m_flat_tree.cend()); }
+ reverse_iterator rbegin()
+ { return container_detail::force_copy<reverse_iterator>(m_flat_tree.rbegin()); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
- { return container_detail::force<reverse_iterator>(m_flat_tree.rbegin()); }
+ const_reverse_iterator rbegin() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.rbegin()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 rbegin() const
- { return container_detail::force<const_reverse_iterator>(m_flat_tree.rbegin()); }
+ reverse_iterator rend()
+ { return container_detail::force_copy<reverse_iterator>(m_flat_tree.rend()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crbegin() const
- { return container_detail::force<const_reverse_iterator>(m_flat_tree.crbegin()); }
+ const_reverse_iterator rend() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.rend()); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend()
- { return container_detail::force<reverse_iterator>(m_flat_tree.rend()); }
+ const_iterator cbegin() const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.cbegin()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a const_iterator to the end of the container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
- { return container_detail::force<const_reverse_iterator>(m_flat_tree.rend()); }
+ const_iterator cend() const
+ { return container_detail::force_copy<const_iterator>(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 crbegin() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.crbegin()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const
- { return container_detail::force<const_reverse_iterator>(m_flat_tree.crend()); }
+ const_reverse_iterator crend() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.crend()); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_flat_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_flat_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_flat_tree.max_size(); }
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! Effects: If there is no key equivalent to x in the flat_map, inserts
+ //! 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.
- //!
+ //!
//! Complexity: Logarithmic.
mapped_type &operator[](const key_type& k);
- //! Effects: If there is no key equivalent to x in the flat_map, inserts
+ //! 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.
- //!
+ //!
//! Complexity: Logarithmic.
mapped_type &operator[](key_type &&k) ;
@@ -443,10 +465,10 @@ class flat_map
void swap(flat_map& x)
{ m_flat_tree.swap(x.m_flat_tree); }
- //! <b>Effects</b>: Inserts x if and only if there is no element in the container
+ //! <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
+ //! <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.
//!
@@ -454,14 +476,14 @@ class flat_map
//! 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)
- { return container_detail::force<std::pair<iterator,bool> >(
+ std::pair<iterator,bool> insert(const value_type& x)
+ { 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
//! 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
+ //! <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.
//!
@@ -469,14 +491,14 @@ class flat_map
//! 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 container_detail::force<std::pair<iterator,bool> >(
+ std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
+ { return container_detail::force_copy<std::pair<iterator,bool> >(
m_flat_tree.insert_unique(boost::move(container_detail::force<impl_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.
//!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! <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.
//!
@@ -484,13 +506,13 @@ class flat_map
//! 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(impl_value_type) x)
+ std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x)
{
- return container_detail::force<std::pair<iterator,bool> >
+ return container_detail::force_copy<std::pair<iterator,bool> >
(m_flat_tree.insert_unique(boost::move(x)));
}
- //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
+ //! <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.
//!
@@ -502,8 +524,11 @@ class flat_map
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
iterator insert(const_iterator position, const value_type& x)
- { return container_detail::force_copy<iterator>(
- m_flat_tree.insert_unique(container_detail::force<impl_const_iterator>(position), container_detail::force<impl_value_type>(x))); }
+ {
+ return container_detail::force_copy<iterator>(
+ m_flat_tree.insert_unique( container_detail::force_copy<impl_const_iterator>(position)
+ , container_detail::force<impl_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.
@@ -515,8 +540,11 @@ class flat_map
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
- { return container_detail::force_copy<iterator>
- (m_flat_tree.insert_unique(container_detail::force<impl_const_iterator>(position), boost::move(container_detail::force<impl_value_type>(x)))); }
+ {
+ return container_detail::force_copy<iterator>
+ (m_flat_tree.insert_unique( container_detail::force_copy<impl_const_iterator>(position)
+ , boost::move(container_detail::force<impl_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.
@@ -527,15 +555,15 @@ class flat_map
//! 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(impl_value_type) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
{
return container_detail::force_copy<iterator>(
- m_flat_tree.insert_unique(container_detail::force<impl_const_iterator>(position), boost::move(x)));
+ m_flat_tree.insert_unique(container_detail::force_copy<impl_const_iterator>(position), 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
+ //! <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)
@@ -543,16 +571,33 @@ class flat_map
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
template <class InputIterator>
- void insert(InputIterator first, InputIterator last)
+ void insert(InputIterator first, InputIterator last)
{ m_flat_tree.insert_unique(first, last); }
+ //! <b>Requires</b>: first, last are not iterators into *this.
+ //!
+ //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
+ //! unique values.
+ //!
+ //! <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. This
+ //! function is more efficient than the normal range creation for ordered ranges.
+ //!
+ //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
+ //! search time plus N*size() insertion time.
+ //!
+ //! <b>Note</b>: If an element is inserted it might invalidate elements.
+ template <class InputIterator>
+ 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
+ //! 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
+ //! <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.
//!
@@ -565,7 +610,7 @@ class flat_map
{ 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
- //! std::forward<Args>(args)... in the container if and only if there is
+ //! 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.
//!
@@ -578,8 +623,11 @@ 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)
- { return container_detail::force_copy<iterator>
- (m_flat_tree.emplace_hint_unique(container_detail::force<impl_const_iterator>(hint), boost::forward<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
@@ -593,7 +641,7 @@ class flat_map
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<impl_const_iterator>(hint) \
+ (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)
@@ -604,15 +652,18 @@ class flat_map
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Linear to the elements with keys bigger than position
//!
//! <b>Note</b>: Invalidates elements with keys
//! not less than the erased element.
- iterator erase(const_iterator position)
- { return container_detail::force_copy<iterator>(m_flat_tree.erase(container_detail::force<impl_const_iterator>(position))); }
+ iterator erase(const_iterator position)
+ {
+ return container_detail::force_copy<iterator>
+ (m_flat_tree.erase(container_detail::force_copy<impl_const_iterator>(position)));
+ }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
//!
@@ -620,7 +671,7 @@ class flat_map
//!
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_flat_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -632,15 +683,18 @@ class flat_map
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
iterator erase(const_iterator first, const_iterator last)
- { return container_detail::force_copy<iterator>
- (m_flat_tree.erase(container_detail::force<impl_const_iterator>(first), container_detail::force<impl_const_iterator>(last))); }
+ {
+ return container_detail::force_copy<iterator>(
+ m_flat_tree.erase( container_detail::force_copy<impl_const_iterator>(first)
+ , container_detail::force_copy<impl_const_iterator>(last)));
+ }
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_flat_tree.clear(); }
//! <b>Effects</b>: Tries to deallocate the excess of memory created
@@ -656,81 +710,81 @@ class flat_map
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator find(const key_type& x)
+ 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
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.s
- const_iterator find(const key_type& x) const
- { return container_detail::force<const_iterator>(m_flat_tree.find(x)); }
+ const_iterator find(const key_type& x) const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.find(x)); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_flat_tree.find(x) == m_flat_tree.end() ? 0 : 1; }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
- { return container_detail::force<const_iterator>(m_flat_tree.lower_bound(x)); }
+ const_iterator lower_bound(const key_type& x) const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.lower_bound(x)); }
//! <b>Returns</b>: An 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
- iterator upper_bound(const key_type& x)
+ 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
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
- { return container_detail::force<const_iterator>(m_flat_tree.upper_bound(x)); }
+ const_iterator upper_bound(const key_type& x) const
+ { return container_detail::force_copy<const_iterator>(m_flat_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 container_detail::force<std::pair<iterator,iterator> >(m_flat_tree.equal_range(x)); }
+ std::pair<iterator,iterator> equal_range(const key_type& x)
+ { return container_detail::force_copy<std::pair<iterator,iterator> >(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<const_iterator,const_iterator> equal_range(const key_type& x) const
- { return container_detail::force<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
+ 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)); }
//! <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
+ 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)
+ void reserve(size_type count)
{ m_flat_tree.reserve(count); }
/// @cond
@@ -752,7 +806,7 @@ class flat_map
}
return (*i).second;
}
- mapped_type &priv_subscript(BOOST_RV_REF(key_type) mk)
+ mapped_type &priv_subscript(BOOST_RV_REF(key_type) mk)
{
key_type &k = mk;
iterator i = lower_bound(k);
@@ -767,38 +821,38 @@ 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)
+inline bool operator==(const flat_map<Key,T,Pred,A>& x,
+ const flat_map<Key,T,Pred,A>& 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)
+inline bool operator<(const flat_map<Key,T,Pred,A>& x,
+ const flat_map<Key,T,Pred,A>& 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)
+inline bool operator!=(const flat_map<Key,T,Pred,A>& x,
+ const flat_map<Key,T,Pred,A>& 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)
+inline bool operator>(const flat_map<Key,T,Pred,A>& x,
+ const flat_map<Key,T,Pred,A>& 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)
+inline bool operator<=(const flat_map<Key,T,Pred,A>& x,
+ const flat_map<Key,T,Pred,A>& 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)
+inline bool operator>=(const flat_map<Key,T,Pred,A>& x,
+ const flat_map<Key,T,Pred,A>& 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)
+inline void swap(flat_map<Key,T,Pred,A>& x,
+ flat_map<Key,T,Pred,A>& y)
{ x.swap(y); }
/// @cond
@@ -824,21 +878,21 @@ template <class Key, class T, class Pred, class A>
class flat_multimap;
template <class Key, class T, class Pred, class A>
-inline bool operator==(const flat_multimap<Key,T,Pred,A>& x,
+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,
+inline bool operator<(const flat_multimap<Key,T,Pred,A>& x,
const flat_multimap<Key,T,Pred,A>& y);
/// @endcond
-//! A flat_multimap is a kind of associative container that supports equivalent keys
-//! (possibly containing multiple copies of the same key value) and provides for
-//! fast retrieval of values of another type T based on the keys. The flat_multimap
+//! A flat_multimap is a kind of associative container that supports equivalent keys
+//! (possibly containing multiple copies of the same key value) and provides for
+//! fast retrieval of values of another type T based on the keys. The flat_multimap
//! class supports random-access iterators.
-//!
-//! A flat_multimap satisfies all of the requirements of a container and of a reversible
-//! container and of an associative container. For a
+//!
+//! A flat_multimap satisfies all of the requirements of a container and of a reversible
+//! container and of an associative container. For a
//! 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>).
//!
@@ -851,21 +905,21 @@ template <class Key, class T, class Pred = std::less< std::pair< Key, T> >, clas
#else
template <class Key, class T, class Pred, class A>
#endif
-class flat_multimap
+class flat_multimap
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(flat_multimap)
- typedef container_detail::flat_tree<Key,
- std::pair<Key, T>,
- container_detail::select1st< std::pair<Key, T> >,
- Pred,
+ typedef container_detail::flat_tree<Key,
+ std::pair<Key, T>,
+ container_detail::select1st< std::pair<Key, T> >,
+ Pred,
A> 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,
+ 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
<container_detail::pair<Key, T> >::type> impl_tree_t;
impl_tree_t m_flat_tree; // flat tree representing flat_map
@@ -916,16 +970,18 @@ class flat_multimap
typedef A allocator_type;
//Non-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;
//! <b>Effects</b>: Default constructs an empty flat_map.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- flat_multimap()
+ flat_multimap()
: m_flat_tree() {}
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison
//! object and allocator.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit flat_multimap(const Pred& comp,
const allocator_type& a = allocator_type())
@@ -933,174 +989,225 @@ class flat_multimap
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object
//! and allocator, and inserts elements from the range [first ,last ).
- //!
- //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
+ //!
+ //! <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_multimap(InputIterator first, InputIterator last,
const Pred& comp = Pred(),
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))
{ m_flat_tree.insert_equal(first, last); }
- //! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object and
//! allocator, and inserts elements from the ordered range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
- //!
+ //!
//! <b>Complexity</b>: Linear in N.
+ //!
+ //! <b>Note</b>: Non-standard extension.
template <class InputIterator>
flat_multimap(ordered_range_t, InputIterator first, InputIterator last,
const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_flat_tree(ordered_range, first, last, comp, a)
+ : m_flat_tree(ordered_range, first, last, comp, a)
{}
//! <b>Effects</b>: Copy constructs a flat_multimap.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- flat_multimap(const flat_multimap<Key,T,Pred,A>& x)
+ flat_multimap(const flat_multimap& x)
: m_flat_tree(x.m_flat_tree) { }
//! <b>Effects</b>: Move constructs a flat_multimap. Constructs *this using x's resources.
- //!
- //! <b>Complexity</b>: Construct.
- //!
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
//! <b>Postcondition</b>: x is emptied.
- flat_multimap(BOOST_RV_REF(flat_multimap) x)
+ flat_multimap(BOOST_RV_REF(flat_multimap) x)
: m_flat_tree(boost::move(x.m_flat_tree))
{ }
+ //! <b>Effects</b>: Copy constructs a flat_multimap using the specified allocator.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ flat_multimap(const flat_multimap& x, const allocator_type &a)
+ : m_flat_tree(x.m_flat_tree, a)
+ {}
+
+ //! <b>Effects</b>: Move constructs a flat_multimap using the specified allocator.
+ //! Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ flat_multimap(BOOST_RV_REF(flat_multimap) x, const allocator_type &a)
+ : m_flat_tree(boost::move(x.m_flat_tree), a)
+ { }
+
//! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- flat_multimap<Key,T,Pred,A>& operator=(BOOST_COPY_ASSIGN_REF(flat_multimap) x)
+ flat_multimap& operator=(BOOST_COPY_ASSIGN_REF(flat_multimap) x)
{ m_flat_tree = x.m_flat_tree; return *this; }
//! <b>Effects</b>: this->swap(x.get()).
- //!
+ //!
//! <b>Complexity</b>: Constant.
- flat_multimap<Key,T,Pred,A>& operator=(BOOST_RV_REF(flat_multimap) mx)
+ flat_multimap& operator=(BOOST_RV_REF(flat_multimap) 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 container_detail::force<key_compare>(m_flat_tree.key_comp()); }
+ key_compare key_comp() const
+ { return container_detail::force_copy<key_compare>(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 value_compare(container_detail::force<key_compare>(m_flat_tree.key_comp())); }
+ value_compare value_comp() const
+ { return value_compare(container_detail::force_copy<key_compare>(m_flat_tree.key_comp())); }
//! <b>Effects</b>: Returns a copy of the Allocator that
//! was passed to the object's constructor.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
- { return container_detail::force<allocator_type>(m_flat_tree.get_allocator()); }
+ allocator_type get_allocator() const
+ { return container_detail::force_copy<allocator_type>(m_flat_tree.get_allocator()); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return container_detail::force<stored_allocator_type>(m_flat_tree.get_stored_allocator()); }
stored_allocator_type &get_stored_allocator()
{ return container_detail::force<stored_allocator_type>(m_flat_tree.get_stored_allocator()); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ return container_detail::force_copy<iterator>(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 begin() const
- { return container_detail::force<const_iterator>(m_flat_tree.begin()); }
+ const_iterator begin() const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.begin()); }
//! <b>Effects</b>: Returns an iterator to the end of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ return container_detail::force_copy<iterator>(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 end() const
- { return container_detail::force<const_iterator>(m_flat_tree.end()); }
+ const_iterator end() const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.end()); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
- { return container_detail::force<reverse_iterator>(m_flat_tree.rbegin()); }
+ reverse_iterator rbegin()
+ { return container_detail::force_copy<reverse_iterator>(m_flat_tree.rbegin()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 rbegin() const
- { return container_detail::force<const_reverse_iterator>(m_flat_tree.rbegin()); }
+ const_reverse_iterator rbegin() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.rbegin()); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ reverse_iterator rend()
+ { return container_detail::force_copy<reverse_iterator>(m_flat_tree.rend()); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reverse_iterator rend() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.rend()); }
+
+ //! <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 container_detail::force_copy<const_iterator>(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 container_detail::force_copy<const_iterator>(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.
- reverse_iterator rend()
- { return container_detail::force<reverse_iterator>(m_flat_tree.rend()); }
+ const_reverse_iterator crbegin() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.crbegin()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
- { return container_detail::force<const_reverse_iterator>(m_flat_tree.rend()); }
+ const_reverse_iterator crend() const
+ { return container_detail::force_copy<const_reverse_iterator>(m_flat_tree.crend()); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_flat_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_flat_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_flat_tree.max_size(); }
//! <b>Effects</b>: Swaps the contents of *this and x.
@@ -1112,33 +1219,36 @@ class flat_multimap
{ m_flat_tree.swap(x.m_flat_tree); }
//! <b>Effects</b>: Inserts x and returns the iterator pointing to the
- //! newly inserted element.
+ //! 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)
- { return container_detail::force_copy<iterator>(m_flat_tree.insert_equal(container_detail::force<impl_value_type>(x))); }
+ iterator insert(const value_type& x)
+ {
+ return container_detail::force_copy<iterator>(
+ m_flat_tree.insert_equal(container_detail::force<impl_value_type>(x)));
+ }
- //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
- //! the iterator pointing to the newly inserted element.
+ //! <b>Effects</b>: Inserts a new value move-constructed from 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(BOOST_RV_REF(value_type) x)
+ iterator insert(BOOST_RV_REF(value_type) x)
{ return container_detail::force_copy<iterator>(m_flat_tree.insert_equal(boost::move(x))); }
- //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
- //! the iterator pointing to the newly inserted element.
+ //! <b>Effects</b>: Inserts a new value move-constructed from 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(BOOST_RV_REF(impl_value_type) x)
+ iterator insert(BOOST_RV_REF(impl_value_type) x)
{ return container_detail::force_copy<iterator>(m_flat_tree.insert_equal(boost::move(x))); }
//! <b>Effects</b>: Inserts a copy of x in the container.
@@ -1152,9 +1262,12 @@ class flat_multimap
//! 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, const value_type& x)
- { return container_detail::force_copy<iterator>
- (m_flat_tree.insert_equal(container_detail::force<impl_const_iterator>(position), container_detail::force<impl_value_type>(x))); }
+ iterator insert(const_iterator position, const value_type& x)
+ {
+ return container_detail::force_copy<iterator>
+ (m_flat_tree.insert_equal( container_detail::force_copy<impl_const_iterator>(position)
+ , container_detail::force<impl_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.
@@ -1167,10 +1280,10 @@ class flat_multimap
//! 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)
+ iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
{
return container_detail::force_copy<iterator>
- (m_flat_tree.insert_equal(container_detail::force<impl_const_iterator>(position)
+ (m_flat_tree.insert_equal(container_detail::force_copy<impl_const_iterator>(position)
, boost::move(x)));
}
@@ -1185,10 +1298,10 @@ class flat_multimap
//! 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(impl_value_type) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(impl_value_type) x)
{
return container_detail::force_copy<iterator>(
- m_flat_tree.insert_equal(container_detail::force<impl_const_iterator>(position), boost::move(x)));
+ m_flat_tree.insert_equal(container_detail::force_copy<impl_const_iterator>(position), boost::move(x)));
}
//! <b>Requires</b>: first, last are not iterators into *this.
@@ -1200,14 +1313,30 @@ class flat_multimap
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
template <class InputIterator>
- void insert(InputIterator first, InputIterator last)
+ void insert(InputIterator first, InputIterator last)
{ m_flat_tree.insert_equal(first, last); }
+ //! <b>Requires</b>: first, last are not iterators into *this.
+ //!
+ //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
+ //!
+ //! <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. This
+ //! function is more efficient than the normal range creation for ordered ranges.
+ //!
+ //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
+ //! search time plus N*size() insertion time.
+ //!
+ //! <b>Note</b>: If an element is inserted it might invalidate elements.
+ template <class InputIterator>
+ 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.
+ //! newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic search time plus linear insertion
//! to the elements with bigger keys than x.
@@ -1233,7 +1362,7 @@ class flat_multimap
iterator emplace_hint(const_iterator hint, Args&&... args)
{
return container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_equal
- (container_detail::force<impl_const_iterator>(hint), boost::forward<Args>(args)...));
+ (container_detail::force_copy<impl_const_iterator>(hint), boost::forward<Args>(args)...));
}
#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -1248,7 +1377,7 @@ class flat_multimap
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<impl_const_iterator>(hint) \
+ (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)
@@ -1259,15 +1388,18 @@ class flat_multimap
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Linear to the elements with keys bigger than position
//!
//! <b>Note</b>: Invalidates elements with keys
//! not less than the erased element.
- iterator erase(const_iterator position)
- { return container_detail::force_copy<iterator>(m_flat_tree.erase(container_detail::force<impl_const_iterator>(position))); }
+ iterator erase(const_iterator position)
+ {
+ return container_detail::force_copy<iterator>(
+ m_flat_tree.erase(container_detail::force_copy<impl_const_iterator>(position)));
+ }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
//!
@@ -1275,7 +1407,7 @@ class flat_multimap
//!
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_flat_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -1287,15 +1419,18 @@ class flat_multimap
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
iterator erase(const_iterator first, const_iterator last)
- { return container_detail::force_copy<iterator>
- (m_flat_tree.erase(container_detail::force<impl_const_iterator>(first), container_detail::force<impl_const_iterator>(last))); }
+ {
+ return container_detail::force_copy<iterator>
+ (m_flat_tree.erase( container_detail::force_copy<impl_const_iterator>(first)
+ , container_detail::force_copy<impl_const_iterator>(last)));
+ }
//! <b>Effects</b>: erase(a.begin(),a.end()).
//!
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_flat_tree.clear(); }
//! <b>Effects</b>: Tries to deallocate the excess of memory created
@@ -1318,75 +1453,75 @@ class flat_multimap
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- const_iterator find(const key_type& x) const
- { return container_detail::force<const_iterator>(m_flat_tree.find(x)); }
+ const_iterator find(const key_type& x) const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.find(x)); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_flat_tree.count(x); }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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 less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
- { return container_detail::force<const_iterator>(m_flat_tree.lower_bound(x)); }
+ const_iterator lower_bound(const key_type& x) const
+ { return container_detail::force_copy<const_iterator>(m_flat_tree.lower_bound(x)); }
//! <b>Returns</b>: An 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
- iterator upper_bound(const key_type& x)
+ 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 less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
- { return container_detail::force<const_iterator>(m_flat_tree.upper_bound(x)); }
+ const_iterator upper_bound(const key_type& x) const
+ { return container_detail::force_copy<const_iterator>(m_flat_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)
+ std::pair<iterator,iterator> equal_range(const key_type& x)
{ return container_detail::force_copy<std::pair<iterator,iterator> >(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<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)); }
//! <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
+ 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)
+ void reserve(size_type count)
{ m_flat_tree.reserve(count); }
/// @cond
@@ -1401,37 +1536,37 @@ 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)
+inline bool operator==(const flat_multimap<Key,T,Pred,A>& x,
+ const flat_multimap<Key,T,Pred,A>& 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)
+inline bool operator<(const flat_multimap<Key,T,Pred,A>& x,
+ const flat_multimap<Key,T,Pred,A>& 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)
+inline bool operator!=(const flat_multimap<Key,T,Pred,A>& x,
+ const flat_multimap<Key,T,Pred,A>& 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)
+inline bool operator>(const flat_multimap<Key,T,Pred,A>& x,
+ const flat_multimap<Key,T,Pred,A>& 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)
+inline bool operator<=(const flat_multimap<Key,T,Pred,A>& x,
+ const flat_multimap<Key,T,Pred,A>& 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)
+inline bool operator>=(const flat_multimap<Key,T,Pred,A>& x,
+ const flat_multimap<Key,T,Pred,A>& 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)
+inline void swap(flat_multimap<Key,T,Pred,A>& x, flat_multimap<Key,T,Pred,A>& y)
{ x.swap(y); }
}}
@@ -1448,7 +1583,7 @@ struct has_trivial_destructor_after_move< boost::container::flat_multimap<K, T,
static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value;
};
*/
-} //namespace boost {
+} //namespace boost {
/// @endcond
diff --git a/boost/container/flat_set.hpp b/boost/container/flat_set.hpp
index f36730972e..09c95eb2f5 100644
--- a/boost/container/flat_set.hpp
+++ b/boost/container/flat_set.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -45,31 +45,31 @@ template <class T, class Pred, class A>
class flat_set;
template <class T, class Pred, class A>
-inline bool operator==(const flat_set<T,Pred,A>& x,
+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,
+inline bool operator<(const flat_set<T,Pred,A>& x,
const flat_set<T,Pred,A>& y);
/// @endcond
-//! flat_set is a Sorted Associative Container that stores objects of type Key.
-//! flat_set is a Simple Associative Container, meaning that its value type,
-//! as well as its key type, is Key. It is also a Unique Associative Container,
-//! meaning that no two elements are the same.
-//!
+//! flat_set is a Sorted Associative Container that stores objects of type Key.
+//! flat_set is a Simple Associative Container, meaning that its value type,
+//! as well as its key type, is Key. It is also a Unique Associative Container,
+//! meaning that no two elements are the same.
+//!
//! flat_set is similar to std::set but it's implemented like an ordered vector.
//! This means that inserting a new element into a flat_set invalidates
//! previous iterators and references
//!
-//! Erasing an element of a flat_set invalidates iterators and references
+//! 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> >
#else
template <class T, class Pred, class A>
#endif
-class flat_set
+class flat_set
{
/// @cond
private:
@@ -100,227 +100,245 @@ class flat_set
typedef typename tree_t::allocator_type allocator_type;
typedef typename tree_t::stored_allocator_type stored_allocator_type;
- //! <b>Effects</b>: Defatuls constructs an empty flat_map.
- //!
+ //! <b>Effects</b>: Default constructs an empty flat_set.
+ //!
//! <b>Complexity</b>: Constant.
explicit flat_set()
: m_flat_tree()
{}
- //! <b>Effects</b>: Constructs an empty flat_map using the specified
+ //! <b>Effects</b>: Constructs an empty flat_set using the specified
//! comparison object and allocator.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit flat_set(const Pred& comp,
const allocator_type& a = allocator_type())
: m_flat_tree(comp, a)
{}
- //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
- //!
- //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
+ //!
+ //! <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_set(InputIterator first, InputIterator last,
+ flat_set(InputIterator first, InputIterator last,
const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_flat_tree(comp, a)
+ : m_flat_tree(comp, a)
{ m_flat_tree.insert_unique(first, last); }
- //! <b>Effects</b>: Constructs an empty flat_set using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty flat_set using the specified comparison object and
//! allocator, and inserts elements from the ordered unique range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
//! unique values.
- //!
+ //!
//! <b>Complexity</b>: Linear in N.
+ //!
+ //! <b>Note</b>: Non-standard extension.
template <class InputIterator>
- flat_set(ordered_unique_range_t, InputIterator first, InputIterator last,
+ flat_set(ordered_unique_range_t, InputIterator first, InputIterator last,
const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_flat_tree(ordered_range, first, last, comp, a)
+ : m_flat_tree(ordered_range, first, last, comp, a)
{}
- //! <b>Effects</b>: Copy constructs a map.
- //!
+ //! <b>Effects</b>: Copy constructs a set.
+ //!
//! <b>Complexity</b>: Linear in x.size().
- flat_set(const flat_set<T,Pred,A>& x)
- : m_flat_tree(x.m_flat_tree) {}
+ flat_set(const flat_set& x)
+ : m_flat_tree(x.m_flat_tree)
+ {}
- //! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources.
- //!
- //! <b>Complexity</b>: Construct.
- //!
+ //! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
//! <b>Postcondition</b>: x is emptied.
- flat_set(BOOST_RV_REF(flat_set) mx)
+ flat_set(BOOST_RV_REF(flat_set) mx)
: m_flat_tree(boost::move(mx.m_flat_tree))
{}
+ //! <b>Effects</b>: Copy constructs a set using the specified allocator.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ flat_set(const flat_set& x, const allocator_type &a)
+ : m_flat_tree(x.m_flat_tree, a)
+ {}
+
+ //! <b>Effects</b>: Move constructs a set using the specified allocator.
+ //! Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant if a == mx.get_allocator(), linear otherwise
+ flat_set(BOOST_RV_REF(flat_set) mx, const allocator_type &a)
+ : m_flat_tree(boost::move(mx.m_flat_tree), a)
+ {}
+
//! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- flat_set<T,Pred,A>& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x)
+ flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x)
{ m_flat_tree = x.m_flat_tree; return *this; }
- //! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //! <b>Effects</b>: Makes *this a copy of the previous value of xx.
+ //!
//! <b>Complexity</b>: Linear in x.size().
- flat_set<T,Pred,A>& operator=(BOOST_RV_REF(flat_set) mx)
+ 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
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return m_flat_tree.get_allocator(); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return m_flat_tree.get_stored_allocator(); }
stored_allocator_type &get_stored_allocator()
{ return m_flat_tree.get_stored_allocator(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ 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 begin() const
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ 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 end() const
+ 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
+ const_iterator cend() const
{ return m_flat_tree.cend(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
- { return m_flat_tree.rbegin(); }
+ reverse_iterator rbegin()
+ { return m_flat_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 rbegin() const
- { return m_flat_tree.rbegin(); }
+ const_reverse_iterator rbegin() const
+ { return m_flat_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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_flat_tree.crbegin(); }
+ const_reverse_iterator crbegin() const
+ { return m_flat_tree.crbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend()
{ return m_flat_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
+ const_reverse_iterator rend() const
{ return m_flat_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const
+ const_reverse_iterator crend() const
{ return m_flat_tree.crend(); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_flat_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_flat_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_flat_tree.max_size(); }
//! <b>Effects</b>: Swaps the contents of *this and x.
@@ -331,10 +349,10 @@ class flat_set
void swap(flat_set& x)
{ m_flat_tree.swap(x.m_flat_tree); }
- //! <b>Effects</b>: Inserts x if and only if there is no element in the container
+ //! <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
+ //! <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.
//!
@@ -342,7 +360,7 @@ class flat_set
//! 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)
+ 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)
@@ -357,7 +375,7 @@ class flat_set
//! <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.
//!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! <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.
//!
@@ -365,10 +383,10 @@ class flat_set
//! 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)
+ std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
{ return m_flat_tree.insert_unique(boost::move(x)); }
- //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
+ //! <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.
//!
@@ -379,7 +397,7 @@ class flat_set
//! 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)
+ 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)
@@ -400,12 +418,12 @@ class flat_set
//! 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)
+ iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
{ return m_flat_tree.insert_unique(position, 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
+ //! <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)
@@ -413,16 +431,31 @@ class flat_set
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
template <class InputIterator>
- void insert(InputIterator first, InputIterator last)
+ void insert(InputIterator first, InputIterator last)
{ m_flat_tree.insert_unique(first, last); }
+ //! <b>Requires</b>: first, last are not iterators into *this and
+ //! must be ordered according to the predicate and must be
+ //! unique values.
+ //!
+ //! <b>Effects</b>: inserts each element from the range [first,last) .This function
+ //! is more efficient than the normal range creation for ordered ranges.
+ //!
+ //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
+ //! search time plus N*size() insertion time.
+ //!
+ //! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
+ template <class InputIterator>
+ 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
+ //! 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
+ //! <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.
//!
@@ -435,7 +468,7 @@ class flat_set
{ 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
+ //! 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.
//!
@@ -471,14 +504,14 @@ class flat_set
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Linear to the elements with keys bigger than position
//!
//! <b>Note</b>: Invalidates elements with keys
//! not less than the erased element.
- iterator erase(const_iterator position)
+ iterator erase(const_iterator position)
{ return m_flat_tree.erase(position); }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
@@ -487,7 +520,7 @@ class flat_set
//!
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_flat_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -498,7 +531,7 @@ class flat_set
//!
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
- iterator erase(const_iterator first, const_iterator last)
+ iterator erase(const_iterator first, const_iterator last)
{ return m_flat_tree.erase(first, last); }
//! <b>Effects</b>: erase(a.begin(),a.end()).
@@ -506,7 +539,7 @@ class flat_set
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_flat_tree.clear(); }
//! <b>Effects</b>: Tries to deallocate the excess of memory created
@@ -522,34 +555,34 @@ class flat_set
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator find(const key_type& x)
+ 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
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.s
- const_iterator find(const key_type& x) const
+ const_iterator find(const key_type& x) const
{ return m_flat_tree.find(x); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_flat_tree.find(x) == m_flat_tree.end() ? 0 : 1; }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
+ const_iterator lower_bound(const key_type& x) const
{ return m_flat_tree.lower_bound(x); }
//! <b>Returns</b>: An iterator pointing to the first element with key not less
@@ -563,42 +596,42 @@ class flat_set
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
+ const_iterator upper_bound(const key_type& x) const
{ return m_flat_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<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
+ 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)
+ void reserve(size_type count)
{ m_flat_tree.reserve(count); }
/// @cond
@@ -609,46 +642,46 @@ class flat_set
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)
+ 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)
+ iterator priv_insert(const_iterator p, const T &x)
{ return m_flat_tree.insert_unique(p, 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)
+inline bool operator==(const flat_set<T,Pred,A>& x,
+ const flat_set<T,Pred,A>& 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)
+inline bool operator<(const flat_set<T,Pred,A>& x,
+ const flat_set<T,Pred,A>& 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)
+inline bool operator!=(const flat_set<T,Pred,A>& x,
+ const flat_set<T,Pred,A>& 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)
+inline bool operator>(const flat_set<T,Pred,A>& x,
+ const flat_set<T,Pred,A>& 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)
+inline bool operator<=(const flat_set<T,Pred,A>& x,
+ const flat_set<T,Pred,A>& 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)
+inline bool operator>=(const flat_set<T,Pred,A>& x,
+ const flat_set<T,Pred,A>& 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)
+inline void swap(flat_set<T,Pred,A>& x, flat_set<T,Pred,A>& y)
{ x.swap(y); }
/// @cond
@@ -675,31 +708,31 @@ template <class T, class Pred, class A>
class flat_multiset;
template <class T, class Pred, class A>
-inline bool operator==(const flat_multiset<T,Pred,A>& x,
+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,
+inline bool operator<(const flat_multiset<T,Pred,A>& x,
const flat_multiset<T,Pred,A>& y);
/// @endcond
-//! flat_multiset is a Sorted Associative Container that stores objects of type Key.
-//! flat_multiset is a Simple Associative Container, meaning that its value type,
+//! flat_multiset is a Sorted Associative Container that stores objects of type Key.
+//! flat_multiset is a Simple Associative Container, meaning that its value type,
//! as well as its key type, is Key.
//! flat_Multiset can store multiple copies of the same key value.
-//!
+//!
//! flat_multiset is similar to std::multiset but it's implemented like an ordered vector.
//! This means that inserting a new element into a flat_multiset invalidates
//! previous iterators and references
//!
-//! Erasing an element of a flat_multiset invalidates iterators and references
+//! 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> >
#else
template <class T, class Pred, class A>
#endif
-class flat_multiset
+class flat_multiset
{
/// @cond
private:
@@ -729,8 +762,8 @@ class flat_multiset
typedef typename tree_t::allocator_type allocator_type;
typedef typename tree_t::stored_allocator_type stored_allocator_type;
- //! <b>Effects</b>: Defatuls constructs an empty flat_map.
- //!
+ //! <b>Effects</b>: Default constructs an empty flat_multiset.
+ //!
//! <b>Complexity</b>: Constant.
explicit flat_multiset()
: m_flat_tree()
@@ -744,187 +777,219 @@ class flat_multiset
flat_multiset(InputIterator first, InputIterator last,
const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_flat_tree(comp, a)
+ : m_flat_tree(comp, a)
{ m_flat_tree.insert_equal(first, last); }
- //! <b>Effects</b>: Constructs an empty flat_multiset using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty flat_multiset using the specified comparison object and
//! allocator, and inserts elements from the ordered range [first ,last ). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
- //!
+ //!
//! <b>Complexity</b>: Linear in N.
+ //!
+ //! <b>Note</b>: Non-standard extension.
template <class InputIterator>
flat_multiset(ordered_range_t, InputIterator first, InputIterator last,
const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_flat_tree(ordered_range, first, last, comp, a)
+ : m_flat_tree(ordered_range, first, last, comp, a)
{}
- flat_multiset(const flat_multiset<T,Pred,A>& x)
- : m_flat_tree(x.m_flat_tree) {}
+ //! <b>Effects</b>: Copy constructs a flat_multiset.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ flat_multiset(const flat_multiset& x)
+ : m_flat_tree(x.m_flat_tree)
+ {}
+
+ //! <b>Effects</b>: Move constructs a flat_multiset. Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Postcondition</b>: x is emptied.
+ flat_multiset(BOOST_RV_REF(flat_multiset) mx)
+ : m_flat_tree(boost::move(mx.m_flat_tree))
+ {}
+
+ //! <b>Effects</b>: Copy constructs a flat_multiset using the specified allocator.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ flat_multiset(const flat_multiset& x, const allocator_type &a)
+ : m_flat_tree(x.m_flat_tree, a)
+ {}
- flat_multiset(BOOST_RV_REF(flat_multiset) x)
- : m_flat_tree(boost::move(x.m_flat_tree))
+ //! <b>Effects</b>: Move constructs a flat_multiset using the specified allocator.
+ //! Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant if a == mx.get_allocator(), linear otherwise
+ flat_multiset(BOOST_RV_REF(flat_multiset) mx, const allocator_type &a)
+ : m_flat_tree(boost::move(mx.m_flat_tree), a)
{}
- flat_multiset<T,Pred,A>& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x)
+ //! <b>Effects</b>: Makes *this a copy of x.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x)
{ m_flat_tree = x.m_flat_tree; return *this; }
- flat_multiset<T,Pred,A>& operator=(BOOST_RV_REF(flat_multiset) mx)
+ //! <b>Effects</b>: Makes *this a copy of x.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ 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
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return m_flat_tree.get_allocator(); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return m_flat_tree.get_stored_allocator(); }
stored_allocator_type &get_stored_allocator()
{ return m_flat_tree.get_stored_allocator(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ 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 begin() const
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ 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 end() const
+ 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
+ const_iterator cend() const
{ return m_flat_tree.cend(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
- { return m_flat_tree.rbegin(); }
+ reverse_iterator rbegin()
+ { return m_flat_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 rbegin() const
- { return m_flat_tree.rbegin(); }
+ const_reverse_iterator rbegin() const
+ { return m_flat_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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_flat_tree.crbegin(); }
+ const_reverse_iterator crbegin() const
+ { return m_flat_tree.crbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend()
{ return m_flat_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
+ const_reverse_iterator rend() const
{ return m_flat_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const
+ const_reverse_iterator crend() const
{ return m_flat_tree.crend(); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_flat_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_flat_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_flat_tree.max_size(); }
//! <b>Effects</b>: Swaps the contents of *this and x.
@@ -936,13 +1001,13 @@ class flat_multiset
{ m_flat_tree.swap(x.m_flat_tree); }
//! <b>Effects</b>: Inserts x and returns the iterator pointing to the
- //! newly inserted element.
+ //! 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)
+ iterator insert(insert_const_ref_type x)
{ return priv_insert(x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -955,13 +1020,13 @@ class flat_multiset
#endif
//! <b>Effects</b>: Inserts a new value_type move constructed from x
- //! and returns the iterator pointing to the newly inserted element.
+ //! 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(BOOST_RV_REF(value_type) x)
+ iterator insert(BOOST_RV_REF(value_type) x)
{ return m_flat_tree.insert_equal(boost::move(x)); }
//! <b>Effects</b>: Inserts a copy of x in the container.
@@ -974,7 +1039,7 @@ class flat_multiset
//! 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)
+ 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)
@@ -997,7 +1062,7 @@ class flat_multiset
//! 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)
+ iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
{ return m_flat_tree.insert_equal(position, boost::move(x)); }
//! <b>Requires</b>: first, last are not iterators into *this.
@@ -1009,14 +1074,28 @@ class flat_multiset
//!
//! <b>Note</b>: If an element is inserted it might invalidate elements.
template <class InputIterator>
- void insert(InputIterator first, InputIterator last)
+ void insert(InputIterator first, InputIterator last)
{ m_flat_tree.insert_equal(first, last); }
+ //! <b>Requires</b>: first, last are not iterators into *this and
+ //! must be ordered according to the predicate.
+ //!
+ //! <b>Effects</b>: inserts each element from the range [first,last) .This function
+ //! is more efficient than the normal range creation for ordered ranges.
+ //!
+ //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
+ //! search time plus N*size() insertion time.
+ //!
+ //! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
+ template <class InputIterator>
+ 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.
+ //! newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic search time plus linear insertion
//! to the elements with bigger keys than x.
@@ -1062,14 +1141,14 @@ class flat_multiset
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Linear to the elements with keys bigger than position
//!
//! <b>Note</b>: Invalidates elements with keys
//! not less than the erased element.
- iterator erase(const_iterator position)
+ iterator erase(const_iterator position)
{ return m_flat_tree.erase(position); }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
@@ -1078,7 +1157,7 @@ class flat_multiset
//!
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_flat_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -1089,7 +1168,7 @@ class flat_multiset
//!
//! <b>Complexity</b>: Logarithmic search time plus erasure time
//! linear to the elements with bigger keys.
- iterator erase(const_iterator first, const_iterator last)
+ iterator erase(const_iterator first, const_iterator last)
{ return m_flat_tree.erase(first, last); }
//! <b>Effects</b>: erase(a.begin(),a.end()).
@@ -1097,7 +1176,7 @@ class flat_multiset
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_flat_tree.clear(); }
//! <b>Effects</b>: Tries to deallocate the excess of memory created
@@ -1113,34 +1192,34 @@ class flat_multiset
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator find(const key_type& x)
+ 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
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.s
- const_iterator find(const key_type& x) const
+ const_iterator find(const key_type& x) const
{ return m_flat_tree.find(x); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_flat_tree.count(x); }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
+ const_iterator lower_bound(const key_type& x) const
{ return m_flat_tree.lower_bound(x); }
//! <b>Returns</b>: An iterator pointing to the first element with key not less
@@ -1154,42 +1233,42 @@ class flat_multiset
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
+ const_iterator upper_bound(const key_type& x) const
{ return m_flat_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<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
+ 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)
+ void reserve(size_type count)
{ m_flat_tree.reserve(count); }
/// @cond
@@ -1200,46 +1279,46 @@ class flat_multiset
friend bool operator< (const flat_multiset<K1,C1,A1>&,
const flat_multiset<K1,C1,A1>&);
private:
- iterator priv_insert(const T &x)
+ iterator priv_insert(const T &x)
{ return m_flat_tree.insert_equal(x); }
- iterator priv_insert(const_iterator p, const T &x)
+ iterator priv_insert(const_iterator p, const T &x)
{ return m_flat_tree.insert_equal(p, 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)
+inline bool operator==(const flat_multiset<T,Pred,A>& x,
+ const flat_multiset<T,Pred,A>& 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)
+inline bool operator<(const flat_multiset<T,Pred,A>& x,
+ const flat_multiset<T,Pred,A>& 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)
+inline bool operator!=(const flat_multiset<T,Pred,A>& x,
+ const flat_multiset<T,Pred,A>& 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)
+inline bool operator>(const flat_multiset<T,Pred,A>& x,
+ const flat_multiset<T,Pred,A>& 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)
+inline bool operator<=(const flat_multiset<T,Pred,A>& x,
+ const flat_multiset<T,Pred,A>& 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)
+inline bool operator>=(const flat_multiset<T,Pred,A>& x,
+ const flat_multiset<T,Pred,A>& 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)
+inline void swap(flat_multiset<T,Pred,A>& x, flat_multiset<T,Pred,A>& y)
{ x.swap(y); }
/// @cond
diff --git a/boost/container/list.hpp b/boost/container/list.hpp
index 6df999bb51..c3e3562988 100644
--- a/boost/container/list.hpp
+++ b/boost/container/list.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -32,7 +32,7 @@
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
#else
//Preprocessor library to emulate perfect forwarding
-#include <boost/container/detail/preprocessor.hpp>
+#include <boost/container/detail/preprocessor.hpp>
#endif
#include <stdexcept>
@@ -65,30 +65,11 @@ template <class T, class VoidPointer>
struct list_node
: public list_hook<VoidPointer>::type
{
+ private:
+ list_node();
- list_node()
- : m_data()
- {}
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- template<class ...Args>
- list_node(Args &&...args)
- : m_data(boost::forward<Args>(args)...)
- {}
-
- #else //#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
- #define BOOST_PP_LOCAL_MACRO(n) \
- template<BOOST_PP_ENUM_PARAMS(n, class P)> \
- list_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- : m_data(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \
- {} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif//#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
-
+ public:
+ typedef typename list_hook<VoidPointer>::type hook_type;
T m_data;
};
@@ -117,26 +98,26 @@ struct intrusive_list_type
/// @endcond
//! A list is a doubly linked list. That is, it is a Sequence that supports both
-//! forward and backward traversal, and (amortized) constant time insertion and
-//! removal of elements at the beginning or the end, or in the middle. Lists have
-//! the important property that insertion and splicing do not invalidate iterators
-//! to list elements, and that even removal invalidates only the iterators that point
-//! to the elements that are removed. The ordering of iterators may be changed
-//! (that is, list<T>::iterator might have a different predecessor or successor
-//! after a list operation than it did before), but the iterators themselves will
-//! not be invalidated or made to point to different elements unless that invalidation
+//! forward and backward traversal, and (amortized) constant time insertion and
+//! removal of elements at the beginning or the end, or in the middle. Lists have
+//! the important property that insertion and splicing do not invalidate iterators
+//! to list elements, and that even removal invalidates only the iterators that point
+//! to the elements that are removed. The ordering of iterators may be changed
+//! (that is, list<T>::iterator might have a different predecessor or successor
+//! after a list operation than it did before), but the iterators themselves will
+//! 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> >
#else
template <class T, class A>
#endif
-class list
+class list
: protected container_detail::node_alloc_holder
<A, typename container_detail::intrusive_list_type<A>::type>
{
/// @cond
- typedef typename
+ typedef typename
container_detail::intrusive_list_type<A>::type Icont;
typedef list <T, A> ThisType;
typedef container_detail::node_alloc_holder<A, Icont> AllocHolder;
@@ -211,11 +192,11 @@ class list
/// @endcond
public:
- //! Const iterator used to iterate through a list.
+ //! Const iterator used to iterate through a list.
class const_iterator
/// @cond
- : public std::iterator<std::bidirectional_iterator_tag,
- value_type, list_difference_type,
+ : public std::iterator<std::bidirectional_iterator_tag,
+ value_type, list_difference_type,
list_const_pointer, list_const_reference>
{
@@ -239,17 +220,17 @@ class list
{}
//Pointer like operators
- const_reference operator*() const
+ const_reference operator*() const
{ return m_it->m_data; }
- const_pointer operator->() const
+ const_pointer operator->() const
{ return const_pointer(&m_it->m_data); }
//Increment / Decrement
- const_iterator& operator++()
+ const_iterator& operator++()
{ prot_incr(); return *this; }
- const_iterator operator++(int)
+ const_iterator operator++(int)
{ typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp); }
const_iterator& operator--()
@@ -278,7 +259,7 @@ class list
explicit iterator(typename Icont::iterator it)
: const_iterator(it)
{}
-
+
typename Icont::iterator get()
{ return this->m_it; }
@@ -295,12 +276,12 @@ class list
pointer operator->() const { return pointer(&this->m_it->m_data); }
//Increment / Decrement
- iterator& operator++()
+ iterator& operator++()
{ this->prot_incr(); return *this; }
iterator operator++(int)
{ typename Icont::iterator tmp = this->m_it; ++*this; return iterator(tmp); }
-
+
iterator& operator--()
{ this->prot_decr(); return *this; }
@@ -309,24 +290,24 @@ class list
};
/// @endcond
- //! Iterator used to iterate backwards through a list.
+ //! Iterator used to iterate backwards through a list.
typedef std::reverse_iterator<iterator> reverse_iterator;
- //! Const iterator used to iterate backwards through a list.
+ //! Const iterator used to iterate backwards through a list.
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
//! <b>Effects</b>: Default constructs a list.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- list()
+ list()
: AllocHolder()
{}
//! <b>Effects</b>: Constructs a list taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit list(const allocator_type &a)
: AllocHolder(a)
@@ -337,7 +318,7 @@ class list
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
explicit list(size_type n)
: AllocHolder(A())
@@ -348,7 +329,7 @@ class list
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! 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())
: AllocHolder(a)
@@ -357,23 +338,51 @@ class list
//! <b>Effects</b>: Copy constructs a list.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
- list(const list& x)
+ list(const list& x)
: AllocHolder(x)
{ this->insert(this->cbegin(), x.begin(), x.end()); }
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
list(BOOST_RV_REF(list) x)
: AllocHolder(boost::move(static_cast<AllocHolder&>(x)))
{}
+ //! <b>Effects</b>: Copy constructs a list using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ list(const list& x, const allocator_type &a)
+ : AllocHolder(a)
+ { this->insert(this->cbegin(), x.begin(), x.end()); }
+
+ //! <b>Effects</b>: Move constructor sing the specified allocator.
+ //! Moves mx's resources to *this.
+ //!
+ //! <b>Throws</b>: If allocation or value_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ list(BOOST_RV_REF(list) x, const allocator_type &a)
+ : AllocHolder(a)
+ {
+ if(this->node_alloc() == x.node_alloc()){
+ this->icont().swap(x.icont());
+ }
+ else{
+ this->insert(this->cbegin(), x.begin(), x.end());
+ }
+ }
+
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the list.
//!
@@ -396,14 +405,14 @@ class list
{} //AllocHolder clears the list
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
allocator_type get_allocator() const
{ return allocator_type(this->node_alloc()); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return this->node_alloc(); }
stored_allocator_type &get_stored_allocator()
@@ -418,129 +427,129 @@ class list
{ AllocHolder::clear(alloc_version()); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator begin()
{ return iterator(this->icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator begin() const
{ return this->cbegin(); }
//! <b>Effects</b>: Returns an iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end()
{ return iterator(this->icont().end()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator end() const
{ return this->cend(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed list.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rbegin()
{ return reverse_iterator(end()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed list.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rbegin() const
{ return this->crbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed list.
- //!
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend()
{ return reverse_iterator(begin()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed list.
- //!
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rend() const
{ return this->crend(); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbegin() const
{ return const_iterator(this->non_const_icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cend() const
{ return const_iterator(this->non_const_icont().end()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed list.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crbegin() const
{ return const_reverse_iterator(this->cend()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed list.
- //!
+ //! of the reversed list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crend() const
{ return const_reverse_iterator(this->cbegin()); }
//! <b>Effects</b>: Returns true if the list contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return !this->size(); }
//! <b>Effects</b>: Returns the number of the elements contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return this->icont().size(); }
//! <b>Effects</b>: Returns the largest possible size of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return AllocHolder::max_size(); }
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -588,7 +597,7 @@ class list
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Amortized constant time.
- void pop_front()
+ void pop_front()
{ this->erase(this->cbegin()); }
//! <b>Effects</b>: Removes the last element from the list.
@@ -596,51 +605,51 @@ class list
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Amortized constant time.
- void pop_back()
+ void pop_back()
{ const_iterator tmp = this->cend(); this->erase(--tmp); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a reference to the first element
+ //! <b>Effects</b>: Returns a reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reference front()
+ reference front()
{ return *this->begin(); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a const reference to the first element
+ //! <b>Effects</b>: Returns a const reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reference front() const
+ const_reference front() const
{ return *this->begin(); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a reference to the first element
+ //! <b>Effects</b>: Returns a reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reference back()
+ reference back()
{ return *(--this->end()); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a const reference to the first element
+ //! <b>Effects</b>: Returns a const reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reference back() const
+ const_reference back() const
{ return *(--this->end()); }
//! <b>Effects</b>: Inserts or erases elements at the end such that
@@ -653,7 +662,7 @@ class list
{
const_iterator iend = this->cend();
size_type len = this->size();
-
+
if(len > new_size){
size_type to_erase = len - new_size;
while(to_erase--){
@@ -676,7 +685,7 @@ class list
{
const_iterator iend = this->end();
size_type len = this->size();
-
+
if(len > new_size){
size_type to_erase = len - new_size;
const_iterator ifirst;
@@ -710,8 +719,8 @@ class list
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
@@ -782,7 +791,7 @@ class list
//!
//! <b>Complexity</b>: Linear to std::distance [first, last).
template <class InpIt>
- void insert(const_iterator p, InpIt first, InpIt last)
+ void insert(const_iterator p, InpIt first, InpIt last)
{
const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
typedef container_detail::bool_<aux_boolean> Result;
@@ -891,7 +900,7 @@ class list
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Amortized constant time.
- iterator erase(const_iterator p)
+ iterator erase(const_iterator p)
{ return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc()))); }
//! <b>Requires</b>: first and last must be valid iterator to elements in *this.
@@ -909,7 +918,7 @@ class list
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
- void assign(size_type n, const T& val)
+ void assign(size_type n, const T& val)
{ this->priv_fill_assign(n, val); }
//! <b>Effects</b>: Assigns the the range [first, last) to *this.
@@ -919,7 +928,7 @@ class list
//!
//! <b>Complexity</b>: Linear to n.
template <class InpIt>
- void assign(InpIt first, InpIt last)
+ void assign(InpIt first, InpIt last)
{
const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
typedef container_detail::bool_<aux_boolean> Result;
@@ -936,7 +945,7 @@ class list
//! are not equal.
//!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of
//! this list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType& x) BOOST_CONTAINER_NOEXCEPT
@@ -947,16 +956,16 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. i must point to an element contained in list x.
- //!
- //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //! If p == i or p == ++i, this function is a null operation.
- //!
+ //! If p == i or p == ++i, this function is a null operation.
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
@@ -967,15 +976,15 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
- //!
- //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //!
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Linear to the number of elements transferred.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
@@ -987,15 +996,15 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
//! n == std::distance(first, last)
- //!
- //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //!
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, ThisType &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
@@ -1004,22 +1013,22 @@ class list
this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
}
- //! <b>Effects</b>: Reverses the order of elements in the list.
- //!
+ //! <b>Effects</b>: Reverses the order of elements in the list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time.
- //!
+ //!
//! <b>Note</b>: Iterators and references are not invalidated
void reverse()
- { this->icont().reverse(); }
+ { this->icont().reverse(); }
//! <b>Effects</b>: Removes all the elements that compare equal to value.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
void remove(const T& value)
@@ -1027,11 +1036,11 @@ class list
//! <b>Effects</b>: Removes all the elements for which a specified
//! predicate is satisfied.
- //!
+ //!
//! <b>Throws</b>: If pred throws.
- //!
+ //!
//! <b>Complexity</b>: Linear time. It performs exactly size() calls to the predicate.
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
template <class Pred>
@@ -1041,25 +1050,25 @@ class list
this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc()));
}
- //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
+ //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
//! elements that are equal from the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Linear time (size()-1 comparisons calls to pred()).
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
void unique()
{ this->unique(value_equal()); }
- //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
+ //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
//! elements that satisfy some binary predicate from the list.
- //!
+ //!
//! <b>Throws</b>: If pred throws.
- //!
+ //!
//! <b>Complexity</b>: Linear time (size()-1 comparisons equality comparisons).
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
template <class BinaryPredicate>
@@ -1069,15 +1078,15 @@ class list
this->icont().unique_and_dispose(Predicate(binary_pred), Destroyer(this->node_alloc()));
}
- //! <b>Requires</b>: The lists x and *this must be distinct.
+ //! <b>Requires</b>: The lists x and *this must be distinct.
//!
//! <b>Effects</b>: This function removes all of x's elements and inserts them
- //! in order into *this according to std::less<value_type>. The merge is stable;
- //! that is, if an element from *this is equivalent to one from x, then the element
- //! from *this will precede the one from x.
- //!
+ //! in order into *this according to std::less<value_type>. The merge is stable;
+ //! that is, if an element from *this is equivalent to one from x, then the element
+ //! from *this will precede the one from x.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time: it performs at most
//! size() + x.size() - 1 comparisons.
void merge(list<T, A>& x)
@@ -1085,17 +1094,17 @@ class list
//! <b>Requires</b>: p must be a comparison function that induces a strict weak
//! ordering and both *this and x must be sorted according to that ordering
- //! The lists x and *this must be distinct.
- //!
+ //! The lists x and *this must be distinct.
+ //!
//! <b>Effects</b>: This function removes all of x's elements and inserts them
- //! in order into *this. The merge is stable; that is, if an element from *this is
- //! equivalent to one from x, then the element from *this will precede the one from x.
- //!
+ //! in order into *this. The merge is stable; that is, if an element from *this is
+ //! equivalent to one from x, then the element from *this will precede the one from x.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time: it performs at most
//! size() + x.size() - 1 comparisons.
- //!
+ //!
//! <b>Note</b>: Iterators and references to *this are not invalidated.
template <class StrictWeakOrdering>
void merge(list &x, StrictWeakOrdering comp)
@@ -1109,25 +1118,25 @@ class list
}
}
- //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
+ //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
//! The sort is stable, that is, the relative order of equivalent elements is preserved.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Notes</b>: Iterators and references are not invalidated.
- //!
+ //!
//! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
//! is the list's size.
void sort()
{ this->sort(value_less()); }
- //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
+ //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
//! The sort is stable, that is, the relative order of equivalent elements is preserved.
- //!
+ //!
//! <b>Throws</b>: Nothing.
//!
//! <b>Notes</b>: Iterators and references are not invalidated.
- //!
+ //!
//! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
//! is the list's size.
template <class StrictWeakOrdering>
@@ -1142,25 +1151,25 @@ class list
/// @cond
private:
- iterator priv_insert(const_iterator p, const T &x)
+ iterator priv_insert(const_iterator p, const T &x)
{
NodePtr tmp = AllocHolder::create_node(x);
return iterator(this->icont().insert(p.get(), *tmp));
}
- iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
+ iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
{
NodePtr tmp = AllocHolder::create_node(boost::move(x));
return iterator(this->icont().insert(p.get(), *tmp));
}
- void priv_push_back (const T &x)
+ void priv_push_back (const T &x)
{ this->insert(this->cend(), x); }
void priv_push_back (BOOST_RV_REF(T) x)
{ this->insert(this->cend(), boost::move(x)); }
- void priv_push_front (const T &x)
+ void priv_push_front (const T &x)
{ this->insert(this->cbegin(), x); }
void priv_push_front (BOOST_RV_REF(T) x)
@@ -1242,10 +1251,10 @@ class list
{ this->priv_create_and_insert_nodes(p, first, last); }
template<class Integer>
- void priv_insert_dispatch(const_iterator p, Integer n, Integer x, container_detail::true_)
+ void priv_insert_dispatch(const_iterator p, Integer n, Integer x, container_detail::true_)
{ this->insert(p, (size_type)n, x); }
- void priv_fill_assign(size_type n, const T& val)
+ void priv_fill_assign(size_type n, const T& val)
{
iterator i = this->begin(), iend = this->end();
@@ -1319,25 +1328,25 @@ inline bool operator<(const list<T,A>& x,
}
template <class T, class A>
-inline bool operator!=(const list<T,A>& x, const list<T,A>& y)
+inline bool operator!=(const list<T,A>& x, const list<T,A>& y)
{
return !(x == y);
}
template <class T, class A>
-inline bool operator>(const list<T,A>& x, const list<T,A>& y)
+inline bool operator>(const list<T,A>& x, const list<T,A>& y)
{
return y < x;
}
template <class T, class A>
-inline bool operator<=(const list<T,A>& x, const list<T,A>& y)
+inline bool operator<=(const list<T,A>& x, const list<T,A>& y)
{
return !(y < x);
}
template <class T, class A>
-inline bool operator>=(const list<T,A>& x, const list<T,A>& y)
+inline bool operator>=(const list<T,A>& x, const list<T,A>& y)
{
return !(x < y);
}
diff --git a/boost/container/map.hpp b/boost/container/map.hpp
index 8f7ecd42b3..91cbd35429 100644
--- a/boost/container/map.hpp
+++ b/boost/container/map.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -47,20 +47,20 @@ namespace container {
/// @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,
+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,
+inline bool operator<(const map<Key,T,Pred,A>& x,
const map<Key,T,Pred,A>& y);
/// @endcond
-//! A map is a kind of associative container that supports unique keys (contains at
-//! most one of each key value) and provides for fast retrieval of values of another
+//! A map is a kind of associative container that supports unique keys (contains at
+//! most one of each key value) and provides for fast retrieval of values of another
//! type T based on the keys. The map class supports bidirectional iterators.
-//!
-//! A map satisfies all of the requirements of a container and of a reversible
-//! container and of an associative container. For a
+//!
+//! A map satisfies all of the requirements of a container and of a reversible
+//! 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>).
@@ -72,15 +72,15 @@ template <class Key, class T, class Pred = std::less< std::pair< const Key, T> >
#else
template <class Key, class T, class Pred, class A>
#endif
-class map
+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,
+ 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
@@ -112,7 +112,7 @@ class map
/// @cond
class value_compare_impl
: public Pred,
- public std::binary_function<value_type, value_type, bool>
+ public std::binary_function<value_type, value_type, bool>
{
friend class map<Key,T,Pred,A>;
protected :
@@ -126,7 +126,7 @@ class map
typedef value_compare_impl value_compare;
//! <b>Effects</b>: Default constructs an empty map.
- //!
+ //!
//! <b>Complexity</b>: Constant.
map()
: m_tree()
@@ -135,9 +135,9 @@ class map
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
}
- //! <b>Effects</b>: Constructs an empty map using the specified comparison object
+ //! <b>Effects</b>: Constructs an empty map using the specified comparison object
//! and allocator.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit map(const Pred& comp,
const allocator_type& a = allocator_type())
@@ -147,204 +147,261 @@ class map
BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
}
- //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
- //!
- //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
+ //!
+ //! <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(),
const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, true)
+ : m_tree(first, last, comp, a, true)
{
//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 A::value_type>::value));
}
- //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
//! allocator, and inserts elements from the ordered unique range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
//! unique values.
- //!
+ //!
//! <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())
- : m_tree(ordered_range, first, last, comp, a)
+ : 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 A::value_type>::value));
}
//! <b>Effects</b>: Copy constructs a map.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- map(const map<Key,T,Pred,A>& x)
+ map(const map& x)
: 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 A::value_type>::value));
}
//! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources.
- //!
- //! <b>Complexity</b>: Construct.
- //!
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
//! <b>Postcondition</b>: x is emptied.
- map(BOOST_RV_REF(map) x)
+ map(BOOST_RV_REF(map) x)
: 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 A::value_type>::value));
+ }
+
+ //! <b>Effects</b>: Copy constructs a map using the specified allocator.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ map(const map& x, const allocator_type &a)
+ : 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));
+ }
+
+ //! <b>Effects</b>: Move constructs a map using the specified allocator.
+ //! Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant if x == x.get_allocator(), linear otherwise.
+ //!
+ //! <b>Postcondition</b>: x is emptied.
+ map(BOOST_RV_REF(map) x, const allocator_type &a)
+ : 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));
}
//! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
map& operator=(BOOST_COPY_ASSIGN_REF(map) x)
{ m_tree = x.m_tree; return *this; }
//! <b>Effects</b>: this->swap(x.get()).
- //!
+ //!
//! <b>Complexity</b>: Constant.
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
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return m_tree.get_allocator(); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return m_tree.get_stored_allocator(); }
stored_allocator_type &get_stored_allocator()
{ return m_tree.get_stored_allocator(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ return m_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 begin() const
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ return m_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 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 end() const
+ const_iterator cend() const
{ return m_tree.end(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
+ reverse_iterator rbegin()
{ return m_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 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 rbegin() const
+ const_reverse_iterator crbegin() const
{ return m_tree.rbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend()
+ reverse_iterator rend()
{ return m_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reverse_iterator rend() const
+ { return this->crend(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
+ const_reverse_iterator crend() const
{ return m_tree.rend(); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_tree.max_size(); }
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! Effects: If there is no key equivalent to x in the map, inserts
+ //! 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.
- //!
+ //!
//! Complexity: Logarithmic.
mapped_type& operator[](const key_type &k);
- //! Effects: If there is no key equivalent to x in the map, inserts
+ //! 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.
- //!
+ //!
//! Complexity: Logarithmic.
mapped_type& operator[](key_type &&k);
#else
@@ -383,62 +440,62 @@ class map
void swap(map& x)
{ m_tree.swap(x.m_tree); }
- //! <b>Effects</b>: Inserts x if and only if there is no element in the container
+ //! <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
+ //! <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)
+ std::pair<iterator,bool> insert(const value_type& x)
{ return m_tree.insert_unique(x); }
- //! <b>Effects</b>: Inserts a new value_type created from the pair if and only if
+ //! <b>Effects</b>: Inserts a new value_type created from the pair 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
+ //! <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 nonconst_value_type& x)
+ std::pair<iterator,bool> insert(const nonconst_value_type& x)
{ return m_tree.insert_unique(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.
//!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! <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(nonconst_value_type) x)
+ std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_value_type) x)
{ return m_tree.insert_unique(boost::move(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.
//!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! <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(nonconst_impl_value_type) x)
+ std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_impl_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
+ //! <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
+ //! <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)
+ 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
+ //! <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.
//!
@@ -450,7 +507,7 @@ class map
iterator insert(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
+ //! <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.
//! p is a hint pointing to where the insert should start to search.
//!
@@ -462,7 +519,7 @@ class map
iterator insert(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
+ //! <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.
//! p is a hint pointing to where the insert should start to search.
//!
@@ -494,22 +551,22 @@ class map
//! <b>Requires</b>: first, last are not iterators into *this.
//!
- //! <b>Effects</b>: inserts each element from the range [first,last) if and only
+ //! <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)
+ void insert(InputIterator first, InputIterator last)
{ m_tree.insert_unique(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)... in the container if and only if there is
+ //! std::forward<Args>(args)... in the container if and only if there is
//! no element in the container with an equivalent key.
//! p is a hint pointing to where the insert should start to search.
//!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! <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.
//!
@@ -520,7 +577,7 @@ class map
{ return m_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
+ //! std::forward<Args>(args)... in the container if and only if there is
//! no element in the container with an equivalent key.
//! p is a hint pointing to where the insert should start to search.
//!
@@ -554,11 +611,11 @@ class map
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Amortized constant time
- iterator erase(const_iterator position)
+ iterator erase(const_iterator position)
{ return m_tree.erase(position); }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
@@ -566,7 +623,7 @@ class map
//! <b>Returns</b>: Returns the number of erased elements.
//!
//! <b>Complexity</b>: log(size()) + count(k)
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -582,67 +639,67 @@ class map
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_tree.clear(); }
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator find(const key_type& x)
+ iterator find(const key_type& x)
{ return m_tree.find(x); }
//! <b>Returns</b>: A 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.
- const_iterator find(const key_type& x) const
+ const_iterator find(const key_type& x) const
{ return m_tree.find(x); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_tree.find(x) == m_tree.end() ? 0 : 1; }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
+ const_iterator lower_bound(const key_type& x) const
{ return m_tree.lower_bound(x); }
//! <b>Returns</b>: An 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
- iterator upper_bound(const key_type& x)
+ 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
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
+ const_iterator upper_bound(const key_type& x) const
{ 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)
+ 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
@@ -666,7 +723,7 @@ class map
return (*i).second;
}
- mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk)
+ mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk)
{
key_type &k = mk;
//we can optimize this
@@ -684,37 +741,37 @@ class map
};
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)
+inline bool operator==(const map<Key,T,Pred,A>& x,
+ const map<Key,T,Pred,A>& 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)
+inline bool operator<(const map<Key,T,Pred,A>& x,
+ const map<Key,T,Pred,A>& 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)
+inline bool operator!=(const map<Key,T,Pred,A>& x,
+ const map<Key,T,Pred,A>& 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)
+inline bool operator>(const map<Key,T,Pred,A>& x,
+ const map<Key,T,Pred,A>& 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)
+inline bool operator<=(const map<Key,T,Pred,A>& x,
+ const map<Key,T,Pred,A>& 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)
+inline bool operator>=(const map<Key,T,Pred,A>& x,
+ const map<Key,T,Pred,A>& 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)
+inline void swap(map<Key,T,Pred,A>& x, map<Key,T,Pred,A>& y)
{ x.swap(y); }
/// @cond
@@ -722,11 +779,11 @@ inline void swap(map<Key,T,Pred,A>& x, map<Key,T,Pred,A>& y)
// 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,
+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,
+inline bool operator<(const multimap<Key,T,Pred,A>& x,
const multimap<Key,T,Pred,A>& y);
} //namespace container {
@@ -743,14 +800,14 @@ namespace container {
/// @endcond
-//! A multimap is a kind of associative container that supports equivalent keys
-//! (possibly containing multiple copies of the same key value) and provides for
+//! A multimap is a kind of associative container that supports equivalent keys
+//! (possibly containing multiple copies of the same key value) and provides for
//! fast retrieval of values of another type T based on the keys. The multimap class
//! supports bidirectional iterators.
-//!
-//! A multimap satisfies all of the requirements of a container and of a reversible
-//! 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>.
+//!
+//! A multimap satisfies all of the requirements of a container and of a reversible
+//! 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>).
//!
@@ -761,15 +818,15 @@ template <class Key, class T, class Pred = std::less< std::pair< const Key, T> >
#else
template <class Key, class T, class Pred, class A>
#endif
-class multimap
+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,
+ 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 typename container_detail::
@@ -802,7 +859,7 @@ class multimap
/// @cond
class value_compare_impl
: public Pred,
- public std::binary_function<value_type, value_type, bool>
+ public std::binary_function<value_type, value_type, bool>
{
friend class multimap<Key,T,Pred,A>;
protected :
@@ -816,7 +873,7 @@ class multimap
typedef value_compare_impl value_compare;
//! <b>Effects</b>: Default constructs an empty multimap.
- //!
+ //!
//! <b>Complexity</b>: Constant.
multimap()
: m_tree()
@@ -827,195 +884,250 @@ class multimap
//! <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())
: 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 A::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 ).
- //!
- //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
+ //!
+ //! <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>
multimap(InputIterator first, InputIterator last,
const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, false)
+ : m_tree(first, last, comp, a, false)
{
//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 A::value_type>::value));
}
- //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
//! allocator, and inserts elements from the ordered range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
- //!
+ //!
//! <b>Complexity</b>: Linear in N.
template <class InputIterator>
multimap(ordered_range_t ordered_range, InputIterator first, InputIterator last, const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_tree(ordered_range, first, last, comp, a)
+ : m_tree(ordered_range, first, last, comp, a)
{}
-
//! <b>Effects</b>: Copy constructs a multimap.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- multimap(const multimap<Key,T,Pred,A>& x)
+ multimap(const multimap& x)
: 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 A::value_type>::value));
}
//! <b>Effects</b>: Move constructs a multimap. Constructs *this using x's resources.
- //!
- //! <b>Complexity</b>: Construct.
- //!
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
//! <b>Postcondition</b>: x is emptied.
- multimap(BOOST_RV_REF(multimap) x)
+ multimap(BOOST_RV_REF(multimap) x)
: 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 A::value_type>::value));
+ }
+
+ //! <b>Effects</b>: Copy constructs a multimap.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ multimap(const multimap& x, const allocator_type &a)
+ : 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));
+ }
+
+ //! <b>Effects</b>: Move constructs a multimap using the specified allocator.
+ //! Constructs *this using x's resources.
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ //!
+ //! <b>Postcondition</b>: x is emptied.
+ multimap(BOOST_RV_REF(multimap) x, const allocator_type &a)
+ : 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));
}
//! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x)
+ multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x)
{ m_tree = x.m_tree; return *this; }
//! <b>Effects</b>: this->swap(x.get()).
- //!
+ //!
//! <b>Complexity</b>: Constant.
- multimap& operator=(BOOST_RV_REF(multimap) x)
+ 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
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return m_tree.get_allocator(); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return m_tree.get_stored_allocator(); }
stored_allocator_type &get_stored_allocator()
{ return m_tree.get_stored_allocator(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ return m_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 begin() const
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ return m_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 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 end() const
+ const_iterator cend() const
{ return m_tree.end(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
+ reverse_iterator rbegin()
{ return m_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 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 rbegin() const
+ const_reverse_iterator crbegin() const
{ return m_tree.rbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend()
+ reverse_iterator rend()
{ return m_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reverse_iterator rend() const
+ { return this->crend(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
+ const_reverse_iterator crend() const
{ return m_tree.rend(); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_tree.max_size(); }
//! <b>Effects</b>: Swaps the contents of *this and x.
@@ -1027,31 +1139,31 @@ class multimap
{ m_tree.swap(x.m_tree); }
//! <b>Effects</b>: Inserts x and returns the iterator pointing to the
- //! newly inserted element.
+ //! newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(const value_type& x)
+ iterator insert(const value_type& x)
{ return m_tree.insert_equal(x); }
- //! <b>Effects</b>: Inserts a new value constructed from x and returns
- //! the iterator pointing to the newly inserted element.
+ //! <b>Effects</b>: Inserts a new value constructed from x and returns
+ //! the iterator pointing to the newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(const nonconst_value_type& x)
+ iterator insert(const nonconst_value_type& x)
{ return m_tree.insert_equal(x); }
- //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
- //! the iterator pointing to the newly inserted element.
+ //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
+ //! the iterator pointing to the newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(BOOST_RV_REF(nonconst_value_type) x)
+ iterator insert(BOOST_RV_REF(nonconst_value_type) x)
{ return m_tree.insert_equal(boost::move(x)); }
- //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
- //! the iterator pointing to the newly inserted element.
+ //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
+ //! 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(nonconst_impl_value_type) x)
{ return m_tree.insert_equal(boost::move(x)); }
//! <b>Effects</b>: Inserts a copy of x in the container.
@@ -1104,7 +1216,7 @@ class multimap
//!
//! <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)
+ void insert(InputIterator first, InputIterator last)
{ m_tree.insert_equal(first, last); }
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1156,11 +1268,11 @@ class multimap
//! <b>Effects</b>: Erases the element pointed to by position.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Amortized constant time
- iterator erase(const_iterator position)
+ iterator erase(const_iterator position)
{ return m_tree.erase(position); }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
@@ -1168,7 +1280,7 @@ class multimap
//! <b>Returns</b>: Returns the number of erased elements.
//!
//! <b>Complexity</b>: log(size()) + count(k)
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -1184,68 +1296,68 @@ class multimap
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_tree.clear(); }
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator find(const key_type& x)
+ iterator find(const key_type& x)
{ return m_tree.find(x); }
//! <b>Returns</b>: A 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.
- const_iterator find(const key_type& x) const
+ const_iterator find(const key_type& x) const
{ return m_tree.find(x); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_tree.count(x); }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
+ const_iterator lower_bound(const key_type& x) const
{ return m_tree.lower_bound(x); }
//! <b>Returns</b>: An 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
- iterator upper_bound(const key_type& x)
+ 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)
+ 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
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
+ const_iterator upper_bound(const key_type& x) const
{ 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<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
@@ -1260,37 +1372,37 @@ class multimap
};
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)
+inline bool operator==(const multimap<Key,T,Pred,A>& x,
+ const multimap<Key,T,Pred,A>& 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)
+inline bool operator<(const multimap<Key,T,Pred,A>& x,
+ const multimap<Key,T,Pred,A>& 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)
+inline bool operator!=(const multimap<Key,T,Pred,A>& x,
+ const multimap<Key,T,Pred,A>& 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)
+inline bool operator>(const multimap<Key,T,Pred,A>& x,
+ const multimap<Key,T,Pred,A>& 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)
+inline bool operator<=(const multimap<Key,T,Pred,A>& x,
+ const multimap<Key,T,Pred,A>& 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)
+inline bool operator>=(const multimap<Key,T,Pred,A>& x,
+ const multimap<Key,T,Pred,A>& 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)
+inline void swap(multimap<Key,T,Pred,A>& x, multimap<Key,T,Pred,A>& y)
{ x.swap(y); }
/// @cond
diff --git a/boost/container/scoped_allocator.hpp b/boost/container/scoped_allocator.hpp
new file mode 100644
index 0000000000..7da71bdf81
--- /dev/null
+++ b/boost/container/scoped_allocator.hpp
@@ -0,0 +1,1466 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Pablo Halpern 2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
+#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
+
+#if (defined MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/container/detail/config_begin.hpp>
+#include <boost/container/detail/workaround.hpp>
+#include <boost/container/scoped_allocator_fwd.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/container/allocator_traits.hpp>
+#include <boost/container/detail/type_traits.hpp>
+#include <boost/container/detail/utilities.hpp>
+#include <utility>
+#include <boost/container/detail/pair.hpp>
+#include <boost/move/move.hpp>
+
+
+namespace boost { namespace container {
+
+//! <b>Remark</b>: if a specialization is derived from true_type, indicates that T may be constructed
+//! with an allocator as its last constructor argument. Ideally, all constructors of T (including the
+//! copy and move constructors) should have a variant that accepts a final argument of
+//! allocator_type.
+//!
+//! <b>Requires</b>: if a specialization is derived from true_type, T must have a nested type,
+//! allocator_type and at least one constructor for which allocator_type is the last
+//! parameter. If not all constructors of T can be called with a final allocator_type argument,
+//! and if T is used in a context where a container must call such a constructor, then the program is
+//! ill-formed.
+//!
+//! [Example:
+//! template <class T, class A = allocator<T> >
+//! class Z {
+//! public:
+//! typedef A allocator_type;
+//!
+//! // Default constructor with optional allocator suffix
+//! Z(const allocator_type& a = allocator_type());
+//!
+//! // Copy constructor and allocator-extended copy constructor
+//! Z(const Z& zz);
+//! Z(const Z& zz, const allocator_type& a);
+//! };
+//!
+//! // Specialize trait for class template Z
+//! template <class T, class A = allocator<T> >
+//! struct constructible_with_allocator_suffix<Z<T,A> >
+//! : ::boost::true_type { };
+//! -- end example]
+//!
+//! <b>Note</b>: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)"
+//! (Pablo Halpern, 2008-02-29) to backport the scoped allocator model to C++03, as
+//! in C++03 there is no mechanism to detect if a type can be constructed from arbitrary arguments.
+//! Applications aiming portability with several compilers should always define this trait.
+//!
+//! In conforming C++11 compilers or compilers supporting SFINAE expressions
+//! (when BOOST_NO_SFINAE_EXPR is NOT defined), this trait is ignored and C++11 rules will be used
+//! to detect if a type should be constructed with suffix or prefix allocator arguments.
+template <class T>
+struct constructible_with_allocator_suffix
+ : ::boost::false_type
+{};
+
+//! <b>Remark</b>: if a specialization is derived from true_type, indicates that T may be constructed
+//! with allocator_arg and T::allocator_type as its first two constructor arguments.
+//! Ideally, all constructors of T (including the copy and move constructors) should have a variant
+//! that accepts these two initial arguments.
+//!
+//! <b>Requires</b>: if a specialization is derived from true_type, T must have a nested type,
+//! allocator_type and at least one constructor for which allocator_arg_t is the first
+//! parameter and allocator_type is the second parameter. If not all constructors of T can be
+//! called with these initial arguments, and if T is used in a context where a container must call such
+//! a constructor, then the program is ill-formed.
+//!
+//! [Example:
+//! template <class T, class A = allocator<T> >
+//! class Y {
+//! public:
+//! typedef A allocator_type;
+//!
+//! // Default constructor with and allocator-extended default constructor
+//! Y();
+//! Y(allocator_arg_t, const allocator_type& a);
+//!
+//! // Copy constructor and allocator-extended copy constructor
+//! Y(const Y& yy);
+//! Y(allocator_arg_t, const allocator_type& a, const Y& yy);
+//!
+//! // Variadic constructor and allocator-extended variadic constructor
+//! template<class ...Args> Y(Args&& args...);
+//! template<class ...Args>
+//! Y(allocator_arg_t, const allocator_type& a, Args&&... args);
+//! };
+//!
+//! // Specialize trait for class template Y
+//! template <class T, class A = allocator<T> >
+//! struct constructible_with_allocator_prefix<Y<T,A> >
+//! : ::boost::true_type { };
+//!
+//! -- end example]
+//!
+//! <b>Note</b>: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)"
+//! (Pablo Halpern, 2008-02-29) to backport the scoped allocator model to C++03, as
+//! in C++03 there is no mechanism to detect if a type can be constructed from arbitrary arguments.
+//! Applications aiming portability with several compilers should always define this trait.
+//!
+//! In conforming C++11 compilers or compilers supporting SFINAE expressions
+//! (when BOOST_NO_SFINAE_EXPR is NOT defined), this trait is ignored and C++11 rules will be used
+//! to detect if a type should be constructed with suffix or prefix allocator arguments.
+template <class T>
+struct constructible_with_allocator_prefix
+ : ::boost::false_type
+{};
+
+///@cond
+
+namespace container_detail {
+
+template<typename T, typename Alloc>
+struct uses_allocator_imp
+{
+ // Use SFINAE (Substitution Failure Is Not An Error) to detect the
+ // presence of an 'allocator_type' nested type convertilble from Alloc.
+
+ private:
+ // Match this function if TypeT::allocator_type exists and is
+ // implicitly convertible from Alloc
+ template <typename U>
+ static char test(int, typename U::allocator_type);
+
+ // Match this function if TypeT::allocator_type does not exist or is
+ // not convertible from Alloc.
+ template <typename U>
+ static int test(LowPriorityConversion<int>, LowPriorityConversion<Alloc>);
+
+ static Alloc alloc; // Declared but not defined
+
+ public:
+ enum { value = sizeof(test<T>(0, alloc)) == sizeof(char) };
+};
+
+} //namespace container_detail {
+
+///@endcond
+
+//! <b>Remark</b>: Automatically detects if T has a nested allocator_type that is convertible from
+//! Alloc. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may
+//! specialize this type to derive from true_type for a T of user-defined type if T does not
+//! have a nested allocator_type but is nonetheless constructible using the specified Alloc.
+//!
+//! <b>Result</b>: derived from true_type if Convertible<Alloc,T::allocator_type> and
+//! derived from false_type otherwise.
+template <typename T, typename Alloc>
+struct uses_allocator
+ : boost::integral_constant<bool, container_detail::uses_allocator_imp<T, Alloc>::value>
+{};
+
+///@cond
+
+namespace container_detail {
+
+template <typename Alloc>
+struct is_scoped_allocator_imp
+{
+ template <typename T>
+ static char test(int, typename T::outer_allocator_type*);
+
+ template <typename T>
+ static int test(LowPriorityConversion<int>, void*);
+
+ static const bool value = (sizeof(char) == sizeof(test<Alloc>(0, 0)));
+};
+
+template<class MaybeScopedAlloc, bool = is_scoped_allocator_imp<MaybeScopedAlloc>::value >
+struct outermost_allocator_type_impl
+{
+ typedef typename MaybeScopedAlloc::outer_allocator_type outer_type;
+ typedef typename outermost_allocator_type_impl<outer_type>::type type;
+};
+
+template<class MaybeScopedAlloc>
+struct outermost_allocator_type_impl<MaybeScopedAlloc, false>
+{
+ typedef MaybeScopedAlloc type;
+};
+
+template<class MaybeScopedAlloc, bool = is_scoped_allocator_imp<MaybeScopedAlloc>::value >
+struct outermost_allocator_imp
+{
+ typedef MaybeScopedAlloc type;
+
+ static type &get(MaybeScopedAlloc &a)
+ { return a; }
+
+ static const type &get(const MaybeScopedAlloc &a)
+ { return a; }
+};
+
+template<class MaybeScopedAlloc>
+struct outermost_allocator_imp<MaybeScopedAlloc, true>
+{
+ typedef typename MaybeScopedAlloc::outer_allocator_type outer_type;
+ typedef typename outermost_allocator_type_impl<outer_type>::type type;
+
+ static type &get(MaybeScopedAlloc &a)
+ { return outermost_allocator_imp<outer_type>::get(a.outer_allocator()); }
+
+ static const type &get(const MaybeScopedAlloc &a)
+ { return outermost_allocator_imp<outer_type>::get(a.outer_allocator()); }
+};
+
+} //namespace container_detail {
+
+template <typename Alloc>
+struct is_scoped_allocator
+ : boost::integral_constant<bool, container_detail::is_scoped_allocator_imp<Alloc>::value>
+{};
+
+template <typename Alloc>
+struct outermost_allocator
+ : container_detail::outermost_allocator_imp<Alloc>
+{};
+
+template <typename Alloc>
+typename container_detail::outermost_allocator_imp<Alloc>::type &
+ get_outermost_allocator(Alloc &a)
+{ return container_detail::outermost_allocator_imp<Alloc>::get(a); }
+
+template <typename Alloc>
+const typename container_detail::outermost_allocator_imp<Alloc>::type &
+ get_outermost_allocator(const Alloc &a)
+{ return container_detail::outermost_allocator_imp<Alloc>::get(a); }
+
+namespace container_detail {
+
+// Check if we can detect is_convertible using advanced SFINAE expressions
+#if !defined(BOOST_NO_SFINAE_EXPR)
+
+ //! Code inspired by Mathias Gaunard's is_convertible.cpp found in the Boost mailing list
+ //! http://boost.2283326.n4.nabble.com/type-traits-is-constructible-when-decltype-is-supported-td3575452.html
+ //! Thanks Mathias!
+
+ //With variadic templates, we need a single class to implement the trait
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+ template<class T, class ...Args>
+ struct is_constructible_impl
+ {
+ typedef char yes_type;
+ struct no_type
+ { char padding[2]; };
+
+ template<std::size_t N>
+ struct dummy;
+
+ template<class X>
+ static yes_type test(dummy<sizeof(X(boost::move_detail::declval<Args>()...))>*);
+
+ template<class X>
+ static no_type test(...);
+
+ static const bool value = sizeof(test<T>(0)) == sizeof(yes_type);
+ };
+
+ template<class T, class ...Args>
+ struct is_constructible
+ : boost::integral_constant<bool, is_constructible_impl<T, Args...>::value>
+ {};
+
+ template <class T, class InnerAlloc, class ...Args>
+ struct is_constructible_with_allocator_prefix
+ : is_constructible<T, allocator_arg_t, InnerAlloc, Args...>
+ {};
+
+ #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+ //Without variadic templates, we need to use de preprocessor to generate
+ //some specializations.
+
+ #define BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS \
+ BOOST_PP_ADD(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, 3)
+ //!
+
+ //Generate N+1 template parameters so that we can specialize N
+ template<class T
+ BOOST_PP_ENUM_TRAILING( BOOST_PP_ADD(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 1)
+ , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT
+ , void)
+ >
+ struct is_constructible_impl;
+
+ //Generate N specializations, from 0 to
+ //BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS parameters
+ #define BOOST_PP_LOCAL_MACRO(n) \
+ template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> \
+ struct is_constructible_impl \
+ <T BOOST_PP_ENUM_TRAILING_PARAMS(n, P) \
+ BOOST_PP_ENUM_TRAILING \
+ ( BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, n) \
+ , BOOST_CONTAINER_PP_IDENTITY, void) \
+ , void> \
+ { \
+ typedef char yes_type; \
+ struct no_type \
+ { char padding[2]; }; \
+ \
+ template<std::size_t N> \
+ struct dummy; \
+ \
+ template<class X> \
+ static yes_type test(dummy<sizeof(X(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_DECLVAL, ~)))>*); \
+ \
+ template<class X> \
+ static no_type test(...); \
+ \
+ static const bool value = sizeof(test<T>(0)) == sizeof(yes_type); \
+ }; \
+ //!
+
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+
+ //Finally just inherit from the implementation to define he trait
+ template< class T
+ BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS
+ , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT
+ , void)
+ >
+ struct is_constructible
+ : boost::integral_constant
+ < bool
+ , is_constructible_impl
+ < T
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, P)
+ , void>::value
+ >
+ {};
+
+ //Finally just inherit from the implementation to define he trait
+ template <class T
+ ,class InnerAlloc
+ BOOST_PP_ENUM_TRAILING( BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 2)
+ , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT
+ , void)
+ >
+ struct is_constructible_with_allocator_prefix
+ : is_constructible
+ < T, allocator_arg_t, InnerAlloc
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 2), P)
+ >
+ {};
+/*
+ template <class T
+ ,class InnerAlloc
+ BOOST_PP_ENUM_TRAILING( BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 1)
+ , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT
+ , void)
+ >
+ struct is_constructible_with_allocator_suffix
+ : is_constructible
+ < T
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 1), P)
+ , InnerAlloc
+ >
+ {};*/
+
+ #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+#else // #if !defined(BOOST_NO_SFINAE_EXPR)
+
+ //Without advanced SFINAE expressions, we can't use is_constructible
+ //so backup to constructible_with_allocator_xxx
+
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+ template < class T, class InnerAlloc, class ...Args>
+ struct is_constructible_with_allocator_prefix
+ : constructible_with_allocator_prefix<T>
+ {};
+/*
+ template < class T, class InnerAlloc, class ...Args>
+ struct is_constructible_with_allocator_suffix
+ : constructible_with_allocator_suffix<T>
+ {};*/
+
+ #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+ template < class T
+ , class InnerAlloc
+ BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT
+ , void)
+ >
+ struct is_constructible_with_allocator_prefix
+ : constructible_with_allocator_prefix<T>
+ {};
+/*
+ template < class T
+ , class InnerAlloc
+ BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT
+ , void)
+ >
+ struct is_constructible_with_allocator_suffix
+ : constructible_with_allocator_suffix<T>
+ {};*/
+
+ #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+#endif // #if !defined(BOOST_NO_SFINAE_EXPR)
+
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+template < typename OutermostAlloc
+ , typename InnerAlloc
+ , typename T
+ , class ...Args
+ >
+inline void dispatch_allocator_prefix_suffix
+ ( boost::true_type use_alloc_prefix, OutermostAlloc& outermost_alloc
+ , InnerAlloc& inner_alloc, T* p, BOOST_FWD_REF(Args) ...args)
+{
+ (void)use_alloc_prefix;
+ allocator_traits<OutermostAlloc>::construct
+ ( outermost_alloc, p, allocator_arg, inner_alloc, ::boost::forward<Args>(args)...);
+}
+
+template < typename OutermostAlloc
+ , typename InnerAlloc
+ , typename T
+ , class ...Args
+ >
+inline void dispatch_allocator_prefix_suffix
+ ( boost::false_type use_alloc_prefix, OutermostAlloc& outermost_alloc
+ , InnerAlloc &inner_alloc, T* p, BOOST_FWD_REF(Args)...args)
+{
+ (void)use_alloc_prefix;
+ allocator_traits<OutermostAlloc>::construct
+ (outermost_alloc, p, ::boost::forward<Args>(args)..., inner_alloc);
+}
+
+template < typename OutermostAlloc
+ , typename InnerAlloc
+ , typename T
+ , class ...Args
+ >
+inline void dispatch_uses_allocator
+ ( boost::true_type uses_allocator, OutermostAlloc& outermost_alloc
+ , InnerAlloc& inner_alloc, T* p, BOOST_FWD_REF(Args)...args)
+{
+ (void)uses_allocator;
+ //BOOST_STATIC_ASSERT((is_constructible_with_allocator_prefix<T, InnerAlloc, Args...>::value ||
+ // is_constructible_with_allocator_suffix<T, InnerAlloc, Args...>::value ));
+ dispatch_allocator_prefix_suffix
+ ( is_constructible_with_allocator_prefix<T, InnerAlloc, Args...>()
+ , outermost_alloc, inner_alloc, p, ::boost::forward<Args>(args)...);
+}
+
+template < typename OutermostAlloc
+ , typename InnerAlloc
+ , typename T
+ , class ...Args
+ >
+inline void dispatch_uses_allocator
+ ( boost::false_type uses_allocator, OutermostAlloc & outermost_alloc
+ , InnerAlloc & inner_alloc
+ ,T* p, BOOST_FWD_REF(Args)...args)
+{
+ (void)uses_allocator; (void)inner_alloc;
+ allocator_traits<OutermostAlloc>::construct
+ (outermost_alloc, p, ::boost::forward<Args>(args)...);
+}
+
+#else //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+#define BOOST_PP_LOCAL_MACRO(n) \
+template < typename OutermostAlloc \
+ , typename InnerAlloc \
+ , typename T \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \
+ > \
+inline void dispatch_allocator_prefix_suffix( \
+ boost::true_type use_alloc_prefix, \
+ OutermostAlloc& outermost_alloc, \
+ InnerAlloc& inner_alloc, \
+ T* p \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+{ \
+ (void)use_alloc_prefix, \
+ allocator_traits<OutermostAlloc>::construct \
+ (outermost_alloc, p, allocator_arg, inner_alloc \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
+} \
+ \
+template < typename OutermostAlloc \
+ , typename InnerAlloc \
+ , typename T \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \
+ > \
+inline void dispatch_allocator_prefix_suffix( \
+ boost::false_type use_alloc_prefix, \
+ OutermostAlloc& outermost_alloc, \
+ InnerAlloc& inner_alloc, \
+ T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+{ \
+ (void)use_alloc_prefix; \
+ allocator_traits<OutermostAlloc>::construct \
+ (outermost_alloc, p \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \
+ , inner_alloc); \
+} \
+ \
+template < typename OutermostAlloc \
+ , typename InnerAlloc \
+ , typename T \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \
+ > \
+inline void dispatch_uses_allocator(boost::true_type uses_allocator, \
+ OutermostAlloc& outermost_alloc, \
+ InnerAlloc& inner_alloc, \
+ T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+{ \
+ (void)uses_allocator; \
+ dispatch_allocator_prefix_suffix \
+ (is_constructible_with_allocator_prefix \
+ < T, InnerAlloc BOOST_PP_ENUM_TRAILING_PARAMS(n, P)>() \
+ , outermost_alloc, inner_alloc, p \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
+} \
+ \
+template < typename OutermostAlloc \
+ , typename InnerAlloc \
+ , typename T \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \
+ > \
+inline void dispatch_uses_allocator(boost::false_type uses_allocator \
+ ,OutermostAlloc & outermost_alloc \
+ ,InnerAlloc & inner_alloc \
+ ,T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+{ \
+ (void)uses_allocator; (void)inner_alloc; \
+ allocator_traits<OutermostAlloc>::construct \
+ (outermost_alloc, p 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 //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+template <typename OuterAlloc, class ...InnerAllocs>
+class scoped_allocator_adaptor_base
+ : public OuterAlloc
+{
+ typedef allocator_traits<OuterAlloc> outer_traits_type;
+ BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base)
+
+ public:
+ template <class OuterA2>
+ struct rebind_base
+ {
+ typedef scoped_allocator_adaptor_base<OuterA2, InnerAllocs...> other;
+ };
+
+ typedef OuterAlloc outer_allocator_type;
+ typedef scoped_allocator_adaptor<InnerAllocs...> inner_allocator_type;
+ typedef boost::integral_constant<
+ bool,
+ outer_traits_type::propagate_on_container_copy_assignment::value ||
+ inner_allocator_type::propagate_on_container_copy_assignment::value
+ > propagate_on_container_copy_assignment;
+ typedef boost::integral_constant<
+ bool,
+ outer_traits_type::propagate_on_container_move_assignment::value ||
+ inner_allocator_type::propagate_on_container_move_assignment::value
+ > propagate_on_container_move_assignment;
+ typedef boost::integral_constant<
+ bool,
+ outer_traits_type::propagate_on_container_swap::value ||
+ inner_allocator_type::propagate_on_container_swap::value
+ > propagate_on_container_swap;
+
+ scoped_allocator_adaptor_base()
+ {}
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs &...args)
+ : outer_allocator_type(::boost::forward<OuterA2>(outerAlloc))
+ , m_inner(args...)
+ {}
+
+ scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other)
+ : outer_allocator_type(other.outer_allocator())
+ , m_inner(other.inner_allocator())
+ {}
+
+ scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other)
+ : outer_allocator_type(::boost::move(other.outer_allocator()))
+ , m_inner(::boost::move(other.inner_allocator()))
+ {}
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base
+ (const scoped_allocator_adaptor_base<OuterA2, InnerAllocs...>& other)
+ : outer_allocator_type(other.outer_allocator())
+ , m_inner(other.inner_allocator())
+ {}
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base
+ (BOOST_RV_REF_BEG scoped_allocator_adaptor_base
+ <OuterA2, InnerAllocs...> BOOST_RV_REF_END other)
+ : outer_allocator_type(other.outer_allocator())
+ , m_inner(other.inner_allocator())
+ {}
+
+ protected:
+ struct internal_type_t{};
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base
+ ( internal_type_t
+ , BOOST_FWD_REF(OuterA2) outerAlloc
+ , const inner_allocator_type &inner)
+ : outer_allocator_type(::boost::forward<OuterA2>(outerAlloc))
+ , m_inner(inner)
+ {}
+
+ public:
+
+ scoped_allocator_adaptor_base &operator=
+ (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other)
+ {
+ outer_allocator_type::operator=(other.outer_allocator());
+ m_inner = other.inner_allocator();
+ return *this;
+ }
+
+ scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other)
+ {
+ outer_allocator_type::operator=(boost::move(other.outer_allocator()));
+ m_inner = ::boost::move(other.inner_allocator());
+ return *this;
+ }
+
+ inner_allocator_type& inner_allocator()
+ { return m_inner; }
+
+ inner_allocator_type const& inner_allocator() const
+ { return m_inner; }
+
+ outer_allocator_type & outer_allocator()
+ { return static_cast<outer_allocator_type&>(*this); }
+
+ const outer_allocator_type &outer_allocator() const
+ { return static_cast<const outer_allocator_type&>(*this); }
+
+ private:
+ inner_allocator_type m_inner;
+};
+
+#else //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+//Let's add a dummy first template parameter to allow creating
+//specializations up to maximum InnerAlloc count
+template <
+ typename OuterAlloc
+ , bool Dummy
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, class Q)
+ >
+class scoped_allocator_adaptor_base;
+
+//Specializations for the adaptor with InnerAlloc allocators
+
+#define BOOST_PP_LOCAL_MACRO(n) \
+template <typename OuterAlloc \
+BOOST_PP_ENUM_TRAILING_PARAMS(n, class Q) \
+> \
+class scoped_allocator_adaptor_base<OuterAlloc, true \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, Q) \
+ BOOST_PP_ENUM_TRAILING( BOOST_PP_SUB(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, n) \
+ , BOOST_CONTAINER_PP_IDENTITY, nat) \
+ > \
+ : public OuterAlloc \
+{ \
+ typedef allocator_traits<OuterAlloc> outer_traits_type; \
+ BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base) \
+ \
+ public: \
+ template <class OuterA2> \
+ struct rebind_base \
+ { \
+ typedef scoped_allocator_adaptor_base<OuterA2, true BOOST_PP_ENUM_TRAILING_PARAMS(n, Q) \
+ BOOST_PP_ENUM_TRAILING \
+ ( BOOST_PP_SUB(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, n) \
+ , BOOST_CONTAINER_PP_IDENTITY, nat) \
+ > other; \
+ }; \
+ \
+ typedef OuterAlloc outer_allocator_type; \
+ typedef scoped_allocator_adaptor<BOOST_PP_ENUM_PARAMS(n, Q) \
+ BOOST_PP_ENUM_TRAILING \
+ ( BOOST_PP_SUB(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, n) \
+ , BOOST_CONTAINER_PP_IDENTITY, nat) \
+ > inner_allocator_type; \
+ typedef boost::integral_constant< \
+ bool, \
+ outer_traits_type::propagate_on_container_copy_assignment::value || \
+ inner_allocator_type::propagate_on_container_copy_assignment::value \
+ > propagate_on_container_copy_assignment; \
+ typedef boost::integral_constant< \
+ bool, \
+ outer_traits_type::propagate_on_container_move_assignment::value || \
+ inner_allocator_type::propagate_on_container_move_assignment::value \
+ > propagate_on_container_move_assignment; \
+ typedef boost::integral_constant< \
+ bool, \
+ outer_traits_type::propagate_on_container_swap::value || \
+ inner_allocator_type::propagate_on_container_swap::value \
+ > propagate_on_container_swap; \
+ \
+ scoped_allocator_adaptor_base() \
+ {} \
+ \
+ template <class OuterA2> \
+ scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q, _)) \
+ : outer_allocator_type(::boost::forward<OuterA2>(outerAlloc)) \
+ , m_inner(BOOST_PP_ENUM_PARAMS(n, q)) \
+ {} \
+ \
+ scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) \
+ : outer_allocator_type(other.outer_allocator()) \
+ , m_inner(other.inner_allocator()) \
+ {} \
+ \
+ scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other) \
+ : outer_allocator_type(::boost::move(other.outer_allocator())) \
+ , m_inner(::boost::move(other.inner_allocator())) \
+ {} \
+ \
+ template <class OuterA2> \
+ scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base<OuterA2, true \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, Q) \
+ BOOST_PP_ENUM_TRAILING \
+ ( BOOST_PP_SUB(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, n) \
+ , BOOST_CONTAINER_PP_IDENTITY, nat) \
+ >& other) \
+ : outer_allocator_type(other.outer_allocator()) \
+ , m_inner(other.inner_allocator()) \
+ {} \
+ \
+ template <class OuterA2> \
+ scoped_allocator_adaptor_base \
+ (BOOST_RV_REF_BEG scoped_allocator_adaptor_base<OuterA2, true \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, Q) \
+ BOOST_PP_ENUM_TRAILING \
+ ( BOOST_PP_SUB(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, n) \
+ , BOOST_CONTAINER_PP_IDENTITY, nat) \
+ > BOOST_RV_REF_END other) \
+ : outer_allocator_type(other.outer_allocator()) \
+ , m_inner(other.inner_allocator()) \
+ {} \
+ \
+ protected: \
+ struct internal_type_t{}; \
+ \
+ template <class OuterA2> \
+ scoped_allocator_adaptor_base \
+ ( internal_type_t \
+ , BOOST_FWD_REF(OuterA2) outerAlloc \
+ , const inner_allocator_type &inner) \
+ : outer_allocator_type(::boost::forward<OuterA2>(outerAlloc)) \
+ , m_inner(inner) \
+ {} \
+ \
+ public: \
+ scoped_allocator_adaptor_base &operator= \
+ (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other) \
+ { \
+ outer_allocator_type::operator=(other.outer_allocator()); \
+ m_inner = other.inner_allocator(); \
+ return *this; \
+ } \
+ \
+ scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other) \
+ { \
+ outer_allocator_type::operator=(boost::move(other.outer_allocator())); \
+ m_inner = ::boost::move(other.inner_allocator()); \
+ return *this; \
+ } \
+ \
+ inner_allocator_type& inner_allocator() \
+ { return m_inner; } \
+ \
+ inner_allocator_type const& inner_allocator() const \
+ { return m_inner; } \
+ \
+ outer_allocator_type & outer_allocator() \
+ { return static_cast<outer_allocator_type&>(*this); } \
+ \
+ const outer_allocator_type &outer_allocator() const \
+ { return static_cast<const outer_allocator_type&>(*this); } \
+ \
+ private: \
+ inner_allocator_type m_inner; \
+}; \
+//!
+#define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+#include BOOST_PP_LOCAL_ITERATE()
+
+#endif //#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+//Specialization for adaptor without any InnerAlloc
+template <typename OuterAlloc>
+class scoped_allocator_adaptor_base
+ < OuterAlloc
+ #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+ , true
+ BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, nat)
+ #endif
+ >
+ : public OuterAlloc
+{
+ BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base)
+ public:
+
+ template <class U>
+ struct rebind_base
+ {
+ typedef scoped_allocator_adaptor_base
+ <typename allocator_traits<OuterAlloc>::template portable_rebind_alloc<U>::type
+ #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+ , true
+ BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat)
+ #endif
+ > other;
+ };
+
+ typedef OuterAlloc outer_allocator_type;
+ typedef allocator_traits<OuterAlloc> outer_traits_type;
+ typedef scoped_allocator_adaptor<OuterAlloc> inner_allocator_type;
+ typedef typename outer_traits_type::
+ propagate_on_container_copy_assignment propagate_on_container_copy_assignment;
+ typedef typename outer_traits_type::
+ propagate_on_container_move_assignment propagate_on_container_move_assignment;
+ typedef typename outer_traits_type::
+ propagate_on_container_swap propagate_on_container_swap;
+
+ scoped_allocator_adaptor_base()
+ {}
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc)
+ : outer_allocator_type(::boost::forward<OuterA2>(outerAlloc))
+ {}
+
+ scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other)
+ : outer_allocator_type(other.outer_allocator())
+ {}
+
+ scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other)
+ : outer_allocator_type(::boost::move(other.outer_allocator()))
+ {}
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base
+ (const scoped_allocator_adaptor_base<
+ OuterA2
+ #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+ , true
+ BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat)
+ #endif
+ >& other)
+ : outer_allocator_type(other.outer_allocator())
+ {}
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base
+ (BOOST_RV_REF_BEG scoped_allocator_adaptor_base<
+ OuterA2
+ #if defined(BOOST_NO_VARIADIC_TEMPLATES)
+ , true
+ BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat)
+ #endif
+ > BOOST_RV_REF_END other)
+ : outer_allocator_type(other.outer_allocator())
+ {}
+
+ protected:
+ struct internal_type_t{};
+
+ template <class OuterA2>
+ scoped_allocator_adaptor_base(internal_type_t, BOOST_FWD_REF(OuterA2) outerAlloc, const inner_allocator_type &)
+ : outer_allocator_type(::boost::forward<OuterA2>(outerAlloc))
+ {}
+
+ public:
+ scoped_allocator_adaptor_base &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other)
+ {
+ outer_allocator_type::operator=(other.outer_allocator());
+ return *this;
+ }
+
+ scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other)
+ {
+ outer_allocator_type::operator=(boost::move(other.outer_allocator()));
+ return *this;
+ }
+
+ inner_allocator_type& inner_allocator()
+ { return static_cast<inner_allocator_type&>(*this); }
+
+ inner_allocator_type const& inner_allocator() const
+ { return static_cast<const inner_allocator_type&>(*this); }
+
+ outer_allocator_type & outer_allocator()
+ { return static_cast<outer_allocator_type&>(*this); }
+
+ const outer_allocator_type &outer_allocator() const
+ { return static_cast<const outer_allocator_type&>(*this); }
+};
+
+} //namespace container_detail {
+
+///@endcond
+
+//Scoped allocator
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+ //! This class is a C++03-compatible implementation of std::scoped_allocator_adaptor.
+ //! The class template scoped_allocator_adaptor is an allocator template that specifies
+ //! the memory resource (the outer allocator) to be used by a container (as any other
+ //! allocator does) and also specifies an inner allocator resource to be passed to
+ //! the constructor of every element within the container.
+ //!
+ //! This adaptor is
+ //! instantiated with one outer and zero or more inner allocator types. If
+ //! instantiated with only one allocator type, the inner allocator becomes the
+ //! scoped_allocator_adaptor itself, thus using the same allocator resource for the
+ //! container and every element within the container and, if the elements themselves
+ //! are containers, each of their elements recursively. If instantiated with more than
+ //! one allocator, the first allocator is the outer allocator for use by the container,
+ //! the second allocator is passed to the constructors of the container's elements,
+ //! and, if the elements themselves are containers, the third allocator is passed to
+ //! the elements' elements, and so on. If containers are nested to a depth greater
+ //! than the number of allocators, the last allocator is used repeatedly, as in the
+ //! single-allocator case, for any remaining recursions.
+ //!
+ //! [<b>Note</b>: The
+ //! scoped_allocator_adaptor is derived from the outer allocator type so it can be
+ //! substituted for the outer allocator type in most expressions. -end note]
+ //!
+ //! In the construct member functions, `OUTERMOST(x)` is x if x does not have
+ //! an `outer_allocator()` member function and
+ //! `OUTERMOST(x.outer_allocator())` otherwise; `OUTERMOST_ALLOC_TRAITS(x)` is
+ //! `allocator_traits<decltype(OUTERMOST(x))>`.
+ //!
+ //! [<b>Note</b>: `OUTERMOST(x)` and
+ //! `OUTERMOST_ALLOC_TRAITS(x)` are recursive operations. It is incumbent upon
+ //! the definition of `outer_allocator()` to ensure that the recursion terminates.
+ //! It will terminate for all instantiations of scoped_allocator_adaptor. -end note]
+ template <typename OuterAlloc, typename ...InnerAllocs>
+ class scoped_allocator_adaptor
+
+ #else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+ template <typename OuterAlloc, typename ...InnerAllocs>
+ class scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>
+
+ #endif // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+#else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+template <typename OuterAlloc
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, class Q)
+ >
+class scoped_allocator_adaptor
+#endif
+ : public container_detail::scoped_allocator_adaptor_base
+ <OuterAlloc
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , InnerAllocs...
+ #else
+ , true BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ >
+{
+ BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor)
+
+ public:
+ /// @cond
+ typedef container_detail::scoped_allocator_adaptor_base
+ <OuterAlloc
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , InnerAllocs...
+ #else
+ , true BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ > base_type;
+ typedef typename base_type::internal_type_t internal_type_t;
+ /// @endcond
+ typedef OuterAlloc outer_allocator_type;
+ //! Type: For exposition only
+ //!
+ typedef allocator_traits<OuterAlloc> outer_traits_type;
+ //! Type: `scoped_allocator_adaptor<OuterAlloc>` if `sizeof...(InnerAllocs)` is zero; otherwise,
+ //! `scoped_allocator_adaptor<InnerAllocs...>`.
+ typedef typename base_type::inner_allocator_type inner_allocator_type;
+ typedef typename outer_traits_type::value_type value_type;
+ typedef typename outer_traits_type::size_type size_type;
+ typedef typename outer_traits_type::difference_type difference_type;
+ typedef typename outer_traits_type::pointer pointer;
+ 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.
+ 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.
+ 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.
+ typedef typename base_type::
+ propagate_on_container_swap propagate_on_container_swap;
+
+ //! Type: Rebinds scoped allocator to
+ //! `typedef scoped_allocator_adaptor
+ //! < typename outer_traits_type::template portable_rebind_alloc<U>::type
+ //! , InnerAllocs... >`
+ template <class U>
+ struct rebind
+ {
+ typedef scoped_allocator_adaptor
+ < typename outer_traits_type::template portable_rebind_alloc<U>::type
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , InnerAllocs...
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ > other;
+ };
+
+ //! <b>Effects</b>: value-initializes the OuterAlloc base class
+ //! and the inner allocator object.
+ scoped_allocator_adaptor()
+ {}
+
+ ~scoped_allocator_adaptor()
+ {}
+
+ //! <b>Effects</b>: initializes each allocator within the adaptor with
+ //! the corresponding allocator from other.
+ scoped_allocator_adaptor(const scoped_allocator_adaptor& other)
+ : base_type(other.base())
+ {}
+
+ //! <b>Effects</b>: move constructs each allocator within the adaptor with
+ //! the corresponding allocator from other.
+ scoped_allocator_adaptor(BOOST_RV_REF(scoped_allocator_adaptor) other)
+ : base_type(::boost::move(other.base()))
+ {}
+
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Requires</b>: OuterAlloc shall be constructible from OuterA2.
+ //!
+ //! <b>Effects</b>: initializes the OuterAlloc base class with boost::forward<OuterA2>(outerAlloc) and inner
+ //! with innerAllocs...(hence recursively initializing each allocator within the adaptor with the
+ //! corresponding allocator from the argument list).
+ template <class OuterA2>
+ scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs & ...innerAllocs)
+ : base_type(::boost::forward<OuterA2>(outerAlloc), innerAllocs...)
+ {}
+ #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ #define BOOST_PP_LOCAL_MACRO(n) \
+ template <class OuterA2> \
+ scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q, _)) \
+ : base_type(::boost::forward<OuterA2>(outerAlloc) \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, q) \
+ ) \
+ {} \
+ //!
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+
+ #endif // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Requires</b>: OuterAlloc shall be constructible from OuterA2.
+ //!
+ //! <b>Effects</b>: initializes each allocator within the adaptor with the corresponding allocator from other.
+ template <class OuterA2>
+ scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , InnerAllocs...
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ > &other)
+ : base_type(other.base())
+ {}
+
+ //! <b>Requires</b>: OuterAlloc shall be constructible from OuterA2.
+ //!
+ //! <b>Effects</b>: initializes each allocator within the adaptor with the corresponding allocator
+ //! rvalue from other.
+ template <class OuterA2>
+ scoped_allocator_adaptor(BOOST_RV_REF_BEG scoped_allocator_adaptor<OuterA2
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , InnerAllocs...
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ > BOOST_RV_REF_END other)
+ : base_type(::boost::move(other.base()))
+ {}
+
+ scoped_allocator_adaptor &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor) other)
+ {
+ base_type::operator=(static_cast<const base_type &>(other));
+ return *this;
+ }
+
+ scoped_allocator_adaptor &operator=(BOOST_RV_REF(scoped_allocator_adaptor) other)
+ {
+ base_type::operator=(boost::move(static_cast<scoped_allocator_adaptor&>(other)));
+ return *this;
+ }
+
+ //! <b>Returns</b>:
+ //! `static_cast<OuterAlloc&>(*this)`.
+ outer_allocator_type & outer_allocator()
+ { return *this; }
+
+ //! <b>Returns</b>:
+ //! `static_cast<const OuterAlloc&>(*this)`.
+ const outer_allocator_type &outer_allocator() const
+ { return *this; }
+
+ //! <b>Returns</b>:
+ //! *this if `sizeof...(InnerAllocs)` is zero; otherwise, inner.
+ inner_allocator_type& inner_allocator()
+ { return base_type::inner_allocator(); }
+
+ //! <b>Returns</b>:
+ //! *this if `sizeof...(InnerAllocs)` is zero; otherwise, inner.
+ inner_allocator_type const& inner_allocator() const
+ { return base_type::inner_allocator(); }
+
+ //! <b>Returns</b>:
+ //! `allocator_traits<OuterAlloc>::max_size(outer_allocator())`.
+ size_type max_size() const
+ {
+ return outer_traits_type::max_size(this->outer_allocator());
+ }
+
+ //! <b>Effects</b>:
+ //! calls `OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p)`.
+ template <class T>
+ void destroy(T* p)
+ {
+ allocator_traits<typename outermost_allocator<OuterAlloc>::type>
+ ::destroy(get_outermost_allocator(this->outer_allocator()), p);
+ }
+
+ //! <b>Returns</b>:
+ //! `allocator_traits<OuterAlloc>::allocate(outer_allocator(), n)`.
+ pointer allocate(size_type n)
+ {
+ return outer_traits_type::allocate(this->outer_allocator(), n);
+ }
+
+ //! <b>Returns</b>:
+ //! `allocator_traits<OuterAlloc>::allocate(outer_allocator(), n, hint)`.
+ pointer allocate(size_type n, const_void_pointer hint)
+ {
+ return outer_traits_type::allocate(this->outer_allocator(), n, hint);
+ }
+
+ //! <b>Effects</b>:
+ //! `allocator_traits<OuterAlloc>::deallocate(outer_allocator(), p, n)`.
+ void deallocate(pointer p, size_type n)
+ {
+ outer_traits_type::deallocate(this->outer_allocator(), p, n);
+ }
+
+ //! <b>Returns</b>: A 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
+ //! the corresponding allocator in *this.
+ scoped_allocator_adaptor select_on_container_copy_construction() const
+ {
+ return scoped_allocator_adaptor
+ (internal_type_t()
+ ,outer_traits_type::select_on_container_copy_construction(this->outer_allocator())
+ ,outer_traits_type::select_on_container_copy_construction(this->inner_allocator())
+ );
+ }
+ /// @cond
+ base_type &base() { return *this; }
+
+ const base_type &base() const { return *this; }
+ /// @endcond
+
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>:
+ //! 1) If `uses_allocator<T, inner_allocator_type>::value` is false calls
+ //! `OUTERMOST_ALLOC_TRAITS(*this)::construct
+ //! (OUTERMOST(*this), p, std::forward<Args>(args)...)`.
+ //!
+ //! 2) Otherwise, if `uses_allocator<T, inner_allocator_type>::value` is true and
+ //! `is_constructible<T, allocator_arg_t, inner_allocator_type, Args...>::value` is true, calls
+ //! `OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, allocator_arg,
+ //! inner_allocator(), std::forward<Args>(args)...)`.
+ //!
+ //! [<b>Note</b>: In compilers without advanced decltype SFINAE support, `is_constructible` can't
+ //! be implemented so that condition will be replaced by
+ //! constructible_with_allocator_prefix<T>::value. -end note]
+ //!
+ //! 3) Otherwise, if uses_allocator<T, inner_allocator_type>::value is true and
+ //! `is_constructible<T, Args..., inner_allocator_type>::value` is true, calls
+ //! `OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p,
+ //! std::forward<Args>(args)..., inner_allocator())`.
+ //!
+ //! [<b>Note</b>: In compilers without advanced decltype SFINAE support, `is_constructible` can't be
+ //! implemented so that condition will be replaced by
+ //! `constructible_with_allocator_suffix<T>::value`. -end note]
+ //!
+ //! 4) Otherwise, the program is ill-formed.
+ //!
+ //! [<b>Note</b>: An error will result if `uses_allocator` evaluates
+ //! to true but the specific constructor does not take an allocator. This definition prevents a silent
+ //! failure to pass an inner allocator to a contained element. -end note]
+ template < typename T, class ...Args>
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ void
+ #else
+ typename container_detail::enable_if_c<!container_detail::is_pair<T>::value, void>::type
+ #endif
+ construct(T* p, BOOST_FWD_REF(Args)...args)
+ {
+ container_detail::dispatch_uses_allocator
+ ( uses_allocator<T, inner_allocator_type>()
+ , get_outermost_allocator(this->outer_allocator())
+ , this->inner_allocator()
+ , p, ::boost::forward<Args>(args)...);
+ }
+
+ #else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //Disable this overload if the first argument is pair as some compilers have
+ //overload selection problems when the first parameter is a pair.
+ #define BOOST_PP_LOCAL_MACRO(n) \
+ template < typename T \
+ BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \
+ > \
+ typename container_detail::enable_if_c<!container_detail::is_pair<T>::value, void>::type \
+ construct(T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { \
+ container_detail::dispatch_uses_allocator \
+ ( uses_allocator<T, inner_allocator_type>() \
+ , get_outermost_allocator(this->outer_allocator()) \
+ , this->inner_allocator() \
+ , p 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 // #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ template <class T1, class T2>
+ void construct(std::pair<T1,T2>* p)
+ { this->construct_pair(p); }
+
+ template <class T1, class T2>
+ void construct(container_detail::pair<T1,T2>* p)
+ { this->construct_pair(p); }
+
+ template <class T1, class T2, class U, class V>
+ void construct(std::pair<T1, T2>* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
+ { this->construct_pair(p, ::boost::forward<U>(x), ::boost::forward<V>(y)); }
+
+ template <class T1, class T2, class U, class V>
+ void construct(container_detail::pair<T1, T2>* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
+ { this->construct_pair(p, ::boost::forward<U>(x), ::boost::forward<V>(y)); }
+
+ template <class T1, class T2, class U, class V>
+ void construct(std::pair<T1, T2>* p, const std::pair<U, V>& x)
+ { this->construct_pair(p, x); }
+
+ template <class T1, class T2, class U, class V>
+ void construct( container_detail::pair<T1, T2>* p
+ , const container_detail::pair<U, V>& x)
+ { this->construct_pair(p, x); }
+
+ template <class T1, class T2, class U, class V>
+ void construct( std::pair<T1, T2>* p
+ , BOOST_RV_REF_BEG std::pair<U, V> BOOST_RV_REF_END x)
+ { this->construct_pair(p, x); }
+
+ template <class T1, class T2, class U, class V>
+ void construct( container_detail::pair<T1, T2>* p
+ , BOOST_RV_REF_BEG container_detail::pair<U, V> BOOST_RV_REF_END x)
+ { this->construct_pair(p, x); }
+
+ /// @cond
+ private:
+ template <class Pair>
+ void construct_pair(Pair* p)
+ {
+ this->construct(container_detail::addressof(p->first));
+ try {
+ this->construct(container_detail::addressof(p->second));
+ }
+ catch (...) {
+ this->destroy(container_detail::addressof(p->first));
+ throw;
+ }
+ }
+
+ template <class Pair, class U, class V>
+ void construct_pair(Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
+ {
+ this->construct(container_detail::addressof(p->first), ::boost::forward<U>(x));
+ try {
+ this->construct(container_detail::addressof(p->second), ::boost::forward<V>(y));
+ }
+ catch (...) {
+ this->destroy(container_detail::addressof(p->first));
+ throw;
+ }
+ }
+
+ template <class Pair, class Pair2>
+ void construct_pair(Pair* p, const Pair2& pr)
+ {
+ this->construct(container_detail::addressof(p->first), pr.first);
+ try {
+ this->construct(container_detail::addressof(p->second), pr.second);
+ }
+ catch (...) {
+ this->destroy(container_detail::addressof(p->first));
+ throw;
+ }
+ }
+
+ template <class Pair, class Pair2>
+ void construct_pair(Pair* p, BOOST_RV_REF(Pair2) pr)
+ {
+ this->construct(container_detail::addressof(p->first), ::boost::move(pr.first));
+ try {
+ this->construct(container_detail::addressof(p->second), ::boost::move(pr.second));
+ }
+ catch (...) {
+ this->destroy(container_detail::addressof(p->first));
+ throw;
+ }
+ }
+
+ //template <class T1, class T2, class... Args1, class... Args2>
+ //void construct(pair<T1, T2>* p, piecewise_construct_t, tuple<Args1...> x, tuple<Args2...> y);
+
+ private:
+ template <class OuterA2>
+ scoped_allocator_adaptor(internal_type_t, BOOST_FWD_REF(OuterA2) outer, const inner_allocator_type& inner)
+ : base_type(internal_type_t(), ::boost::forward<OuterA2>(outer), inner)
+ {}
+
+ /// @endcond
+};
+
+template <typename OuterA1, typename OuterA2
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename... InnerAllocs
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, class Q)
+ #endif
+ >
+inline bool operator==(
+ const scoped_allocator_adaptor<OuterA1
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ ,InnerAllocs...
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ >& a,
+ const scoped_allocator_adaptor<OuterA2
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ ,InnerAllocs...
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ >& b)
+{
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ const bool has_zero_inner = sizeof...(InnerAllocs) == 0u;
+ #else
+ const bool has_zero_inner =
+ boost::container::container_detail::is_same
+ <Q0, container_detail::nat>::value;
+ #endif
+
+ return a.outer_allocator() == b.outer_allocator()
+ && (has_zero_inner || a.inner_allocator() == b.inner_allocator());
+}
+
+template <typename OuterA1, typename OuterA2
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename... InnerAllocs
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, class Q)
+ #endif
+ >
+inline bool operator!=(
+ const scoped_allocator_adaptor<OuterA1
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ ,InnerAllocs...
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ >& a,
+ const scoped_allocator_adaptor<OuterA2
+ #if !defined(BOOST_NO_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ ,InnerAllocs...
+ #else
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q)
+ #endif
+ >& b)
+{
+ return ! (a == b);
+}
+
+}} // namespace boost { namespace container {
+
+#include <boost/container/detail/config_end.hpp>
+
+#endif // BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP
diff --git a/boost/container/scoped_allocator_fwd.hpp b/boost/container/scoped_allocator_fwd.hpp
new file mode 100644
index 0000000000..0814a50699
--- /dev/null
+++ b/boost/container/scoped_allocator_fwd.hpp
@@ -0,0 +1,83 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP
+#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP
+
+#if (defined MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/container/detail/config_begin.hpp>
+#include <boost/container/detail/workaround.hpp>
+
+#if defined(BOOST_NO_VARIADIC_TEMPLATES)
+#include <boost/container/detail/preprocessor.hpp>
+#include <boost/container/detail/type_traits.hpp>
+#endif
+
+namespace boost { namespace container {
+
+///@cond
+
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+ #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+ template <typename OuterAlloc, typename ...InnerAllocs>
+ class scoped_allocator_adaptor;
+
+ #else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+ template <typename ...InnerAllocs>
+ class scoped_allocator_adaptor;
+
+ template <typename OuterAlloc, typename ...InnerAllocs>
+ class scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
+
+ #endif // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
+
+
+#else // #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+
+template <typename OuterAlloc
+BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT, container_detail::nat)
+>
+class scoped_allocator_adaptor;
+
+#endif
+
+///@endcond
+
+//! The allocator_arg_t struct is an empty structure type used as a unique type to
+//! disambiguate constructor and function overloading. Specifically, several types
+//! have constructors with allocator_arg_t as the first argument, immediately followed
+//! by an argument of a type that satisfies the Allocator requirements
+struct allocator_arg_t{};
+
+//! A instance of type allocator_arg_t
+//!
+static const allocator_arg_t allocator_arg = allocator_arg_t();
+
+template <class T>
+struct constructible_with_allocator_suffix;
+
+template <class T>
+struct constructible_with_allocator_prefix;
+
+template <typename T, typename Alloc>
+struct uses_allocator;
+
+}} // namespace boost { namespace container {
+
+#include <boost/container/detail/config_end.hpp>
+
+#endif // BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP
diff --git a/boost/container/set.hpp b/boost/container/set.hpp
index b25e7013fc..09ada20033 100644
--- a/boost/container/set.hpp
+++ b/boost/container/set.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -42,32 +42,32 @@ namespace container {
/// @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,
+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,
+inline bool operator<(const set<T,Pred,A>& x,
const set<T,Pred,A>& y);
/// @endcond
-//! A set is a kind of associative container that supports unique keys (contains at
-//! most one of each key value) and provides for fast retrieval of the keys themselves.
-//! Class set supports bidirectional iterators.
-//!
-//! A set satisfies all of the requirements of a container and of a reversible container
-//! , and of an associative container. A set also provides most operations described in
+//! A set is a kind of associative container that supports unique keys (contains at
+//! most one of each key value) and provides for fast retrieval of the keys themselves.
+//! Class set supports bidirectional iterators.
+//!
+//! A set satisfies all of the requirements of a container and of a reversible container
+//! , 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> >
#else
template <class T, class Pred, class A>
#endif
-class set
+class set
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(set)
- typedef container_detail::rbtree<T, T,
+ typedef container_detail::rbtree<T, T,
container_detail::identity<T>, Pred, A> tree_t;
tree_t m_tree; // red-black tree representing set
typedef typename container_detail::
@@ -95,225 +95,240 @@ class set
typedef typename tree_t::stored_allocator_type stored_allocator_type;
//! <b>Effects</b>: Default constructs an empty set.
- //!
+ //!
//! <b>Complexity</b>: Constant.
set()
: m_tree()
{}
- //! <b>Effects</b>: Constructs an empty set using the specified comparison object
+ //! <b>Effects</b>: Constructs an empty set using the specified comparison object
//! and allocator.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit set(const Pred& comp,
const allocator_type& a = allocator_type())
: m_tree(comp, a)
{}
- //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
//! allocator, and inserts elements from the range [first ,last ).
- //!
- //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
+ //!
+ //! <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(),
const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, true)
+ : m_tree(first, last, comp, a, true)
{}
- //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
//! allocator, and inserts elements from the ordered unique range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
//! unique values.
- //!
+ //!
//! <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())
- : m_tree(ordered_range, first, last, comp, a)
+ : m_tree(ordered_range, first, last, comp, a)
{}
//! <b>Effects</b>: Copy constructs a set.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- set(const set& x)
+ set(const set& x)
: m_tree(x.m_tree)
{}
//! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources.
- //!
- //! <b>Complexity</b>: Construct.
- //!
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
//! <b>Postcondition</b>: x is emptied.
- set(BOOST_RV_REF(set) x)
+ set(BOOST_RV_REF(set) x)
: m_tree(boost::move(x.m_tree))
{}
+ //! <b>Effects</b>: Copy constructs a set using the specified allocator.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ set(const set& x, const allocator_type &a)
+ : m_tree(x.m_tree, a)
+ {}
+
+ //! <b>Effects</b>: Move constructs a set using the specified allocator.
+ //! Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ set(BOOST_RV_REF(set) x, const allocator_type &a)
+ : m_tree(boost::move(x.m_tree), a)
+ {}
+
//! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
set& operator=(BOOST_COPY_ASSIGN_REF(set) x)
{ m_tree = x.m_tree; return *this; }
//! <b>Effects</b>: this->swap(x.get()).
- //!
+ //!
//! <b>Complexity</b>: Constant.
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
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return m_tree.get_allocator(); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return m_tree.get_stored_allocator(); }
stored_allocator_type &get_stored_allocator()
{ return m_tree.get_stored_allocator(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant
- iterator begin()
+ iterator begin()
{ return m_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 begin() const
+ const_iterator begin() const
{ return m_tree.begin(); }
//! <b>Effects</b>: Returns an iterator to the end of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ return m_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 end() const
+ const_iterator end() const
{ return m_tree.end(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
- { return m_tree.rbegin(); }
+ reverse_iterator rbegin()
+ { return m_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 rbegin() const
- { return m_tree.rbegin(); }
+ const_reverse_iterator rbegin() const
+ { return m_tree.rbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend()
+ reverse_iterator rend()
{ return m_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
+ const_reverse_iterator rend() const
{ return m_tree.rend(); }
//! <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
+ const_iterator cbegin() const
{ return m_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
+ const_iterator cend() const
{ return m_tree.cend(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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.crbegin(); }
+ const_reverse_iterator crbegin() const
+ { return m_tree.crbegin(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const
+ const_reverse_iterator crend() const
{ return m_tree.crend(); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_tree.max_size(); }
//! <b>Effects</b>: Swaps the contents of *this and x.
@@ -324,15 +339,15 @@ class set
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
+ //! <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
+ //! <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)
+ 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)
@@ -345,18 +360,18 @@ class set
{ return priv_insert(u); }
#endif
- //! <b>Effects</b>: Move constructs a new value from x if and only if there is
+ //! <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
+ //! <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)
+ 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
+ //! <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.
//!
@@ -365,7 +380,7 @@ class set
//!
//! <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)
+ 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)
@@ -384,28 +399,28 @@ class set
//! <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)
+ 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
+ //! <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)
+ void insert(InputIterator first, InputIterator last)
{ m_tree.insert_unique(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
+ //! 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
//! newly inserted element.
//!
- //! <b>Returns</b>: The bool component of the returned pair is true if and only
+ //! <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.
//!
@@ -418,7 +433,7 @@ class set
{ return m_tree.emplace_unique(boost::forward<Args>(args)...); }
//! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... if and only if there is
+ //! 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
//! should start to search.
@@ -451,11 +466,11 @@ class set
//! <b>Effects</b>: Erases the element pointed to by p.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Amortized constant time
- iterator erase(const_iterator p)
+ iterator erase(const_iterator p)
{ return m_tree.erase(p); }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
@@ -463,7 +478,7 @@ class set
//! <b>Returns</b>: Returns the number of erased elements.
//!
//! <b>Complexity</b>: log(size()) + count(k)
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -471,7 +486,7 @@ class set
//! <b>Returns</b>: Returns last.
//!
//! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
- iterator erase(const_iterator first, const_iterator last)
+ iterator erase(const_iterator first, const_iterator last)
{ return m_tree.erase(first, last); }
//! <b>Effects</b>: erase(a.begin(),a.end()).
@@ -479,41 +494,41 @@ class set
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_tree.clear(); }
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator find(const key_type& x)
+ iterator find(const key_type& x)
{ return m_tree.find(x); }
//! <b>Returns</b>: A 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.
- const_iterator find(const key_type& x) const
+ const_iterator find(const key_type& x) const
{ return m_tree.find(x); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_tree.find(x) == m_tree.end() ? 0 : 1; }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
+ const_iterator lower_bound(const key_type& x) const
{ return m_tree.lower_bound(x); }
//! <b>Returns</b>: An iterator pointing to the first element with key not less
@@ -527,21 +542,21 @@ class set
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
+ const_iterator upper_bound(const key_type& x) const
{ 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)
+ 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
@@ -552,47 +567,47 @@ class set
friend bool operator< (const set<K1,C1,A1>&, const set<K1,C1,A1>&);
private:
- std::pair<iterator, bool> priv_insert(const T &x)
+ std::pair<iterator, bool> priv_insert(const T &x)
{ return m_tree.insert_unique(x); }
- iterator priv_insert(const_iterator p, const T &x)
+ iterator priv_insert(const_iterator p, const T &x)
{ return m_tree.insert_unique(p, x); }
/// @endcond
};
template <class T, class Pred, class A>
-inline bool operator==(const set<T,Pred,A>& x,
- const set<T,Pred,A>& y)
+inline bool operator==(const set<T,Pred,A>& x,
+ const set<T,Pred,A>& 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)
+inline bool operator<(const set<T,Pred,A>& x,
+ const set<T,Pred,A>& 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)
+inline bool operator!=(const set<T,Pred,A>& x,
+ const set<T,Pred,A>& 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)
+inline bool operator>(const set<T,Pred,A>& x,
+ const set<T,Pred,A>& 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)
+inline bool operator<=(const set<T,Pred,A>& x,
+ const set<T,Pred,A>& 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)
+inline bool operator>=(const set<T,Pred,A>& x,
+ const set<T,Pred,A>& y)
{ return !(x < y); }
template <class T, class Pred, class A>
-inline void swap(set<T,Pred,A>& x, set<T,Pred,A>& y)
+inline void swap(set<T,Pred,A>& x, set<T,Pred,A>& y)
{ x.swap(y); }
/// @cond
@@ -612,32 +627,32 @@ 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,
+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,
+inline bool operator<(const multiset<T,Pred,A>& x,
const multiset<T,Pred,A>& y);
/// @endcond
-//! A multiset is a kind of associative container that supports equivalent keys
-//! (possibly contains multiple copies of the same key value) and provides for
+//! A multiset is a kind of associative container that supports equivalent keys
+//! (possibly contains multiple copies of the same key value) and provides for
//! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators.
-//!
-//! A multiset satisfies all of the requirements of a container and of a reversible
-//! container, and of an associative container). multiset also provides most operations
+//!
+//! A multiset satisfies all of the requirements of a container and of a reversible
+//! 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> >
#else
template <class T, class Pred, class A>
#endif
-class multiset
+class multiset
{
/// @cond
private:
BOOST_COPYABLE_AND_MOVABLE(multiset)
- typedef container_detail::rbtree<T, T,
+ typedef container_detail::rbtree<T, T,
container_detail::identity<T>, Pred, A> tree_t;
tree_t m_tree; // red-black tree representing multiset
typedef typename container_detail::
@@ -666,7 +681,7 @@ class multiset
//! <b>Effects</b>: Constructs an empty multiset using the specified comparison
//! object and allocator.
- //!
+ //!
//! <b>Complexity</b>: Constant.
multiset()
: m_tree()
@@ -674,7 +689,7 @@ class multiset
//! <b>Effects</b>: Constructs an empty multiset using the specified comparison
//! object and allocator.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit multiset(const Pred& comp,
const allocator_type& a = allocator_type())
@@ -683,209 +698,226 @@ class multiset
//! <b>Effects</b>: Constructs an empty multiset using the specified comparison object
//! and allocator, and inserts elements from the range [first ,last ).
- //!
- //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
+ //!
+ //! <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>
multiset(InputIterator first, InputIterator last,
const Pred& comp = Pred(),
const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, false)
+ : m_tree(first, last, comp, a, false)
{}
- //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
+ //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
//! allocator, and inserts elements from the ordered range [first ,last ). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
- //!
+ //!
//! <b>Complexity</b>: Linear in N.
template <class InputIterator>
multiset( ordered_range_t ordered_range, InputIterator first, InputIterator last
, const Pred& comp = Pred()
, const allocator_type& a = allocator_type())
- : m_tree(ordered_range, first, last, comp, a)
+ : m_tree(ordered_range, first, last, comp, a)
{}
//! <b>Effects</b>: Copy constructs a multiset.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- multiset(const multiset& x)
+ multiset(const multiset& x)
: m_tree(x.m_tree)
{}
//! <b>Effects</b>: Move constructs a multiset. Constructs *this using x's resources.
- //!
- //! <b>Complexity</b>: Construct.
- //!
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
//! <b>Postcondition</b>: x is emptied.
- multiset(BOOST_RV_REF(multiset) x)
+ multiset(BOOST_RV_REF(multiset) x)
: m_tree(boost::move(x.m_tree))
{}
+ //! <b>Effects</b>: Copy constructs a multiset using the specified allocator.
+ //!
+ //! <b>Complexity</b>: Linear in x.size().
+ multiset(const multiset& x, const allocator_type &a)
+ : m_tree(x.m_tree, a)
+ {}
+
+ //! <b>Effects</b>: Move constructs a multiset using the specified allocator.
+ //! Constructs *this using x's resources.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ //!
+ //! <b>Postcondition</b>: x is emptied.
+ multiset(BOOST_RV_REF(multiset) x, const allocator_type &a)
+ : m_tree(boost::move(x.m_tree), a)
+ {}
+
//! <b>Effects</b>: Makes *this a copy of x.
- //!
+ //!
//! <b>Complexity</b>: Linear in x.size().
- multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x)
+ multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x)
{ m_tree = x.m_tree; return *this; }
//! <b>Effects</b>: this->swap(x.get()).
- //!
+ //!
//! <b>Complexity</b>: Constant.
- multiset& operator=(BOOST_RV_REF(multiset) x)
+ 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
+ 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
+ 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.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return m_tree.get_allocator(); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return m_tree.get_stored_allocator(); }
stored_allocator_type &get_stored_allocator()
{ return m_tree.get_stored_allocator(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ return m_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 begin() const
+ const_iterator begin() const
{ return m_tree.begin(); }
//! <b>Effects</b>: Returns an iterator to the end of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator end()
+ iterator end()
{ return m_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 end() const
+ const_iterator end() const
{ return m_tree.end(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
- { return m_tree.rbegin(); }
+ reverse_iterator rbegin()
+ { return m_tree.rbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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 rbegin() const
- { return m_tree.rbegin(); }
+ const_reverse_iterator rbegin() const
+ { return m_tree.rbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend()
+ reverse_iterator rend()
{ return m_tree.rend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
+ const_reverse_iterator rend() const
{ return m_tree.rend(); }
//! <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
+ const_iterator cbegin() const
{ return m_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
+ const_iterator cend() const
{ return m_tree.cend(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed container.
- //!
+ //! <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.crbegin(); }
+ const_reverse_iterator crbegin() const
+ { return m_tree.crbegin(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed container.
- //!
+ //! of the reversed container.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const
+ const_reverse_iterator crend() const
{ return m_tree.crend(); }
//! <b>Effects</b>: Returns true if the container contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return m_tree.empty(); }
//! <b>Effects</b>: Returns the number of the elements contained in the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return m_tree.size(); }
//! <b>Effects</b>: Returns the largest possible size of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return m_tree.max_size(); }
//! <b>Effects</b>: Swaps the contents of *this and x.
@@ -897,10 +929,10 @@ class multiset
{ m_tree.swap(x.m_tree); }
//! <b>Effects</b>: Inserts x and returns the iterator pointing to the
- //! newly inserted element.
+ //! newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator insert(insert_const_ref_type x)
+ iterator insert(insert_const_ref_type x)
{ return priv_insert(x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -920,7 +952,7 @@ class multiset
//!
//! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
//! is inserted right before p.
- iterator insert(BOOST_RV_REF(value_type) x)
+ iterator insert(BOOST_RV_REF(value_type) x)
{ return m_tree.insert_equal(boost::move(x)); }
//! <b>Effects</b>: Inserts a copy of x in the container.
@@ -931,7 +963,7 @@ class multiset
//!
//! <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)
+ 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)
@@ -952,7 +984,7 @@ class multiset
//!
//! <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)
+ iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
{ return m_tree.insert_equal(p, boost::move(x)); }
//! <b>Requires</b>: first, last are not iterators into *this.
@@ -961,14 +993,14 @@ class multiset
//!
//! <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)
+ 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.
+ //! newly inserted element.
//!
//! <b>Complexity</b>: Logarithmic.
template <class... Args>
@@ -1008,11 +1040,11 @@ class multiset
//! <b>Effects</b>: Erases the element pointed to by p.
//!
//! <b>Returns</b>: Returns an iterator pointing to the element immediately
- //! following q prior to the element being erased. If no such element exists,
+ //! following q prior to the element being erased. If no such element exists,
//! returns end().
//!
//! <b>Complexity</b>: Amortized constant time
- iterator erase(const_iterator p)
+ iterator erase(const_iterator p)
{ return m_tree.erase(p); }
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
@@ -1020,7 +1052,7 @@ class multiset
//! <b>Returns</b>: Returns the number of erased elements.
//!
//! <b>Complexity</b>: log(size()) + count(k)
- size_type erase(const key_type& x)
+ size_type erase(const key_type& x)
{ return m_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
@@ -1036,41 +1068,41 @@ class multiset
//! <b>Postcondition</b>: size() == 0.
//!
//! <b>Complexity</b>: linear in size().
- void clear()
+ void clear()
{ m_tree.clear(); }
//! <b>Returns</b>: An iterator pointing to an element with the key
//! equivalent to x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic.
- iterator find(const key_type& x)
+ iterator find(const key_type& x)
{ return m_tree.find(x); }
//! <b>Returns</b>: A 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.
- const_iterator find(const key_type& x) const
+ const_iterator find(const key_type& x) const
{ return m_tree.find(x); }
//! <b>Returns</b>: The number of elements with key equivalent to x.
//!
//! <b>Complexity</b>: log(size())+count(k)
- size_type count(const key_type& x) const
+ size_type count(const key_type& x) const
{ return m_tree.count(x); }
//! <b>Returns</b>: An 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
- iterator lower_bound(const key_type& x)
+ 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
//! less than k, or a.end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator lower_bound(const key_type& x) const
+ const_iterator lower_bound(const key_type& x) const
{ return m_tree.lower_bound(x); }
//! <b>Returns</b>: An iterator pointing to the first element with key not less
@@ -1084,21 +1116,21 @@ class multiset
//! less than x, or end() if such an element is not found.
//!
//! <b>Complexity</b>: Logarithmic
- const_iterator upper_bound(const key_type& x) const
+ const_iterator upper_bound(const key_type& x) const
{ 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)
+ 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
@@ -1109,47 +1141,47 @@ class multiset
friend bool operator< (const multiset<K1,C1,A1>&,
const multiset<K1,C1,A1>&);
private:
- iterator priv_insert(const T &x)
+ iterator priv_insert(const T &x)
{ return m_tree.insert_equal(x); }
- iterator priv_insert(const_iterator p, const T &x)
+ iterator priv_insert(const_iterator p, const T &x)
{ return m_tree.insert_equal(p, x); }
/// @endcond
};
template <class T, class Pred, class A>
-inline bool operator==(const multiset<T,Pred,A>& x,
- const multiset<T,Pred,A>& y)
+inline bool operator==(const multiset<T,Pred,A>& x,
+ const multiset<T,Pred,A>& 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)
+inline bool operator<(const multiset<T,Pred,A>& x,
+ const multiset<T,Pred,A>& 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)
+inline bool operator!=(const multiset<T,Pred,A>& x,
+ const multiset<T,Pred,A>& 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)
+inline bool operator>(const multiset<T,Pred,A>& x,
+ const multiset<T,Pred,A>& 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)
+inline bool operator<=(const multiset<T,Pred,A>& x,
+ const multiset<T,Pred,A>& 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)
+inline bool operator>=(const multiset<T,Pred,A>& x,
+ const multiset<T,Pred,A>& y)
{ return !(x < y); }
template <class T, class Pred, class A>
-inline void swap(multiset<T,Pred,A>& x, multiset<T,Pred,A>& y)
+inline void swap(multiset<T,Pred,A>& x, multiset<T,Pred,A>& y)
{ x.swap(y); }
/// @cond
diff --git a/boost/container/slist.hpp b/boost/container/slist.hpp
index 1cdcdf1046..57719357fc 100644
--- a/boost/container/slist.hpp
+++ b/boost/container/slist.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -32,7 +32,7 @@
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//Preprocessor library to emulate perfect forwarding
#else
-#include <boost/container/detail/preprocessor.hpp>
+#include <boost/container/detail/preprocessor.hpp>
#endif
#include <stdexcept>
@@ -65,31 +65,11 @@ template <class T, class VoidPointer>
struct slist_node
: public slist_hook<VoidPointer>::type
{
+ private:
+ slist_node();
- slist_node()
- : m_data()
- {}
-
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- template<class ...Args>
- slist_node(Args &&...args)
- : m_data(boost::forward<Args>(args)...)
- {}
-
- #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
- #define BOOST_PP_LOCAL_MACRO(n) \
- template<BOOST_PP_ENUM_PARAMS(n, class P)> \
- slist_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- : m_data(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \
- {} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif//#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
+ public:
+ typedef typename slist_hook<VoidPointer>::type hook_type;
T m_data;
};
@@ -119,51 +99,51 @@ struct intrusive_slist_type
/// @endcond
-//! An slist is a singly linked list: a list where each element is linked to the next
-//! element, but not to the previous element. That is, it is a Sequence that
-//! supports forward but not backward traversal, and (amortized) constant time
-//! insertion and removal of elements. Slists, like lists, have the important
-//! property that insertion and splicing do not invalidate iterators to list elements,
-//! and that even removal invalidates only the iterators that point to the elements
-//! that are removed. The ordering of iterators may be changed (that is,
-//! slist<T>::iterator might have a different predecessor or successor after a list
-//! operation than it did before), but the iterators themselves will not be invalidated
+//! An slist is a singly linked list: a list where each element is linked to the next
+//! element, but not to the previous element. That is, it is a Sequence that
+//! supports forward but not backward traversal, and (amortized) constant time
+//! insertion and removal of elements. Slists, like lists, have the important
+//! property that insertion and splicing do not invalidate iterators to list elements,
+//! and that even removal invalidates only the iterators that point to the elements
+//! that are removed. The ordering of iterators may be changed (that is,
+//! slist<T>::iterator might have a different predecessor or successor after a list
+//! operation than it did before), but the iterators themselves will not be invalidated
//! or made to point to different elements unless that invalidation or mutation is explicit.
//!
-//! The main difference between slist and list is that list's iterators are bidirectional
-//! iterators, while slist's iterators are forward iterators. This means that slist is
-//! less versatile than list; frequently, however, bidirectional iterators are
-//! unnecessary. You should usually use slist unless you actually need the extra
-//! functionality of list, because singly linked lists are smaller and faster than double
-//! linked lists.
-//!
-//! Important performance note: like every other Sequence, slist defines the member
-//! functions insert and erase. Using these member functions carelessly, however, can
-//! result in disastrously slow programs. The problem is that insert's first argument is
-//! an iterator p, and that it inserts the new element(s) before p. This means that
-//! insert must find the iterator just before p; this is a constant-time operation
-//! for list, since list has bidirectional iterators, but for slist it must find that
-//! iterator by traversing the list from the beginning up to p. In other words:
+//! The main difference between slist and list is that list's iterators are bidirectional
+//! iterators, while slist's iterators are forward iterators. This means that slist is
+//! less versatile than list; frequently, however, bidirectional iterators are
+//! unnecessary. You should usually use slist unless you actually need the extra
+//! functionality of list, because singly linked lists are smaller and faster than double
+//! linked lists.
+//!
+//! Important performance note: like every other Sequence, slist defines the member
+//! functions insert and erase. Using these member functions carelessly, however, can
+//! result in disastrously slow programs. The problem is that insert's first argument is
+//! an iterator p, and that it inserts the new element(s) before p. This means that
+//! insert must find the iterator just before p; this is a constant-time operation
+//! for list, since list has bidirectional iterators, but for slist it must find that
+//! iterator by traversing the list from the beginning up to p. In other words:
//! insert and erase are slow operations anywhere but near the beginning of the slist.
-//!
-//! Slist provides the member functions insert_after and erase_after, which are constant
-//! time operations: you should always use insert_after and erase_after whenever
-//! possible. If you find that insert_after and erase_after aren't adequate for your
-//! needs, and that you often need to use insert and erase in the middle of the list,
+//!
+//! Slist provides the member functions insert_after and erase_after, which are constant
+//! time operations: you should always use insert_after and erase_after whenever
+//! possible. If you find that insert_after and erase_after aren't adequate for your
+//! 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> >
#else
template <class T, class A>
#endif
-class slist
+class slist
: protected container_detail::node_alloc_holder
<A, typename container_detail::intrusive_slist_type<A>::type>
{
/// @cond
typedef typename container_detail::
move_const_ref_type<T>::type insert_const_ref_type;
- typedef typename
+ typedef typename
container_detail::intrusive_slist_type<A>::type Icont;
typedef container_detail::node_alloc_holder<A, Icont> AllocHolder;
typedef typename AllocHolder::NodePtr NodePtr;
@@ -238,11 +218,11 @@ class slist
public:
- //! Const iterator used to iterate through a list.
+ //! Const iterator used to iterate through a list.
class const_iterator
/// @cond
- : public std::iterator<std::forward_iterator_tag,
- value_type, list_difference_type,
+ : public std::iterator<std::forward_iterator_tag,
+ value_type, list_difference_type,
list_const_pointer, list_const_reference>
{
@@ -265,17 +245,17 @@ class slist
{}
//Pointer like operators
- const_reference operator*() const
+ const_reference operator*() const
{ return m_it->m_data; }
- const_pointer operator->() const
+ const_pointer operator->() const
{ return const_pointer(&m_it->m_data); }
//Increment / Decrement
- const_iterator& operator++()
+ const_iterator& operator++()
{ prot_incr(); return *this; }
- const_iterator operator++(int)
+ const_iterator operator++(int)
{ typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp); }
//Comparison operators
@@ -298,7 +278,7 @@ class slist
explicit iterator(typename Icont::iterator it)
: const_iterator(it)
{}
-
+
typename Icont::iterator get()
{ return this->m_it; }
@@ -315,7 +295,7 @@ class slist
pointer operator->() const { return pointer(&this->m_it->m_data); }
//Increment / Decrement
- iterator& operator++()
+ iterator& operator++()
{ this->prot_incr(); return *this; }
iterator operator++(int)
@@ -326,18 +306,18 @@ class slist
public:
//! <b>Effects</b>: Constructs a list taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
slist()
: AllocHolder()
{}
//! <b>Effects</b>: Constructs a list taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit slist(const allocator_type& a)
: AllocHolder(a)
@@ -352,7 +332,7 @@ class slist
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
explicit slist(size_type n, const value_type& x, const allocator_type& a = allocator_type())
: AllocHolder(a)
@@ -367,34 +347,62 @@ class slist
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InpIt>
slist(InpIt first, InpIt last,
- const allocator_type& a = allocator_type())
+ const allocator_type& a = allocator_type())
: AllocHolder(a)
{ this->insert_after(this->before_begin(), first, last); }
//! <b>Effects</b>: Copy constructs a list.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
- slist(const slist& x)
+ slist(const slist& x)
: AllocHolder(x)
{ this->insert_after(this->before_begin(), x.begin(), x.end()); }
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
slist(BOOST_RV_REF(slist) x)
: AllocHolder(boost::move(static_cast<AllocHolder&>(x)))
{}
+ //! <b>Effects</b>: Copy constructs a list using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ slist(const slist& x, const allocator_type &a)
+ : AllocHolder(a)
+ { this->insert_after(this->before_begin(), x.begin(), x.end()); }
+
+ //! <b>Effects</b>: Move constructor using the specified allocator.
+ //! Moves x's resources to *this.
+ //!
+ //! <b>Throws</b>: If allocation or value_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ slist(BOOST_RV_REF(slist) x, const allocator_type &a)
+ : AllocHolder(a)
+ {
+ if(this->node_alloc() == x.node_alloc()){
+ this->icont().swap(x.icont());
+ }
+ else{
+ this->insert(this->cbegin(), x.begin(), x.end());
+ }
+ }
+
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
@@ -417,8 +425,8 @@ class slist
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
@@ -452,18 +460,18 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements.
- ~slist()
+ ~slist()
{} //AllocHolder clears the slist
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
allocator_type get_allocator() const
{ return allocator_type(this->node_alloc()); }
- const stored_allocator_type &get_stored_allocator() const
+ const stored_allocator_type &get_stored_allocator() const
{ return this->node_alloc(); }
stored_allocator_type &get_stored_allocator()
@@ -486,7 +494,7 @@ class slist
//!
//! <b>Complexity</b>: Linear to n.
template <class InpIt>
- void assign(InpIt first, InpIt last)
+ void assign(InpIt first, InpIt last)
{
const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
typedef container_detail::bool_<aux_boolean> Result;
@@ -494,33 +502,33 @@ class slist
}
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator begin()
+ iterator begin()
{ return iterator(this->icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_iterator begin() const
+ const_iterator begin() const
{ return this->cbegin(); }
//! <b>Effects</b>: Returns an iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end()
{ return iterator(this->icont().end()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator end() const
{ return this->cend(); }
@@ -528,71 +536,71 @@ class slist
//! <b>Effects</b>: Returns a non-dereferenceable iterator that,
//! when incremented, yields begin(). This iterator may be used
//! as the argument toinsert_after, erase_after, etc.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- iterator before_begin()
+ iterator before_begin()
{ return iterator(end()); }
- //! <b>Effects</b>: Returns a non-dereferenceable const_iterator
+ //! <b>Effects</b>: Returns a non-dereferenceable const_iterator
//! that, when incremented, yields begin(). This iterator may be used
//! as the argument toinsert_after, erase_after, etc.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator before_begin() const
{ return this->cbefore_begin(); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_iterator cbegin() const
+ const_iterator cbegin() const
{ return const_iterator(this->non_const_icont().begin()); }
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cend() const
{ return const_iterator(this->non_const_icont().end()); }
- //! <b>Effects</b>: Returns a non-dereferenceable const_iterator
+ //! <b>Effects</b>: Returns a non-dereferenceable const_iterator
//! that, when incremented, yields begin(). This iterator may be used
//! as the argument toinsert_after, erase_after, etc.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbefore_begin() const
{ return const_iterator(end()); }
//! <b>Effects</b>: Returns the number of the elements contained in the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return this->icont().size(); }
//! <b>Effects</b>: Returns the largest possible size of the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type max_size() const
+ size_type max_size() const
{ return AllocHolder::max_size(); }
//! <b>Effects</b>: Returns true if the list contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- bool empty() const
+ bool empty() const
{ return !this->size(); }
//! <b>Effects</b>: Swaps the contents of *this and x.
@@ -605,24 +613,24 @@ class slist
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a reference to the first element
+ //! <b>Effects</b>: Returns a reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reference front()
+ reference front()
{ return *this->begin(); }
//! <b>Requires</b>: !empty()
//!
- //! <b>Effects</b>: Returns a const reference to the first element
+ //! <b>Effects</b>: Returns a const reference to the first element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reference front() const
+ const_reference front() const
{ return *this->begin(); }
//! <b>Effects</b>: Inserts a copy of t in the beginning of the list.
@@ -660,24 +668,24 @@ class slist
void pop_front()
{ this->icont().pop_front_and_dispose(Destroyer(this->node_alloc())); }
- //! <b>Returns</b>: The iterator to the element before i in the sequence.
- //! Returns the end-iterator, if either i is the begin-iterator or the
- //! sequence is empty.
- //!
+ //! <b>Returns</b>: The iterator to the element before i in the sequence.
+ //! Returns the end-iterator, if either i is the begin-iterator or the
+ //! sequence is empty.
+ //!
//! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Linear to the number of elements before i.
- iterator previous(iterator p)
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements before i.
+ iterator previous(iterator p)
{ return iterator(this->icont().previous(p.get())); }
- //! <b>Returns</b>: The const_iterator to the element before i in the sequence.
- //! Returns the end-const_iterator, if either i is the begin-const_iterator or
- //! the sequence is empty.
- //!
+ //! <b>Returns</b>: The const_iterator to the element before i in the sequence.
+ //! Returns the end-const_iterator, if either i is the begin-const_iterator or
+ //! the sequence is empty.
+ //!
//! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Linear to the number of elements before i.
- const_iterator previous(const_iterator p)
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements before i.
+ const_iterator previous(const_iterator p)
{ return const_iterator(this->icont().previous(p.get())); }
//! <b>Requires</b>: p must be a valid iterator of *this.
@@ -686,14 +694,14 @@ class slist
//! by prev_p.
//!
//! <b>Returns</b>: An iterator to the inserted element.
- //!
+ //!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Amortized constant time.
//!
//! <b>Note</b>: Does not affect the validity of iterators and references of
//! previous values.
- iterator insert_after(const_iterator prev_pos, insert_const_ref_type x)
+ iterator insert_after(const_iterator prev_pos, insert_const_ref_type x)
{ return this->priv_insert_after(prev_pos, x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -712,14 +720,14 @@ class slist
//! p pointed by prev_pos.
//!
//! <b>Returns</b>: An iterator to the inserted element.
- //!
+ //!
//! <b>Throws</b>: If memory allocation throws.
- //!
+ //!
//! <b>Complexity</b>: Amortized constant time.
//!
//! <b>Note</b>: Does not affect the validity of iterators and references of
//! previous values.
- iterator insert_after(const_iterator prev_pos, BOOST_RV_REF(value_type) x)
+ iterator insert_after(const_iterator prev_pos, BOOST_RV_REF(value_type) x)
{ return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(boost::move(x)))); }
//! <b>Requires</b>: prev_pos must be a valid iterator of *this.
@@ -736,19 +744,19 @@ class slist
{ this->priv_create_and_insert_nodes(prev_pos, n, x); }
//! <b>Requires</b>: prev_pos must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Inserts the range pointed by [first, last)
+ //!
+ //! <b>Effects</b>: Inserts the range pointed by [first, last)
//! after the p prev_pos.
- //!
+ //!
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to the number of elements inserted.
- //!
+ //!
//! <b>Note</b>: Does not affect the validity of iterators and references of
//! previous values.
template <class InIter>
- void insert_after(const_iterator prev_pos, InIter first, InIter last)
+ void insert_after(const_iterator prev_pos, InIter first, InIter last)
{
const bool aux_boolean = container_detail::is_convertible<InIter, size_type>::value;
typedef container_detail::bool_<aux_boolean> Result;
@@ -762,7 +770,7 @@ class slist
//! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the elements before p.
- iterator insert(const_iterator position, insert_const_ref_type x)
+ iterator insert(const_iterator position, insert_const_ref_type x)
{ return this->priv_insert(position, x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -782,7 +790,7 @@ class slist
//! <b>Throws</b>: If memory allocation throws.
//!
//! <b>Complexity</b>: Linear to the elements before p.
- iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
+ iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
{ return this->insert_after(previous(p), boost::move(x)); }
//! <b>Requires</b>: p must be a valid iterator of *this.
@@ -792,9 +800,9 @@ class slist
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n plus linear to the elements before p.
- void insert(const_iterator p, size_type n, const value_type& x)
+ void insert(const_iterator p, size_type n, const value_type& x)
{ return this->insert_after(previous(p), n, x); }
-
+
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
//! <b>Effects</b>: Insert a copy of the [first, last) range before p.
@@ -805,7 +813,7 @@ class slist
//! <b>Complexity</b>: Linear to std::distance [first, last) plus
//! linear to the elements before p.
template <class InIter>
- void insert(const_iterator p, InIter first, InIter last)
+ void insert(const_iterator p, InIter first, InIter last)
{ return this->insert_after(previous(p), first, last); }
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -884,11 +892,11 @@ class slist
//!
//! <b>Returns</b>: the first element remaining beyond the removed elements,
//! or end() if no such element exists.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Does not invalidate iterators or references to non erased elements.
iterator erase_after(const_iterator prev_pos)
{
@@ -896,17 +904,17 @@ class slist
}
//! <b>Effects</b>: Erases the range (before_first, last) from
- //! the list.
+ //! the list.
//!
//! <b>Returns</b>: the first element remaining beyond the removed elements,
//! or end() if no such element exists.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Linear to the number of erased elements.
- //!
+ //!
//! <b>Note</b>: Does not invalidate iterators or references to non erased elements.
- iterator erase_after(const_iterator before_first, const_iterator last)
+ iterator erase_after(const_iterator before_first, const_iterator last)
{
return iterator(this->icont().erase_after_and_dispose(before_first.get(), last.get(), Destroyer(this->node_alloc())));
}
@@ -918,7 +926,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements before p.
- iterator erase(const_iterator p)
+ iterator erase(const_iterator p)
{ return iterator(this->erase_after(previous(p))); }
//! <b>Requires</b>: first and last must be valid iterator to elements in *this.
@@ -945,7 +953,7 @@ class slist
--new_size;
cur = cur_next;
}
- if (cur_next != end_n)
+ if (cur_next != end_n)
this->erase_after(const_iterator(cur), const_iterator(end_n));
else
this->insert_after(const_iterator(cur), new_size, x);
@@ -962,7 +970,7 @@ class slist
typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
size_type len = this->size();
size_type left = new_size;
-
+
while (++(cur_next = cur) != end_n && left > 0){
--left;
cur = cur_next;
@@ -980,7 +988,7 @@ class slist
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements in the list.
- void clear()
+ void clear()
{ this->icont().clear_and_dispose(Destroyer(this->node_alloc())); }
//! <b>Requires</b>: p must point to an element contained
@@ -993,7 +1001,7 @@ class slist
//! are not equal.
//!
//! <b>Complexity</b>: Linear to the elements in x.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of
//! this list. Iterators of this list and all the references are not invalidated.
void splice_after(const_iterator prev_pos, slist& x)
@@ -1008,16 +1016,16 @@ class slist
//! <b>Requires</b>: prev_pos must be a valid iterator of this.
//! i must point to an element contained in list x.
- //!
- //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
//! after the element pointed by prev_pos.
- //! If prev_pos == prev or prev_pos == ++prev, this function is a null operation.
- //!
+ //! If prev_pos == prev or prev_pos == ++prev, this function is a null operation.
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice_after(const_iterator prev_pos, slist& x, const_iterator prev)
@@ -1033,18 +1041,18 @@ class slist
//! <b>Requires</b>: prev_pos must be a valid iterator of this.
//! before_first and before_last must be valid iterators of x.
//! prev_pos must not be contained in [before_first, before_last) range.
- //!
+ //!
//! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
//! from list x to this list, after the element pointed by prev_pos.
- //!
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Linear to the number of transferred elements.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
- void splice_after(const_iterator prev_pos, slist& x,
+ void splice_after(const_iterator prev_pos, slist& x,
const_iterator before_first, const_iterator before_last)
{
if((NodeAlloc&)*this == (NodeAlloc&)x){
@@ -1060,18 +1068,18 @@ class slist
//! before_first and before_last must be valid iterators of x.
//! prev_pos must not be contained in [before_first, before_last) range.
//! n == std::distance(before_first, before_last)
- //!
+ //!
//! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
//! from list x to this list, after the element pointed by prev_pos.
- //!
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
- void splice_after(const_iterator prev_pos, slist& x,
+ void splice_after(const_iterator prev_pos, slist& x,
const_iterator before_first, const_iterator before_last,
size_type n)
{
@@ -1094,24 +1102,24 @@ class slist
//! are not equal.
//!
//! <b>Complexity</b>: Linear in distance(begin(), p), and linear in x.size().
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of
//! this list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, ThisType& x)
+ void splice(const_iterator p, ThisType& x)
{ this->splice_after(this->previous(p), x); }
//! <b>Requires</b>: p must point to an element contained
//! by this list. i must point to an element contained in list x.
- //!
- //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //! If p == i or p == ++i, this function is a null operation.
- //!
+ //! If p == i or p == ++i, this function is a null operation.
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Linear in distance(begin(), p), and in distance(x.begin(), i).
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, slist& x, const_iterator i)
@@ -1119,37 +1127,37 @@ class slist
//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
- //!
- //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
- //!
+ //!
//! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
//! are not equal.
- //!
+ //!
//! <b>Complexity</b>: Linear in distance(begin(), p), in distance(x.begin(), first),
//! and in distance(first, last).
- //!
+ //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, slist& x, const_iterator first, const_iterator last)
{ this->splice_after(previous(p), x, previous(first), previous(last)); }
- //! <b>Effects</b>: Reverses the order of elements in the list.
- //!
+ //! <b>Effects</b>: Reverses the order of elements in the list.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time.
- //!
+ //!
//! <b>Note</b>: Iterators and references are not invalidated
- void reverse()
+ void reverse()
{ this->icont().reverse(); }
//! <b>Effects</b>: Removes all the elements that compare equal to value.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
void remove(const T& value)
@@ -1157,57 +1165,57 @@ class slist
//! <b>Effects</b>: Removes all the elements for which a specified
//! predicate is satisfied.
- //!
+ //!
//! <b>Throws</b>: If pred throws.
- //!
+ //!
//! <b>Complexity</b>: Linear time. It performs exactly size() calls to the predicate.
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
- template <class Pred>
+ template <class Pred>
void remove_if(Pred pred)
{
typedef ValueCompareToNodeCompare<Pred> Predicate;
this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc()));
}
- //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
+ //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
//! elements that are equal from the list.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Linear time (size()-1 comparisons calls to pred()).
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
void unique()
{ this->unique(value_equal()); }
- //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
+ //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
//! elements that satisfy some binary predicate from the list.
- //!
+ //!
//! <b>Throws</b>: If pred throws.
- //!
+ //!
//! <b>Complexity</b>: Linear time (size()-1 comparisons equality comparisons).
- //!
+ //!
//! <b>Note</b>: The relative order of elements that are not removed is unchanged,
//! and iterators to elements that are not removed remain valid.
- template <class Pred>
+ template <class Pred>
void unique(Pred pred)
{
typedef ValueCompareToNodeCompare<Pred> Predicate;
this->icont().unique_and_dispose(Predicate(pred), Destroyer(this->node_alloc()));
}
- //! <b>Requires</b>: The lists x and *this must be distinct.
+ //! <b>Requires</b>: The lists x and *this must be distinct.
//!
//! <b>Effects</b>: This function removes all of x's elements and inserts them
- //! in order into *this according to std::less<value_type>. The merge is stable;
- //! that is, if an element from *this is equivalent to one from x, then the element
- //! from *this will precede the one from x.
- //!
+ //! in order into *this according to std::less<value_type>. The merge is stable;
+ //! that is, if an element from *this is equivalent to one from x, then the element
+ //! from *this will precede the one from x.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time: it performs at most
//! size() + x.size() - 1 comparisons.
void merge(slist & x)
@@ -1215,17 +1223,17 @@ class slist
//! <b>Requires</b>: p must be a comparison function that induces a strict weak
//! ordering and both *this and x must be sorted according to that ordering
- //! The lists x and *this must be distinct.
- //!
+ //! The lists x and *this must be distinct.
+ //!
//! <b>Effects</b>: This function removes all of x's elements and inserts them
- //! in order into *this. The merge is stable; that is, if an element from *this is
- //! equivalent to one from x, then the element from *this will precede the one from x.
- //!
+ //! in order into *this. The merge is stable; that is, if an element from *this is
+ //! equivalent to one from x, then the element from *this will precede the one from x.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: This function is linear time: it performs at most
//! size() + x.size() - 1 comparisons.
- //!
+ //!
//! <b>Note</b>: Iterators and references to *this are not invalidated.
template <class StrictWeakOrdering>
void merge(slist& x, StrictWeakOrdering comp)
@@ -1239,28 +1247,28 @@ class slist
}
}
- //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
+ //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
//! The sort is stable, that is, the relative order of equivalent elements is preserved.
- //!
+ //!
//! <b>Throws</b>: Nothing.
//!
//! <b>Notes</b>: Iterators and references are not invalidated.
- //!
+ //!
//! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
//! is the list's size.
void sort()
{ this->sort(value_less()); }
- //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
+ //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
//! The sort is stable, that is, the relative order of equivalent elements is preserved.
- //!
+ //!
//! <b>Throws</b>: Nothing.
//!
//! <b>Notes</b>: Iterators and references are not invalidated.
- //!
+ //!
//! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
//! is the list's size.
- template <class StrictWeakOrdering>
+ template <class StrictWeakOrdering>
void sort(StrictWeakOrdering comp)
{
// nothing if the slist has length 0 or 1.
@@ -1271,10 +1279,10 @@ class slist
/// @cond
private:
- iterator priv_insert(const_iterator p, const value_type& x)
+ iterator priv_insert(const_iterator p, const value_type& x)
{ return this->insert_after(previous(p), x); }
- iterator priv_insert_after(const_iterator prev_pos, const value_type& x)
+ iterator priv_insert_after(const_iterator prev_pos, const value_type& x)
{ return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(x))); }
void priv_push_front(const value_type &x)
@@ -1354,10 +1362,10 @@ class slist
{ this->priv_create_and_insert_nodes(prev, first, last); }
template<class Integer>
- void priv_insert_dispatch(const_iterator prev, Integer n, Integer x, container_detail::true_)
+ void priv_insert_dispatch(const_iterator prev, Integer n, Integer x, container_detail::true_)
{ this->priv_create_and_insert_nodes(prev, (size_type)n, x); }
- void priv_fill_assign(size_type n, const T& val)
+ void priv_fill_assign(size_type n, const T& val)
{
iterator end_n(this->end());
iterator prev(this->before_begin());
@@ -1396,11 +1404,11 @@ class slist
}
template <class Int>
- void priv_insert_after_range_dispatch(const_iterator prev_pos, Int n, Int x, container_detail::true_)
+ void priv_insert_after_range_dispatch(const_iterator prev_pos, Int n, Int x, container_detail::true_)
{ this->priv_create_and_insert_nodes(prev_pos, (size_type)n, x); }
template <class InIter>
- void priv_insert_after_range_dispatch(const_iterator prev_pos, InIter first, InIter last, container_detail::false_)
+ void priv_insert_after_range_dispatch(const_iterator prev_pos, InIter first, InIter last, container_detail::false_)
{ this->priv_create_and_insert_nodes(prev_pos, first, last); }
//Functors for member algorithm defaults
@@ -1430,7 +1438,7 @@ class slist
};
template <class T, class A>
-inline bool
+inline bool
operator==(const slist<T,A>& x, const slist<T,A>& y)
{
if(x.size() != y.size()){
@@ -1457,27 +1465,27 @@ operator<(const slist<T,A>& sL1, const slist<T,A>& sL2)
}
template <class T, class A>
-inline bool
-operator!=(const slist<T,A>& sL1, const slist<T,A>& sL2)
+inline bool
+operator!=(const slist<T,A>& sL1, const slist<T,A>& sL2)
{ return !(sL1 == sL2); }
template <class T, class A>
-inline bool
-operator>(const slist<T,A>& sL1, const slist<T,A>& sL2)
+inline bool
+operator>(const slist<T,A>& sL1, const slist<T,A>& sL2)
{ return sL2 < sL1; }
template <class T, class A>
-inline bool
+inline bool
operator<=(const slist<T,A>& sL1, const slist<T,A>& sL2)
{ return !(sL2 < sL1); }
template <class T, class A>
-inline bool
+inline bool
operator>=(const slist<T,A>& sL1, const slist<T,A>& sL2)
{ return !(sL1 < sL2); }
template <class T, class A>
-inline void swap(slist<T,A>& x, slist<T,A>& y)
+inline void swap(slist<T,A>& x, slist<T,A>& y)
{ x.swap(y); }
}}
@@ -1505,12 +1513,12 @@ namespace container {
///@cond
-//Ummm, I don't like to define things in namespace std, but
+//Ummm, I don't like to define things in namespace std, but
//there is no other way
namespace std {
template <class T, class A>
-class insert_iterator<boost::container::slist<T, A> >
+class insert_iterator<boost::container::slist<T, A> >
{
protected:
typedef boost::container::slist<T, A> Container;
@@ -1524,14 +1532,14 @@ class insert_iterator<boost::container::slist<T, A> >
typedef void pointer;
typedef void reference;
- insert_iterator(Container& x,
- typename Container::iterator i,
- bool is_previous = false)
+ insert_iterator(Container& x,
+ typename Container::iterator i,
+ bool is_previous = false)
: container(&x), iter(is_previous ? i : x.previous(i)){ }
- insert_iterator<Container>&
- operator=(const typename Container::value_type& value)
- {
+ insert_iterator<Container>&
+ operator=(const typename Container::value_type& value)
+ {
iter = container->insert_after(iter, value);
return *this;
}
diff --git a/boost/container/stable_vector.hpp b/boost/container/stable_vector.hpp
index 851b5f26e8..d91eccd16e 100644
--- a/boost/container/stable_vector.hpp
+++ b/boost/container/stable_vector.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -34,7 +34,7 @@
#include <boost/container/detail/utilities.hpp>
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/algorithms.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include <algorithm>
@@ -78,10 +78,6 @@ struct smart_ptr_type<T*>
{ return ptr;}
};
-template<class Ptr>
-inline typename smart_ptr_type<Ptr>::pointer to_raw_pointer(const Ptr &ptr)
-{ return smart_ptr_type<Ptr>::get(ptr); }
-
template <class C>
class clear_on_destroy
{
@@ -97,7 +93,7 @@ class clear_on_destroy
{
if(do_clear_){
c_.clear();
- c_.clear_pool();
+ c_.clear_pool();
}
}
@@ -110,13 +106,10 @@ class clear_on_destroy
template<class VoidPtr>
struct node_type_base
-{/*
- node_type_base(VoidPtr p)
- : up(p)
- {}*/
+{
node_type_base()
{}
- void set_pointer(VoidPtr p)
+ void set_pointer(const VoidPtr &p)
{ up = p; }
VoidPtr up;
@@ -126,33 +119,10 @@ template<typename VoidPointer, typename T>
struct node_type
: public node_type_base<VoidPointer>
{
- node_type()
- : value()
- {}
-
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- template<class ...Args>
- node_type(Args &&...args)
- : value(boost::forward<Args>(args)...)
- {}
-
- #else //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, >) \
- node_type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- : value(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \
- {} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif//BOOST_CONTAINER_PERFECT_FORWARDING
-
- void set_pointer(VoidPointer p)
- { node_type_base<VoidPointer>::set_pointer(p); }
+ private:
+ node_type();
+ public:
T value;
};
@@ -202,21 +172,21 @@ class iterator
iterator(const iterator<T, T&, typename boost::intrusive::pointer_traits<Pointer>::template rebind_pointer<T>::type>& x)
: pn(x.pn)
{}
-
+
private:
static node_type_ptr_t node_ptr_cast(const void_ptr &p)
{
- return node_type_ptr_t(static_cast<node_type_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return node_type_ptr_t(static_cast<node_type_t*>(container_detail::to_raw_pointer(p)));
}
static const_node_type_ptr_t node_ptr_cast(const const_void_ptr &p)
{
- return const_node_type_ptr_t(static_cast<const node_type_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return const_node_type_ptr_t(static_cast<const node_type_t*>(container_detail::to_raw_pointer(p)));
}
static void_ptr_ptr void_ptr_ptr_cast(const void_ptr &p)
{
- return void_ptr_ptr(static_cast<void_ptr*>(stable_vector_detail::to_raw_pointer(p)));
+ return void_ptr_ptr(static_cast<void_ptr*>(container_detail::to_raw_pointer(p)));
}
reference dereference() const
@@ -238,7 +208,7 @@ class iterator
pointer operator->() const { return pointer(&this->dereference()); }
//Increment / Decrement
- iterator& operator++()
+ iterator& operator++()
{ this->increment(); return *this; }
iterator operator++(int)
@@ -353,35 +323,37 @@ BOOST_JOIN(check_invariant_,__LINE__).touch();
/// @endcond
-//!Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
-//!drop-in replacement implemented as a node container, offering iterator and reference
-//!stability.
+//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
+//! drop-in replacement implemented as a node container, offering iterator and reference
+//! stability.
//!
-//!More details taken the author's blog: (<a href="http://bannalia.blogspot.com/2008/09/introducing-stablevector.html" > Introducing stable_vector</a>)
+//! More details taken the author's blog:
+//! (<a href="http://bannalia.blogspot.com/2008/09/introducing-stablevector.html" >
+//! Introducing stable_vector</a>)
//!
-//!We present stable_vector, a fully STL-compliant stable container that provides
-//!most of the features of std::vector except element contiguity.
+//! We present stable_vector, a fully STL-compliant stable container that provides
+//! most of the features of std::vector except element contiguity.
//!
-//!General properties: stable_vector satisfies all the requirements of a container,
-//!a reversible container and a sequence and provides all the optional operations
-//!present in std::vector. Like std::vector, iterators are random access.
-//!stable_vector does not provide element contiguity; in exchange for this absence,
-//!the container is stable, i.e. references and iterators to an element of a stable_vector
-//!remain valid as long as the element is not erased, and an iterator that has been
-//!assigned the return value of end() always remain valid until the destruction of
-//!the associated stable_vector.
+//! General properties: stable_vector satisfies all the requirements of a container,
+//! a reversible container and a sequence and provides all the optional operations
+//! present in std::vector. Like std::vector, iterators are random access.
+//! stable_vector does not provide element contiguity; in exchange for this absence,
+//! the container is stable, i.e. references and iterators to an element of a stable_vector
+//! remain valid as long as the element is not erased, and an iterator that has been
+//! assigned the return value of end() always remain valid until the destruction of
+//! the associated stable_vector.
//!
-//!Operation complexity: The big-O complexities of stable_vector operations match
-//!exactly those of std::vector. In general, insertion/deletion is constant time at
-//!the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector
-//!does not internally perform any value_type destruction, copy or assignment
-//!operations other than those exactly corresponding to the insertion of new
-//!elements or deletion of stored elements, which can sometimes compensate in terms
-//!of performance for the extra burden of doing more pointer manipulation and an
-//!additional allocation per element.
+//! Operation complexity: The big-O complexities of stable_vector operations match
+//! exactly those of std::vector. In general, insertion/deletion is constant time at
+//! the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector
+//! does not internally perform any value_type destruction, copy or assignment
+//! operations other than those exactly corresponding to the insertion of new
+//! elements or deletion of stored elements, which can sometimes compensate in terms
+//! of performance for the extra burden of doing more pointer manipulation and an
+//! additional allocation per element.
//!
-//!Exception safety: As stable_vector does not internally copy elements around, some
-//!operations provide stronger exception safety guarantees than in std::vector:
+//! 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> >
#else
@@ -426,7 +398,7 @@ class stable_vector
integral_constant<unsigned, 1> allocator_v1;
typedef ::boost::container::container_detail::
integral_constant<unsigned, 2> allocator_v2;
- typedef ::boost::container::container_detail::integral_constant
+ typedef ::boost::container::container_detail::integral_constant
<unsigned, boost::container::container_detail::
version<A>::value> alloc_version;
typedef typename allocator_traits_type::
@@ -509,9 +481,9 @@ class stable_vector
public:
//! <b>Effects</b>: Default constructs a stable_vector.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
stable_vector()
: internal_data(), impl()
@@ -520,11 +492,11 @@ class stable_vector
}
//! <b>Effects</b>: Constructs a stable_vector taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- explicit stable_vector(const A& al)
+ explicit stable_vector(const allocator_type& al)
: internal_data(al),impl(al)
{
STABLE_VECTOR_CHECK_INVARIANT;
@@ -535,10 +507,10 @@ class stable_vector
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
explicit stable_vector(size_type n)
- : internal_data(A()),impl(A())
+ : internal_data(),impl()
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->resize(n);
@@ -551,9 +523,9 @@ class stable_vector
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
- stable_vector(size_type n, const T& t, const A& al=A())
+ stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
: internal_data(al),impl(al)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
@@ -570,7 +542,7 @@ class stable_vector
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InputIterator>
- stable_vector(InputIterator first,InputIterator last,const A& al=A())
+ stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type())
: internal_data(al),impl(al)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
@@ -582,7 +554,7 @@ class stable_vector
//! <b>Effects</b>: Copy constructs a stable_vector.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
stable_vector(const stable_vector& x)
: internal_data(allocator_traits<node_allocator_type>::
@@ -599,7 +571,7 @@ class stable_vector
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
stable_vector(BOOST_RV_REF(stable_vector) x)
: internal_data(boost::move(x.node_alloc())), impl(boost::move(x.impl))
@@ -607,6 +579,40 @@ class stable_vector
this->priv_swap_members(x);
}
+ //! <b>Effects</b>: Copy constructs a stable_vector using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ stable_vector(const stable_vector& x, const allocator_type &a)
+ : internal_data(a), impl(a)
+ {
+ stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
+ this->insert(this->cbegin(), x.begin(), x.end());
+ STABLE_VECTOR_CHECK_INVARIANT;
+ cod.release();
+ }
+
+ //! <b>Effects</b>: Move constructor using the specified allocator.
+ //! Moves mx's resources to *this.
+ //!
+ //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise
+ stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
+ : internal_data(a), impl(a)
+ {
+ if(this->node_alloc() == x.node_alloc()){
+ this->priv_swap_members(x);
+ }
+ else{
+ stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
+ this->insert(this->cbegin(), x.begin(), x.end());
+ STABLE_VECTOR_CHECK_INVARIANT;
+ cod.release();
+ }
+ }
+
//! <b>Effects</b>: Destroys the stable_vector. All stored values are destroyed
//! and used memory is deallocated.
//!
@@ -616,13 +622,13 @@ class stable_vector
~stable_vector()
{
this->clear();
- clear_pool();
+ clear_pool();
}
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
@@ -705,146 +711,146 @@ class stable_vector
}
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator()const {return node_alloc();}
+ allocator_type get_allocator()const {return this->node_alloc();}
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
{ return node_alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
{ return node_alloc(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator begin()
{ return (impl.empty()) ? end(): iterator(node_ptr_cast(impl.front())) ; }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator begin()const
{ return (impl.empty()) ? cend() : const_iterator(node_ptr_cast(impl.front())) ; }
//! <b>Effects</b>: Returns an iterator to the end of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end() {return iterator(get_end_node());}
//! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator end()const {return const_iterator(get_end_node());}
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed stable_vector.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rbegin() {return reverse_iterator(this->end());}
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed stable_vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rbegin()const {return const_reverse_iterator(this->end());}
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed stable_vector.
- //!
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend() {return reverse_iterator(this->begin());}
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed stable_vector.
- //!
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rend()const {return const_reverse_iterator(this->begin());}
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbegin()const {return this->begin();}
//! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cend()const {return this->end();}
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed stable_vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crbegin()const{return this->rbegin();}
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed stable_vector.
- //!
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crend()const {return this->rend();}
//! <b>Effects</b>: Returns the number of the elements contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type size() const
{ return impl.empty() ? 0 : (impl.size() - ExtraPointers); }
//! <b>Effects</b>: Returns the largest possible size of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type max_size() const
{ return impl.max_size() - ExtraPointers; }
//! <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
{
@@ -859,9 +865,9 @@ class stable_vector
}
//! <b>Effects</b>: Returns true if the stable_vector contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
bool empty() const
{ return impl.empty() || impl.size() == ExtraPointers; }
@@ -901,7 +907,7 @@ class stable_vector
//! 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.
void reserve(size_type n)
{
@@ -909,7 +915,7 @@ class stable_vector
if(n > this->max_size())
throw std::bad_alloc();
- size_type size = this->size();
+ size_type size = this->size();
size_type old_capacity = this->capacity();
if(n > old_capacity){
this->initialize_end_node(n);
@@ -929,31 +935,31 @@ class stable_vector
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference operator[](size_type n){return value(impl[n]);}
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference operator[](size_type n)const{return value(impl[n]);}
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference at(size_type n)
{
@@ -964,11 +970,11 @@ class stable_vector
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference at(size_type n)const
{
@@ -981,9 +987,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a reference to the first
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference front()
{ return value(impl.front()); }
@@ -992,9 +998,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a const reference to the first
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference front()const
{ return value(impl.front()); }
@@ -1003,9 +1009,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference back()
{ return value(*(&impl.back() - ExtraPointers)); }
@@ -1014,9 +1020,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a const reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference back()const
{ return value(*(&impl.back() - ExtraPointers)); }
@@ -1027,7 +1033,7 @@ class stable_vector
//! T's copy constructor throws.
//!
//! <b>Complexity</b>: Amortized constant time.
- void push_back(insert_const_ref_type x)
+ void push_back(insert_const_ref_type x)
{ return priv_push_back(x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1045,7 +1051,7 @@ class stable_vector
//! <b>Throws</b>: If memory allocation throws.
//!
//! <b>Complexity</b>: Amortized constant time.
- void push_back(BOOST_RV_REF(T) t)
+ void push_back(BOOST_RV_REF(T) t)
{ this->insert(end(), boost::move(t)); }
//! <b>Effects</b>: Removes the last element from the stable_vector.
@@ -1064,7 +1070,7 @@ class stable_vector
//!
//! <b>Complexity</b>: If position is end(), amortized constant time
//! Linear time otherwise.
- iterator insert(const_iterator position, insert_const_ref_type x)
+ iterator insert(const_iterator position, insert_const_ref_type x)
{ return this->priv_insert(position, x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1084,7 +1090,7 @@ class stable_vector
//!
//! <b>Complexity</b>: If position is end(), amortized constant time
//! Linear time otherwise.
- iterator insert(const_iterator position, BOOST_RV_REF(T) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(T) x)
{
typedef repeat_iterator<T, difference_type> repeat_it;
typedef boost::move_iterator<repeat_it> repeat_move_it;
@@ -1137,7 +1143,7 @@ class stable_vector
void emplace_back(Args &&...args)
{
typedef emplace_functor<Args...> EmplaceFunctor;
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator;
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
}
@@ -1157,7 +1163,7 @@ class stable_vector
//Just call more general insert(pos, size, value) and return iterator
size_type pos_n = position - cbegin();
typedef emplace_functor<Args...> EmplaceFunctor;
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator;
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
this->insert(position, EmplaceIterator(ef), EmplaceIterator());
return iterator(this->begin() + pos_n);
@@ -1172,7 +1178,7 @@ class stable_vector
typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \
BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >) \
EmplaceFunctor; \
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator; \
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator; \
EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \
BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \
BOOST_PP_RPAREN_IF(n); \
@@ -1186,7 +1192,7 @@ class stable_vector
typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \
BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >) \
EmplaceFunctor; \
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator; \
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator; \
EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \
BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \
BOOST_PP_RPAREN_IF(n); \
@@ -1204,7 +1210,7 @@ class stable_vector
//!
//! <b>Throws</b>: Nothing.
//!
- //! <b>Complexity</b>: Linear to the elements between pos and the
+ //! <b>Complexity</b>: Linear to the elements between pos and the
//! last element. Constant if pos is the last element.
iterator erase(const_iterator position)
{
@@ -1482,12 +1488,12 @@ class stable_vector
static node_type_ptr_t node_ptr_cast(const void_ptr &p)
{
- return node_type_ptr_t(static_cast<node_type_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return node_type_ptr_t(static_cast<node_type_t*>(container_detail::to_raw_pointer(p)));
}
static node_type_base_ptr_t node_base_ptr_cast(const void_ptr &p)
{
- return node_type_base_ptr_t(static_cast<node_type_base_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return node_type_base_ptr_t(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p)));
}
static value_type& value(const void_ptr &p)
@@ -1529,7 +1535,9 @@ class stable_vector
{
node_type_ptr_t p = this->allocate_one();
try{
- boost::container::construct_in_place(this->node_alloc(), &*p, it);
+ boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), it);
+ //This does not throw
+ ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
p->set_pointer(up);
}
catch(...){
@@ -1573,7 +1581,7 @@ class stable_vector
{
for(; first!=last; ++first){
this->insert(position, *first);
- }
+ }
}
template <class InputIterator>
@@ -1621,7 +1629,9 @@ class stable_vector
p = mem.front();
mem.pop_front();
//This can throw
- boost::container::construct_in_place(this->node_alloc(), &*p, first);
+ boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+ //This does not throw
+ ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
p->set_pointer(void_ptr_ptr(&it[i]));
++first;
it[i] = p;
@@ -1650,7 +1660,9 @@ class stable_vector
break;
}
//This can throw
- boost::container::construct_in_place(this->node_alloc(), &*p, first);
+ boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+ //This does not throw
+ ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
p->set_pointer(void_ptr_ptr(&it[i]));
++first;
it[i]=p;
@@ -1680,7 +1692,7 @@ class stable_vector
return false;
}
for(const_impl_iterator it = impl.begin(), it_end = get_last_align(); it != it_end; ++it){
- if(const_void_ptr(node_ptr_cast(*it)->up) !=
+ if(const_void_ptr(node_ptr_cast(*it)->up) !=
const_void_ptr(const_void_ptr_ptr(&*it)))
return false;
}
diff --git a/boost/container/string.hpp b/boost/container/string.hpp
index 3a9c55a3c4..2a64cec428 100644
--- a/boost/container/string.hpp
+++ b/boost/container/string.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -43,15 +43,16 @@
#include <boost/container/detail/algorithms.hpp>
#include <boost/container/detail/version_type.hpp>
#include <boost/container/detail/allocation_type.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/move/move.hpp>
#include <boost/static_assert.hpp>
+#include <boost/functional/hash.hpp>
#include <functional>
#include <string>
-#include <stdexcept>
-#include <utility>
+#include <stdexcept>
+#include <utility>
#include <iterator>
#include <memory>
#include <algorithm>
@@ -78,14 +79,14 @@ namespace container {
/// @cond
namespace container_detail {
// ------------------------------------------------------------
-// Class basic_string_base.
+// Class basic_string_base.
// basic_string_base is a helper class that makes it it easier to write
// an exception-safe version of basic_string. The constructor allocates,
// but does not initialize, a block of memory. The destructor
// deallocates, but does not destroy elements within, a block of
-// 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
+// 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>
class basic_string_base
@@ -111,22 +112,22 @@ class basic_string_base
basic_string_base(const allocator_type& a, size_type n)
: members_(a)
- {
- this->init();
+ {
+ this->init();
this->allocate_initial_block(n);
}
basic_string_base(BOOST_RV_REF(basic_string_base) b)
: members_(boost::move(b.alloc()))
- {
+ {
this->init();
- this->swap_data(b);
+ this->swap_data(b);
}
- ~basic_string_base()
- {
+ ~basic_string_base()
+ {
if(!this->is_short()){
- this->deallocate_block();
+ this->deallocate_block();
allocator_traits_type::destroy
( this->alloc()
, static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))
@@ -136,7 +137,7 @@ class basic_string_base
private:
- //This is the structure controlling a long string
+ //This is the structure controlling a long string
struct long_t
{
size_type is_short : 1;
@@ -175,8 +176,8 @@ class basic_string_base
//This type has the same alignment and size as long_t but it's POD
//so, unlike long_t, it can be placed in a union
-
- typedef typename boost::aligned_storage< sizeof(long_t),
+
+ typedef typename boost::aligned_storage< sizeof(long_t),
container_detail::alignment_of<long_t>::value>::type long_raw_t;
protected:
@@ -187,13 +188,13 @@ class basic_string_base
container_detail::ct_rounded_size<sizeof(short_header), AlignmentOfValueType>::value;
static const size_type ZeroCostInternalBufferChars =
(sizeof(long_t) - ShortDataOffset)/sizeof(value_type);
- static const size_type UnalignedFinalInternalBufferChars =
+ static const size_type UnalignedFinalInternalBufferChars =
(ZeroCostInternalBufferChars > MinInternalBufferChars) ?
ZeroCostInternalBufferChars : MinInternalBufferChars;
struct short_t
{
- short_header h;
+ short_header h;
value_type data[UnalignedFinalInternalBufferChars];
};
@@ -241,7 +242,7 @@ class basic_string_base
{ return static_cast<bool>(this->members_.m_repr.s.h.is_short != 0); }
void is_short(bool yes)
- {
+ {
if(yes && !this->is_short()){
allocator_traits_type::destroy
( this->alloc()
@@ -273,7 +274,7 @@ class basic_string_base
std::pair<pointer, bool>
allocation_command(allocation_type command,
- size_type limit_size,
+ size_type limit_size,
size_type preferred_size,
size_type &received_size, pointer reuse = 0)
{
@@ -287,7 +288,7 @@ class basic_string_base
std::pair<pointer, bool>
allocation_command(allocation_type command,
- size_type limit_size,
+ size_type limit_size,
size_type preferred_size,
size_type &received_size,
const pointer &reuse,
@@ -303,21 +304,21 @@ class basic_string_base
std::pair<pointer, bool>
allocation_command(allocation_type command,
- size_type limit_size,
+ size_type limit_size,
size_type preferred_size,
size_type &received_size,
pointer reuse,
allocator_v2)
{
- return this->alloc().allocation_command(command, limit_size, preferred_size,
+ return this->alloc().allocation_command(command, limit_size, preferred_size,
received_size, reuse);
}
size_type next_capacity(size_type additional_objects) const
{ return get_next_capacity(allocator_traits_type::max_size(this->alloc()), this->priv_storage(), additional_objects); }
- void deallocate(pointer p, size_type n)
- {
+ void deallocate(pointer p, size_type n)
+ {
if (p && (n > InternalBufferChars))
this->alloc().deallocate(p, n);
}
@@ -365,9 +366,9 @@ class basic_string_base
throw_length_error();
}
- void deallocate_block()
+ void deallocate_block()
{ this->deallocate(this->priv_addr(), this->priv_storage()); }
-
+
size_type max_size() const
{ return allocator_traits_type::max_size(this->alloc()) - 1; }
@@ -404,13 +405,13 @@ class basic_string_base
{ return this->members_.m_repr.long_repr().storage; }
void priv_storage(size_type storage)
- {
+ {
if(!this->is_short())
this->priv_long_storage(storage);
}
void priv_long_storage(size_type storage)
- {
+ {
this->members_.m_repr.long_repr().storage = storage;
}
@@ -424,7 +425,7 @@ class basic_string_base
{ return this->members_.m_repr.long_repr().length; }
void priv_size(size_type sz)
- {
+ {
if(this->is_short())
this->priv_short_size(sz);
else
@@ -432,12 +433,12 @@ class basic_string_base
}
void priv_short_size(size_type sz)
- {
+ {
this->members_.m_repr.s.h.length = (unsigned char)sz;
}
void priv_long_size(size_type sz)
- {
+ {
this->members_.m_repr.long_repr().length = static_cast<typename allocator_traits_type::size_type>(sz);
}
@@ -470,41 +471,41 @@ class basic_string_base
/// @endcond
-//! The basic_string class represents a Sequence of characters. It contains all the
-//! usual operations of a Sequence, and, additionally, it contains standard string
+//! The basic_string class represents a Sequence of characters. It contains all the
+//! usual operations of a Sequence, and, additionally, it contains standard string
//! operations such as search and concatenation.
//!
-//! The basic_string class is parameterized by character type, and by that type's
+//! The basic_string class is parameterized by character type, and by that type's
//! Character Traits.
-//!
-//! This class has performance characteristics very much like vector<>, meaning,
+//!
+//! This class has performance characteristics very much like vector<>, meaning,
//! for example, that it does not perform reference-count or copy-on-write, and that
-//! concatenation of two strings is an O(N) operation.
-//!
-//! Some of basic_string's member functions use an unusual method of specifying positions
-//! and ranges. In addition to the conventional method using iterators, many of
-//! basic_string's member functions use a single value pos of type size_type to represent a
-//! position (in which case the position is begin() + pos, and many of basic_string's
-//! member functions use two values, pos and n, to represent a range. In that case pos is
-//! the beginning of the range and n is its size. That is, the range is
-//! [begin() + pos, begin() + pos + n).
-//!
-//! Note that the C++ standard does not specify the complexity of basic_string operations.
-//! In this implementation, basic_string has performance characteristics very similar to
-//! those of vector: access to a single character is O(1), while copy and concatenation
+//! concatenation of two strings is an O(N) operation.
+//!
+//! Some of basic_string's member functions use an unusual method of specifying positions
+//! and ranges. In addition to the conventional method using iterators, many of
+//! basic_string's member functions use a single value pos of type size_type to represent a
+//! position (in which case the position is begin() + pos, and many of basic_string's
+//! member functions use two values, pos and n, to represent a range. In that case pos is
+//! the beginning of the range and n is its size. That is, the range is
+//! [begin() + pos, begin() + pos + n).
+//!
+//! Note that the C++ standard does not specify the complexity of basic_string operations.
+//! In this implementation, basic_string has performance characteristics very similar to
+//! those of vector: access to a single character is O(1), while copy and concatenation
//! are O(N).
-//!
-//! In this implementation, begin(),
+//!
+//! In this implementation, begin(),
//! end(), rbegin(), rend(), operator[], c_str(), and data() do not invalidate iterators.
//! In this implementation, iterators are only invalidated by member functions that
-//! explicitly change the string's contents.
+//! 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> >
#else
template <class CharT, class Traits, class A>
#endif
class basic_string
- : private container_detail::basic_string_base<A>
+ : private container_detail::basic_string_base<A>
{
/// @cond
private:
@@ -535,12 +536,12 @@ class basic_string
const Pointer m_first;
const Pointer m_last;
- Not_within_traits(Pointer f, Pointer l)
+ Not_within_traits(Pointer f, Pointer l)
: m_first(f), m_last(l) {}
- bool operator()(const typename Tr::char_type& x) const
+ bool operator()(const typename Tr::char_type& x) const
{
- return std::find_if(m_first, m_last,
+ return std::find_if(m_first, m_last,
std::bind1st(Eq_traits<Tr>(), x)) == m_last;
}
};
@@ -558,11 +559,11 @@ class basic_string
typedef Traits traits_type;
//! Pointer to CharT
typedef typename allocator_traits_type::pointer pointer;
- //! Const pointer to CharT
+ //! Const pointer to CharT
typedef typename allocator_traits_type::const_pointer const_pointer;
- //! Reference to CharT
+ //! Reference to CharT
typedef typename allocator_traits_type::reference reference;
- //! Const reference to CharT
+ //! Const reference to CharT
typedef typename allocator_traits_type::const_reference const_reference;
//! An unsigned integral type
typedef typename allocator_traits_type::size_type size_type;
@@ -576,7 +577,7 @@ class basic_string
typedef std::reverse_iterator<iterator> reverse_iterator;
//! Const iterator used to iterate backwards through a string
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- //! The largest possible value of type size_type. That is, size_type(-1).
+ //! The largest possible value of type size_type. That is, size_type(-1).
static const size_type npos;
/// @cond
@@ -602,7 +603,7 @@ class basic_string
/// @endcond
//! <b>Effects</b>: Default constructs a basic_string.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor throws.
basic_string()
: base_t()
@@ -610,7 +611,7 @@ class basic_string
//! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
explicit basic_string(const allocator_type& a)
: base_t(a)
@@ -619,26 +620,52 @@ class basic_string
//! <b>Effects</b>: Copy constructs a basic_string.
//!
//! <b>Postcondition</b>: x == *this.
- //!
- //! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
- basic_string(const basic_string& s)
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor throws.
+ basic_string(const basic_string& s)
: base_t(allocator_traits_type::select_on_container_copy_construction(s.alloc()))
{ this->priv_range_initialize(s.begin(), s.end()); }
- //! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
+ //! <b>Effects</b>: Move constructor. Moves s's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- basic_string(BOOST_RV_REF(basic_string) s)
+ basic_string(BOOST_RV_REF(basic_string) s)
: base_t(boost::move((base_t&)s))
{}
+ //! <b>Effects</b>: Copy constructs a basic_string using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Throws</b>: If allocation throws.
+ basic_string(const basic_string& s, const allocator_type &a)
+ : base_t(a)
+ { this->priv_range_initialize(s.begin(), s.end()); }
+
+ //! <b>Effects</b>: Move constructor using the specified allocator.
+ //! Moves s's resources to *this.
+ //!
+ //! <b>Throws</b>: If allocation throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == s.get_allocator(), linear otherwise.
+ basic_string(BOOST_RV_REF(basic_string) s, const allocator_type &a)
+ : base_t(a)
+ {
+ if(a == this->alloc()){
+ this->swap_data(s);
+ }
+ else{
+ this->priv_range_initialize(s.begin(), s.end());
+ }
+ }
+
//! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
- //! and is initialized by a specific number of characters of the s string.
+ //! and is initialized by a specific number of characters of the s string.
basic_string(const basic_string& s, size_type pos, size_type n = npos,
- const allocator_type& a = allocator_type())
- : base_t(a)
+ const allocator_type& a = allocator_type())
+ : base_t(a)
{
if (pos > s.size())
this->throw_out_of_range();
@@ -650,15 +677,15 @@ class basic_string
//! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
//! and is initialized by a specific number of characters of the s c-string.
basic_string(const CharT* s, size_type n,
- const allocator_type& a = allocator_type())
- : base_t(a)
+ const allocator_type& a = allocator_type())
+ : base_t(a)
{ this->priv_range_initialize(s, s + n); }
//! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
//! and is initialized by the null-terminated s c-string.
basic_string(const CharT* s,
const allocator_type& a = allocator_type())
- : base_t(a)
+ : base_t(a)
{ this->priv_range_initialize(s, s + Traits::length(s)); }
//! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
@@ -666,7 +693,7 @@ class basic_string
basic_string(size_type n, CharT c,
const allocator_type& a = allocator_type())
: base_t(a)
- {
+ {
this->priv_range_initialize(cvalue_iterator(c, n),
cvalue_iterator());
}
@@ -689,13 +716,13 @@ class basic_string
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- ~basic_string()
+ ~basic_string()
{}
-
+
//! <b>Effects</b>: Copy constructs a string.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
basic_string& operator=(BOOST_COPY_ASSIGN_REF(basic_string) x)
{
@@ -721,7 +748,7 @@ class basic_string
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
basic_string& operator=(BOOST_RV_REF(basic_string) x)
{
@@ -747,7 +774,7 @@ class basic_string
}
//! <b>Effects</b>: Assignment from a null-terminated c-string.
- basic_string& operator=(const CharT* s)
+ basic_string& operator=(const CharT* s)
{ return this->assign(s, s + Traits::length(s)); }
//! <b>Effects</b>: Assignment from character.
@@ -755,155 +782,155 @@ class basic_string
{ return this->assign(static_cast<size_type>(1), c); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator begin()
{ return this->priv_addr(); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator begin() const
{ return this->priv_addr(); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbegin() const
{ return this->priv_addr(); }
//! <b>Effects</b>: Returns an iterator to the end of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end()
{ return this->priv_addr() + this->priv_size(); }
//! <b>Effects</b>: Returns a const_iterator to the end of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_iterator end() const
- { return this->priv_addr() + this->priv_size(); }
+ const_iterator end() const
+ { return this->priv_addr() + this->priv_size(); }
//! <b>Effects</b>: Returns a const_iterator to the end of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_iterator cend() const
- { return this->priv_addr() + this->priv_size(); }
+ const_iterator cend() const
+ { return this->priv_addr() + this->priv_size(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed vector.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin()
+ reverse_iterator rbegin()
{ return reverse_iterator(this->priv_addr() + this->priv_size()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rbegin() const
+ const_reverse_iterator rbegin() const
{ return this->crbegin(); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crbegin() const
+ const_reverse_iterator crbegin() const
{ return const_reverse_iterator(this->priv_addr() + this->priv_size()); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed vector.
- //!
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend()
+ reverse_iterator rend()
{ return reverse_iterator(this->priv_addr()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed vector.
- //!
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const
+ const_reverse_iterator rend() const
{ return this->crend(); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed vector.
- //!
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const
+ const_reverse_iterator crend() const
{ return const_reverse_iterator(this->priv_addr()); }
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const
+ allocator_type get_allocator() const
{ return this->alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
{ return this->alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
{ return this->alloc(); }
//! <b>Effects</b>: Returns the number of the elements contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- size_type size() const
+ size_type size() const
{ return this->priv_size(); }
//! <b>Effects</b>: Returns the number of the elements contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type length() const
{ return this->size(); }
//! <b>Effects</b>: Returns the largest possible size of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type max_size() const
{ return base_t::max_size(); }
@@ -935,7 +962,7 @@ class basic_string
//! 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
void reserve(size_type res_arg)
{
@@ -962,9 +989,9 @@ class basic_string
//! <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 this->priv_capacity(); }
@@ -1014,42 +1041,42 @@ class basic_string
}
//! <b>Effects</b>: Returns true if the vector contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
bool empty() const
{ return !this->priv_size(); }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference operator[](size_type n)
{ return *(this->priv_addr() + n); }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference operator[](size_type n) const
{ return *(this->priv_addr() + n); }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference at(size_type n) {
if (n >= size())
@@ -1059,11 +1086,11 @@ class basic_string
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference at(size_type n) const {
if (n >= size())
@@ -1092,12 +1119,12 @@ class basic_string
//! <b>Effects</b>: Calls append(str.data(), str.size()).
//!
//! <b>Returns</b>: *this
- basic_string& append(const basic_string& s)
+ basic_string& append(const basic_string& s)
{ return this->append(s.begin(), s.end()); }
//! <b>Requires</b>: pos <= str.size()
//!
- //! <b>Effects</b>: Determines the effective length rlen of the string to append
+ //! <b>Effects</b>: Determines the effective length rlen of the string to append
//! as the smaller of n and str.size() - pos and calls append(str.data() + pos, rlen).
//!
//! <b>Throws</b>: If memory allocation throws and out_of_range if pos > str.size()
@@ -1121,7 +1148,7 @@ class basic_string
//! <b>Throws</b>: If memory allocation throws length_error if size() + n > max_size().
//!
//! <b>Returns</b>: *this
- basic_string& append(const CharT* s, size_type n)
+ basic_string& append(const CharT* s, size_type n)
{ return this->append(s, s + n); }
//! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT.
@@ -1129,7 +1156,7 @@ class basic_string
//! <b>Effects</b>: Calls append(s, traits::length(s)).
//!
//! <b>Returns</b>: *this
- basic_string& append(const CharT* s)
+ basic_string& append(const CharT* s)
{ return this->append(s, s + Traits::length(s)); }
//! <b>Effects</b>: Equivalent to append(basic_string(n, c)).
@@ -1164,17 +1191,17 @@ class basic_string
//! <b>Effects</b>: Equivalent to assign(str, 0, npos).
//!
//! <b>Returns</b>: *this
- basic_string& assign(const basic_string& s)
+ basic_string& assign(const basic_string& s)
{ return this->operator=(s); }
//! <b>Effects</b>: The function replaces the string controlled by *this
- //! with a string of length str.size() whose elements are a copy of the string
+ //! with a string of length str.size() whose elements are a copy of the string
//! controlled by str. Leaves str in a valid but unspecified state.
//!
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: *this
- basic_string& assign(BOOST_RV_REF(basic_string) ms)
+ basic_string& assign(BOOST_RV_REF(basic_string) ms)
{ return this->swap_data(ms), *this; }
//! <b>Requires</b>: pos <= str.size()
@@ -1185,11 +1212,11 @@ class basic_string
//! <b>Throws</b>: If memory allocation throws or out_of_range if pos > str.size().
//!
//! <b>Returns</b>: *this
- basic_string& assign(const basic_string& s,
+ basic_string& assign(const basic_string& s,
size_type pos, size_type n) {
if (pos > s.size())
this->throw_out_of_range();
- return this->assign(s.begin() + pos,
+ return this->assign(s.begin() + pos,
s.begin() + pos + container_detail::min_value(n, s.size() - pos));
}
@@ -1199,7 +1226,7 @@ class basic_string
//! length n whose elements are a copy of those pointed to by s.
//!
//! <b>Throws</b>: If memory allocation throws or length_error if n > max_size().
- //!
+ //!
//! <b>Returns</b>: *this
basic_string& assign(const CharT* s, size_type n)
{ return this->assign(s, s + n); }
@@ -1222,7 +1249,7 @@ class basic_string
//!
//! <b>Returns</b>: *this
template <class InputIter>
- basic_string& assign(InputIter first, InputIter last)
+ basic_string& assign(InputIter first, InputIter last)
{
//Dispatch depending on integer/iterator
const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value;
@@ -1237,7 +1264,7 @@ class basic_string
//! <b>Throws</b>: If memory allocation throws or out_of_range if pos > size().
//!
//! <b>Returns</b>: *this
- basic_string& insert(size_type pos, const basic_string& s)
+ basic_string& insert(size_type pos, const basic_string& s)
{
if (pos > size())
this->throw_out_of_range();
@@ -1256,7 +1283,7 @@ class basic_string
//!
//! <b>Returns</b>: *this
basic_string& insert(size_type pos1, const basic_string& s,
- size_type pos2, size_type n)
+ size_type pos2, size_type n)
{
if (pos1 > this->size() || pos2 > s.size())
this->throw_out_of_range();
@@ -1280,7 +1307,7 @@ class basic_string
//! length_error if size() + n > max_size().
//!
//! <b>Returns</b>: *this
- basic_string& insert(size_type pos, const CharT* s, size_type n)
+ basic_string& insert(size_type pos, const CharT* s, size_type n)
{
if (pos > this->size())
this->throw_out_of_range();
@@ -1298,7 +1325,7 @@ class basic_string
//! length_error if size() > max_size() - Traits::length(s)
//!
//! <b>Returns</b>: *this
- basic_string& insert(size_type pos, const CharT* s)
+ basic_string& insert(size_type pos, const CharT* s)
{
if (pos > size())
this->throw_out_of_range();
@@ -1315,7 +1342,7 @@ class basic_string
//! length_error if size() > max_size() - n
//!
//! <b>Returns</b>: *this
- basic_string& insert(size_type pos, size_type n, CharT c)
+ basic_string& insert(size_type pos, size_type n, CharT c)
{
if (pos > this->size())
this->throw_out_of_range();
@@ -1330,7 +1357,7 @@ class basic_string
//! <b>Effects</b>: inserts a copy of c before the character referred to by p.
//!
//! <b>Returns</b>: An iterator which refers to the copy of the inserted character.
- iterator insert(const_iterator p, CharT c)
+ iterator insert(const_iterator p, CharT c)
{
size_type new_offset = p - this->priv_addr() + 1;
this->insert(p, cvalue_iterator(c, 1), cvalue_iterator());
@@ -1356,7 +1383,7 @@ class basic_string
//! <b>Returns</b>: An iterator which refers to the copy of the first
//! inserted character, or p if first == last.
template <class InputIter>
- void insert(const_iterator p, InputIter first, InputIter last)
+ void insert(const_iterator p, InputIter first, InputIter last)
{
//Dispatch depending on integer/iterator
const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value;
@@ -1375,13 +1402,13 @@ class basic_string
//! <b>Throws</b>: out_of_range if pos > size().
//!
//! <b>Returns</b>: *this
- basic_string& erase(size_type pos = 0, size_type n = npos)
+ basic_string& erase(size_type pos = 0, size_type n = npos)
{
if (pos > size())
this->throw_out_of_range();
erase(this->priv_addr() + pos, this->priv_addr() + pos + container_detail::min_value(n, size() - pos));
return *this;
- }
+ }
//! <b>Effects</b>: Removes the character referred to by p.
//!
@@ -1389,12 +1416,12 @@ class basic_string
//!
//! <b>Returns</b>: An iterator which points to the element immediately following p prior to the element being
//! erased. If no such element exists, end() is returned.
- iterator erase(const_iterator p)
+ iterator erase(const_iterator p)
{
// The move includes the terminating null.
CharT *ptr = const_cast<CharT*>(container_detail::to_raw_pointer(p));
Traits::move(ptr,
- container_detail::to_raw_pointer(p + 1),
+ container_detail::to_raw_pointer(p + 1),
this->priv_size() - (p - this->priv_addr()));
this->priv_size(this->priv_size()-1);
return iterator(ptr);
@@ -1414,7 +1441,7 @@ class basic_string
if (first != last) { // The move includes the terminating null.
size_type num_erased = last - first;
Traits::move(f,
- container_detail::to_raw_pointer(last),
+ container_detail::to_raw_pointer(last),
(this->priv_size() + 1)-(last - this->priv_addr()));
size_type new_length = this->priv_size() - num_erased;
this->priv_size(new_length);
@@ -1440,14 +1467,14 @@ class basic_string
//! <b>Throws</b>: if memory allocation throws or out_of_range if pos1 > size().
//!
//! <b>Returns</b>: *this
- basic_string& replace(size_type pos1, size_type n1, const basic_string& str)
+ basic_string& replace(size_type pos1, size_type n1, const basic_string& str)
{
if (pos1 > size())
this->throw_out_of_range();
const size_type len = container_detail::min_value(n1, size() - pos1);
if (this->size() - len >= this->max_size() - str.size())
this->throw_length_error();
- return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len,
+ return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len,
str.begin(), str.end());
}
@@ -1461,7 +1488,7 @@ class basic_string
//!
//! <b>Returns</b>: *this
basic_string& replace(size_type pos1, size_type n1,
- const basic_string& str, size_type pos2, size_type n2)
+ const basic_string& str, size_type pos2, size_type n2)
{
if (pos1 > size() || pos2 > str.size())
this->throw_out_of_range();
@@ -1475,20 +1502,20 @@ class basic_string
//! <b>Requires</b>: pos1 <= size() and s points to an array of at least n2 elements of CharT.
//!
- //! <b>Effects</b>: Determines the effective length xlen of the string to be removed as the
- //! smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error.
- //! Otherwise, the function replaces the string controlled by *this with a string of
- //! length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements
- //! of the original string controlled by *this, whose next n2 elements are a copy of the
- //! initial n2 elements of s, and whose remaining elements are a copy of the elements of
+ //! <b>Effects</b>: Determines the effective length xlen of the string to be removed as the
+ //! smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error.
+ //! Otherwise, the function replaces the string controlled by *this with a string of
+ //! length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements
+ //! of the original string controlled by *this, whose next n2 elements are a copy of the
+ //! initial n2 elements of s, and whose remaining elements are a copy of the elements of
//! the original string controlled by *this beginning at position pos + xlen.
//!
- //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or length_error
+ //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or length_error
//! if the length of the resulting string would exceed max_size()
//!
//! <b>Returns</b>: *this
basic_string& replace(size_type pos1, size_type n1,
- const CharT* s, size_type n2)
+ const CharT* s, size_type n2)
{
if (pos1 > size())
this->throw_out_of_range();
@@ -1509,11 +1536,11 @@ class basic_string
//! remaining elements are a copy of the elements of the original string controlled by *this
//! beginning at position pos + xlen.
//!
- //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or length_error
+ //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or length_error
//! if the length of the resulting string would exceed max_size()
//!
//! <b>Returns</b>: *this
- basic_string& replace(size_type pos, size_type n1, const CharT* s)
+ basic_string& replace(size_type pos, size_type n1, const CharT* s)
{
if (pos > size())
this->throw_out_of_range();
@@ -1529,11 +1556,11 @@ class basic_string
//!
//! <b>Effects</b>: Equivalent to replace(pos1, n1, basic_string(n2, c)).
//!
- //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or length_error
+ //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or length_error
//! if the length of the resulting string would exceed max_size()
//!
//! <b>Returns</b>: *this
- basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c)
+ basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c)
{
if (pos1 > size())
this->throw_out_of_range();
@@ -1550,10 +1577,10 @@ class basic_string
//! <b>Throws</b>: if memory allocation throws
//!
//! <b>Returns</b>: *this
- basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str)
+ basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str)
{ return this->replace(i1, i2, str.begin(), str.end()); }
- //! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges and
+ //! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges and
//! s points to an array of at least n elements
//!
//! <b>Effects</b>: Calls replace(i1 - begin(), i2 - i1, s, n).
@@ -1561,7 +1588,7 @@ class basic_string
//! <b>Throws</b>: if memory allocation throws
//!
//! <b>Returns</b>: *this
- basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s, size_type n)
+ basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s, size_type n)
{ return this->replace(i1, i2, s, s + n); }
//! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges and s points to an
@@ -1572,7 +1599,7 @@ class basic_string
//! <b>Throws</b>: if memory allocation throws
//!
//! <b>Returns</b>: *this
- basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s)
+ basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s)
{ return this->replace(i1, i2, s, s + Traits::length(s)); }
//! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges.
@@ -1604,7 +1631,7 @@ class basic_string
//!
//! <b>Returns</b>: *this
template <class InputIter>
- basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2)
+ basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2)
{
//Dispatch depending on integer/iterator
const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value;
@@ -1616,14 +1643,14 @@ class basic_string
//!
//! <b>Effects</b>: Determines the effective length rlen of the string to copy as the
//! smaller of n and size() - pos. s shall designate an array of at least rlen elements.
- //! The function then replaces the string designated by s with a string of length rlen
+ //! The function then replaces the string designated by s with a string of length rlen
//! whose elements are a copy of the string controlled by *this beginning at position pos.
//! The function does not append a null object to the string designated by s.
//!
//! <b>Throws</b>: if memory allocation throws, out_of_range if pos > size().
//!
//! <b>Returns</b>: rlen
- size_type copy(CharT* s, size_type n, size_type pos = 0) const
+ size_type copy(CharT* s, size_type n, size_type pos = 0) const
{
if (pos > size())
this->throw_out_of_range();
@@ -1632,7 +1659,7 @@ class basic_string
return len;
}
- //! <b>Effects</b>: *this contains the same sequence of characters that was in s,
+ //! <b>Effects</b>: *this contains the same sequence of characters that was in s,
//! s contains the same sequence of characters that was in *this.
//!
//! <b>Throws</b>: Nothing
@@ -1648,7 +1675,7 @@ class basic_string
//! <b>Returns</b>: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
//!
//! <b>Complexity</b>: constant time.
- const CharT* c_str() const
+ const CharT* c_str() const
{ return container_detail::to_raw_pointer(this->priv_addr()); }
//! <b>Requires</b>: The program shall not alter any of the values stored in the character array.
@@ -1656,17 +1683,17 @@ class basic_string
//! <b>Returns</b>: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
//!
//! <b>Complexity</b>: constant time.
- const CharT* data() const
+ const CharT* data() const
{ return container_detail::to_raw_pointer(this->priv_addr()); }
- //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that both
+ //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that both
//! of the following conditions obtain: 19 pos <= xpos and xpos + str.size() <= size();
//! 2) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.
//!
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
- size_type find(const basic_string& s, size_type pos = 0) const
+ size_type find(const basic_string& s, size_type pos = 0) const
{ return find(s.c_str(), pos, s.size()); }
//! <b>Requires</b>: s points to an array of at least n elements of CharT.
@@ -1681,7 +1708,7 @@ class basic_string
else {
pointer finish = this->priv_addr() + this->priv_size();
const const_iterator result =
- std::search(container_detail::to_raw_pointer(this->priv_addr() + pos),
+ std::search(container_detail::to_raw_pointer(this->priv_addr() + pos),
container_detail::to_raw_pointer(finish),
s, s + n, Eq_traits<Traits>());
return result != finish ? result - begin() : npos;
@@ -1693,7 +1720,7 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: find(basic_string(s), pos).
- size_type find(const CharT* s, size_type pos = 0) const
+ size_type find(const CharT* s, size_type pos = 0) const
{ return find(s, pos, Traits::length(s)); }
//! <b>Throws</b>: Nothing
@@ -1712,7 +1739,7 @@ class basic_string
}
}
- //! <b>Effects</b>: Determines the highest position xpos, if possible, such
+ //! <b>Effects</b>: Determines the highest position xpos, if possible, such
//! that both of the following conditions obtain:
//! a) xpos <= pos and xpos + str.size() <= size();
//! b) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.
@@ -1720,7 +1747,7 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
- size_type rfind(const basic_string& str, size_type pos = npos) const
+ size_type rfind(const basic_string& str, size_type pos = npos) const
{ return rfind(str.c_str(), pos, str.size()); }
//! <b>Requires</b>: s points to an array of at least n elements of CharT.
@@ -1745,13 +1772,13 @@ class basic_string
}
}
- //! <b>Requires</b>: pos <= size() and s points to an array of at least
+ //! <b>Requires</b>: pos <= size() and s points to an array of at least
//! traits::length(s) + 1 elements of CharT.
//!
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: rfind(basic_string(s), pos).
- size_type rfind(const CharT* s, size_type pos = npos) const
+ size_type rfind(const CharT* s, size_type pos = npos) const
{ return rfind(s, pos, Traits::length(s)); }
//! <b>Throws</b>: Nothing
@@ -1779,7 +1806,7 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
- size_type find_first_of(const basic_string& s, size_type pos = 0) const
+ size_type find_first_of(const basic_string& s, size_type pos = 0) const
{ return find_first_of(s.c_str(), pos, s.size()); }
//! <b>Requires</b>: s points to an array of at least n elements of CharT.
@@ -1805,7 +1832,7 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: find_first_of(basic_string(s), pos).
- size_type find_first_of(const CharT* s, size_type pos = 0) const
+ size_type find_first_of(const CharT* s, size_type pos = 0) const
{ return find_first_of(s, pos, Traits::length(s)); }
//! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT.
@@ -1813,10 +1840,10 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: find_first_of(basic_string<CharT,traits,Allocator>(1,c), pos).
- size_type find_first_of(CharT c, size_type pos = 0) const
+ size_type find_first_of(CharT c, size_type pos = 0) const
{ return find(c, pos); }
- //! <b>Effects</b>: Determines the highest position xpos, if possible, such that both of
+ //! <b>Effects</b>: Determines the highest position xpos, if possible, such that both of
//! the following conditions obtain: a) xpos <= pos and xpos < size(); b)
//! traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.
//!
@@ -1852,16 +1879,16 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: find_last_of(basic_string<CharT,traits,Allocator>(1,c),pos).
- size_type find_last_of(const CharT* s, size_type pos = npos) const
+ size_type find_last_of(const CharT* s, size_type pos = npos) const
{ return find_last_of(s, pos, Traits::length(s)); }
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: find_last_of(basic_string(s), pos).
- size_type find_last_of(CharT c, size_type pos = npos) const
+ size_type find_last_of(CharT c, size_type pos = npos) const
{ return rfind(c, pos); }
- //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that
+ //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that
//! both of the following conditions obtain:
//! a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for no
//! element I of the string controlled by str.
@@ -1869,7 +1896,7 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
- size_type find_first_not_of(const basic_string& str, size_type pos = 0) const
+ size_type find_first_not_of(const basic_string& str, size_type pos = 0) const
{ return find_first_not_of(str.c_str(), pos, str.size()); }
//! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT.
@@ -1894,7 +1921,7 @@ class basic_string
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: find_first_not_of(basic_string(s), pos).
- size_type find_first_not_of(const CharT* s, size_type pos = 0) const
+ size_type find_first_not_of(const CharT* s, size_type pos = 0) const
{ return find_first_not_of(s, pos, Traits::length(s)); }
//! <b>Throws</b>: Nothing
@@ -1914,7 +1941,7 @@ class basic_string
}
//! <b>Effects</b>: Determines the highest position xpos, if possible, such that
- //! both of the following conditions obtain: a) xpos <= pos and xpos < size();
+ //! both of the following conditions obtain: a) xpos <= pos and xpos < size();
//! b) traits::eq(at(xpos), str.at(I)) for no element I of the string controlled by str.
//!
//! <b>Throws</b>: Nothing
@@ -1977,11 +2004,11 @@ class basic_string
//! <b>Throws</b>: If memory allocation throws or out_of_range if pos > size().
//!
//! <b>Returns</b>: basic_string<CharT,traits,Allocator>(data()+pos,rlen).
- basic_string substr(size_type pos = 0, size_type n = npos) const
+ basic_string substr(size_type pos = 0, size_type n = npos) const
{
if (pos > size())
this->throw_out_of_range();
- return basic_string(this->priv_addr() + pos,
+ return basic_string(this->priv_addr() + pos,
this->priv_addr() + pos + container_detail::min_value(n, size() - pos), this->alloc());
}
@@ -1994,7 +2021,7 @@ class basic_string
//! <b>Returns</b>: The nonzero result if the result of the comparison is nonzero.
//! Otherwise, returns a value < 0 if size() < str.size(), a 0 value if size() == str.size(),
//! and value > 0 if size() > str.size()
- int compare(const basic_string& str) const
+ int compare(const basic_string& str) const
{ return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), str.priv_addr(), str.priv_addr() + str.priv_size()); }
//! <b>Requires</b>: pos1 <= size()
@@ -2005,16 +2032,16 @@ class basic_string
//! <b>Throws</b>: out_of_range if pos1 > size()
//!
//! <b>Returns</b>:basic_string(*this,pos1,n1).compare(str).
- int compare(size_type pos1, size_type n1, const basic_string& str) const
+ int compare(size_type pos1, size_type n1, const basic_string& str) const
{
if (pos1 > size())
this->throw_out_of_range();
- return s_compare(this->priv_addr() + pos1,
+ return s_compare(this->priv_addr() + pos1,
this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
str.priv_addr(), str.priv_addr() + str.priv_size());
}
- //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size()
+ //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size()
//!
//! <b>Effects</b>: Determines the effective length rlen of the string to copy as
//! the smaller of
@@ -2022,20 +2049,20 @@ class basic_string
//! <b>Throws</b>: out_of_range if pos1 > size() or pos2 > str.size()
//!
//! <b>Returns</b>: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)).
- int compare(size_type pos1, size_type n1,
+ int compare(size_type pos1, size_type n1,
const basic_string& str, size_type pos2, size_type n2) const {
if (pos1 > size() || pos2 > str.size())
this->throw_out_of_range();
- return s_compare(this->priv_addr() + pos1,
+ return s_compare(this->priv_addr() + pos1,
this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
- str.priv_addr() + pos2,
+ str.priv_addr() + pos2,
str.priv_addr() + pos2 + container_detail::min_value(n2, size() - pos2));
}
//! <b>Throws</b>: Nothing
//!
//! <b>Returns</b>: compare(basic_string(s)).
- int compare(const CharT* s) const
+ int compare(const CharT* s) const
{ return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), s, s + Traits::length(s)); }
@@ -2045,11 +2072,11 @@ class basic_string
//!
//! <b>Returns</b>: basic_string(*this, pos, n1).compare(basic_string(s, n2)).
int compare(size_type pos1, size_type n1,
- const CharT* s, size_type n2) const
+ const CharT* s, size_type n2) const
{
if (pos1 > size())
this->throw_out_of_range();
- return s_compare(this->priv_addr() + pos1,
+ return s_compare(this->priv_addr() + pos1,
this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
s, s + n2);
}
@@ -2059,18 +2086,18 @@ class basic_string
//! <b>Throws</b>: out_of_range if pos1 > size()
//!
//! <b>Returns</b>: basic_string(*this, pos, n1).compare(basic_string(s, n2)).
- int compare(size_type pos1, size_type n1, const CharT* s) const
+ int compare(size_type pos1, size_type n1, const CharT* s) const
{ return this->compare(pos1, n1, s, Traits::length(s)); }
/// @cond
private:
static int s_compare(const_pointer f1, const_pointer l1,
- const_pointer f2, const_pointer l2)
+ const_pointer f2, const_pointer l2)
{
const difference_type n1 = l1 - f1;
const difference_type n2 = l2 - f2;
- const int cmp = Traits::compare(container_detail::to_raw_pointer(f1),
- container_detail::to_raw_pointer(f2),
+ const int cmp = Traits::compare(container_detail::to_raw_pointer(f1),
+ container_detail::to_raw_pointer(f2),
container_detail::min_value(n1, n2));
return cmp != 0 ? cmp : (n1 < n2 ? -1 : (n1 > n2 ? 1 : 0));
}
@@ -2105,7 +2132,7 @@ class basic_string
template<class AllocVersion>
void priv_shrink_to_fit_dynamic_buffer
- ( AllocVersion
+ ( AllocVersion
, typename container_detail::enable_if<container_detail::is_same<AllocVersion, allocator_v2> >::type* = 0)
{
size_type received_size;
@@ -2125,7 +2152,7 @@ class basic_string
// Helper functions used by constructors. It is a severe error for
// any of them to be called anywhere except from within constructors.
- void priv_terminate_string()
+ void priv_terminate_string()
{ this->priv_construct_null(this->priv_addr() + this->priv_size()); }
template <class InputIter>
@@ -2138,7 +2165,7 @@ class basic_string
}
template <class ForwardIter>
- void priv_range_initialize(ForwardIter f, ForwardIter l,
+ void priv_range_initialize(ForwardIter f, ForwardIter l,
std::forward_iterator_tag)
{
difference_type n = std::distance(f, l);
@@ -2167,7 +2194,7 @@ class basic_string
template <class InputIter>
void priv_initialize_dispatch(InputIter f, InputIter l, container_detail::false_)
{ this->priv_range_initialize(f, l); }
-
+
template<class FwdIt, class Count> inline
void priv_uninitialized_fill_n(FwdIt first, Count count, const CharT val)
{
@@ -2215,7 +2242,7 @@ class basic_string
}
template <class Integer>
- basic_string& priv_assign_dispatch(Integer n, Integer x, container_detail::true_)
+ basic_string& priv_assign_dispatch(Integer n, Integer x, container_detail::true_)
{ return this->assign((size_type) n, (CharT) x); }
template <class InputIter>
@@ -2246,7 +2273,7 @@ class basic_string
}
template <class ForwardIter>
- void priv_insert(const_iterator position, ForwardIter first,
+ void priv_insert(const_iterator position, ForwardIter first,
ForwardIter last, std::forward_iterator_tag)
{
if (first != last) {
@@ -2260,13 +2287,13 @@ class basic_string
//Check if we have enough capacity
if (remaining >= n){
- enough_capacity = true;
+ enough_capacity = true;
}
else {
//Otherwise expand current buffer or allocate new storage
new_cap = this->next_capacity(n);
allocation_ret = this->allocation_command
- (allocate_new | expand_fwd | expand_bwd, old_size + n + 1,
+ (allocate_new | expand_fwd | expand_bwd, old_size + n + 1,
new_cap, new_cap, old_start);
//Check forward expansion
@@ -2327,7 +2354,7 @@ class basic_string
this->priv_long_storage(new_cap);
}
else{
- //value_type is POD, so backwards expansion is much easier
+ //value_type is POD, so backwards expansion is much easier
//than with vector<T>
value_type *oldbuf = container_detail::to_raw_pointer(old_start);
value_type *newbuf = container_detail::to_raw_pointer(new_start);
@@ -2351,12 +2378,12 @@ class basic_string
template <class Integer>
void priv_insert_dispatch(const_iterator p, Integer n, Integer x,
- container_detail::true_)
+ container_detail::true_)
{ insert(p, (size_type) n, (CharT) x); }
template <class InputIter>
void priv_insert_dispatch(const_iterator p, InputIter first, InputIter last,
- container_detail::false_)
+ container_detail::false_)
{
typedef typename std::iterator_traits<InputIter>::iterator_category Category;
priv_insert(p, first, last, Category());
@@ -2369,19 +2396,19 @@ class basic_string
Traits::assign(*result, *first);
}
- void priv_copy(const CharT* first, const CharT* last, CharT* result)
+ void priv_copy(const CharT* first, const CharT* last, CharT* result)
{ Traits::copy(result, first, last - first); }
template <class Integer>
basic_string& priv_replace_dispatch(const_iterator first, const_iterator last,
Integer n, Integer x,
- container_detail::true_)
+ container_detail::true_)
{ return this->replace(first, last, (size_type) n, (CharT) x); }
template <class InputIter>
basic_string& priv_replace_dispatch(const_iterator first, const_iterator last,
InputIter f, InputIter l,
- container_detail::false_)
+ container_detail::false_)
{
typedef typename std::iterator_traits<InputIter>::iterator_category Category;
return this->priv_replace(first, last, f, l, Category());
@@ -2404,7 +2431,7 @@ class basic_string
template <class ForwardIter>
basic_string& priv_replace(const_iterator first, const_iterator last,
- ForwardIter f, ForwardIter l,
+ ForwardIter f, ForwardIter l,
std::forward_iterator_tag)
{
difference_type n = std::distance(f, l);
@@ -2442,9 +2469,9 @@ wstring;
/// @cond
-template <class CharT, class Traits, class A>
-const typename basic_string<CharT,Traits,A>::size_type
-basic_string<CharT,Traits,A>::npos
+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;
/// @endcond
@@ -2500,7 +2527,7 @@ BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A)
template <class CharT, class Traits, class A>
inline basic_string<CharT,Traits,A>
-operator+(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator+(const CharT* s, const basic_string<CharT,Traits,A>& y)
{
typedef basic_string<CharT, Traits, A> str_t;
typedef typename str_t::reserve_t reserve_t;
@@ -2523,7 +2550,7 @@ operator+(const CharT* s,
template <class CharT, class Traits, class A>
inline basic_string<CharT,Traits,A>
-operator+(CharT c, const basic_string<CharT,Traits,A>& y)
+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;
@@ -2545,7 +2572,7 @@ operator+(CharT c,
template <class CharT, class Traits, class A>
inline basic_string<CharT,Traits,A>
-operator+(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator+(const basic_string<CharT,Traits,A>& x, const CharT* s)
{
typedef basic_string<CharT,Traits,A> str_t;
typedef typename str_t::reserve_t reserve_t;
@@ -2568,7 +2595,7 @@ operator+(BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
template <class CharT, class Traits, class A>
inline basic_string<CharT,Traits,A>
-operator+(const basic_string<CharT,Traits,A>& x, const CharT c)
+operator+(const basic_string<CharT,Traits,A>& x, const CharT c)
{
typedef basic_string<CharT,Traits,A> str_t;
typedef typename str_t::reserve_t reserve_t;
@@ -2593,7 +2620,7 @@ operator+( BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx
template <class CharT, class Traits, class A>
inline bool
operator==(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+ const basic_string<CharT,Traits,A>& y)
{
return x.size() == y.size() &&
Traits::compare(x.data(), y.data(), x.size()) == 0;
@@ -2601,7 +2628,7 @@ operator==(const basic_string<CharT,Traits,A>& x,
template <class CharT, class Traits, class A>
inline bool
-operator==(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator==(const CharT* s, const basic_string<CharT,Traits,A>& y)
{
typename basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
return n == y.size() && Traits::compare(s, y.data(), n) == 0;
@@ -2609,7 +2636,7 @@ operator==(const CharT* s, const basic_string<CharT,Traits,A>& y)
template <class CharT, class Traits, class A>
inline bool
-operator==(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator==(const basic_string<CharT,Traits,A>& x, const CharT* s)
{
typename basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
return x.size() == n && Traits::compare(x.data(), s, n) == 0;
@@ -2618,17 +2645,17 @@ operator==(const basic_string<CharT,Traits,A>& x, const CharT* s)
template <class CharT, class Traits, class A>
inline bool
operator!=(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+ const basic_string<CharT,Traits,A>& y)
{ return !(x == y); }
template <class CharT, class Traits, class A>
inline bool
-operator!=(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator!=(const CharT* s, const basic_string<CharT,Traits,A>& y)
{ return !(s == y); }
template <class CharT, class Traits, class A>
inline bool
-operator!=(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator!=(const basic_string<CharT,Traits,A>& x, const CharT* s)
{ return !(x == s); }
@@ -2636,7 +2663,7 @@ operator!=(const basic_string<CharT,Traits,A>& x, const CharT* s)
template <class CharT, class Traits, class A>
inline bool
-operator<(const basic_string<CharT,Traits,A>& x, const basic_string<CharT,Traits,A>& y)
+operator<(const basic_string<CharT,Traits,A>& x, const basic_string<CharT,Traits,A>& y)
{
return x.compare(y) < 0;
// return basic_string<CharT,Traits,A>
@@ -2645,7 +2672,7 @@ operator<(const basic_string<CharT,Traits,A>& x, const basic_string<CharT,Traits
template <class CharT, class Traits, class A>
inline bool
-operator<(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator<(const CharT* s, const basic_string<CharT,Traits,A>& y)
{
return y.compare(s) > 0;
// basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
@@ -2656,7 +2683,7 @@ operator<(const CharT* s, const basic_string<CharT,Traits,A>& y)
template <class CharT, class Traits, class A>
inline bool
operator<(const basic_string<CharT,Traits,A>& x,
- const CharT* s)
+ const CharT* s)
{
return x.compare(s) < 0;
// basic_string<CharT,Traits,A>::size_type n = Traits::length(s);
@@ -2679,7 +2706,7 @@ operator>(const CharT* s, const basic_string<CharT,Traits,A>& y) {
template <class CharT, class Traits, class A>
inline bool
-operator>(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator>(const basic_string<CharT,Traits,A>& x, const CharT* s)
{
return s < x;
}
@@ -2687,44 +2714,44 @@ operator>(const basic_string<CharT,Traits,A>& x, const CharT* s)
template <class CharT, class Traits, class A>
inline bool
operator<=(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+ const basic_string<CharT,Traits,A>& y)
{
return !(y < x);
}
template <class CharT, class Traits, class A>
inline bool
-operator<=(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator<=(const CharT* s, const basic_string<CharT,Traits,A>& y)
{ return !(y < s); }
template <class CharT, class Traits, class A>
inline bool
-operator<=(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator<=(const basic_string<CharT,Traits,A>& x, const CharT* s)
{ return !(s < x); }
template <class CharT, class Traits, class A>
inline bool
operator>=(const basic_string<CharT,Traits,A>& x,
- const basic_string<CharT,Traits,A>& y)
+ const basic_string<CharT,Traits,A>& y)
{ return !(x < y); }
template <class CharT, class Traits, class A>
inline bool
-operator>=(const CharT* s, const basic_string<CharT,Traits,A>& y)
+operator>=(const CharT* s, const basic_string<CharT,Traits,A>& y)
{ return !(s < y); }
template <class CharT, class Traits, class A>
inline bool
-operator>=(const basic_string<CharT,Traits,A>& x, const CharT* s)
+operator>=(const basic_string<CharT,Traits,A>& 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)
+inline void swap(basic_string<CharT,Traits,A>& x, basic_string<CharT,Traits,A>& y)
{ x.swap(y); }
/// @cond
-// I/O.
+// I/O.
namespace container_detail {
template <class CharT, class Traits>
@@ -2762,11 +2789,11 @@ operator<<(std::basic_ostream<CharT, Traits>& os, const basic_string<CharT,Trait
if (w != 0 && n < w)
pad_len = w - n;
-
+
if (!left)
- ok = container_detail::string_fill(os, buf, pad_len);
+ ok = container_detail::string_fill(os, buf, pad_len);
- ok = ok &&
+ ok = ok &&
buf->sputn(s.data(), std::streamsize(n)) == std::streamsize(n);
if (left)
@@ -2781,7 +2808,7 @@ operator<<(std::basic_ostream<CharT, Traits>& os, const basic_string<CharT,Trait
template <class CharT, class Traits, class A>
-std::basic_istream<CharT, Traits>&
+std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,A>& s)
{
typename std::basic_istream<CharT, Traits>::sentry sentry(is);
@@ -2816,7 +2843,7 @@ operator>>(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,A>&
s.push_back(c);
}
}
-
+
// If we have read no characters, then set failbit.
if (s.size() == 0)
is.setstate(std::ios_base::failbit);
@@ -2827,8 +2854,8 @@ operator>>(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,A>&
return is;
}
-template <class CharT, class Traits, class A>
-std::basic_istream<CharT, Traits>&
+template <class CharT, class Traits, class A>
+std::basic_istream<CharT, Traits>&
getline(std::istream& is, basic_string<CharT,Traits,A>& s,CharT delim)
{
typename basic_string<CharT,Traits,A>::size_type nread = 0;
@@ -2846,7 +2873,7 @@ getline(std::istream& is, basic_string<CharT,Traits,A>& s,CharT delim)
else {
++nread;
CharT c = Traits::to_char_type(c1);
- if (!Traits::eq(c, delim))
+ if (!Traits::eq(c, delim))
s.push_back(c);
else
break; // Character is extracted but not appended.
@@ -2859,8 +2886,8 @@ getline(std::istream& is, basic_string<CharT,Traits,A>& s,CharT delim)
return is;
}
-template <class CharT, class Traits, class A>
-inline std::basic_istream<CharT, Traits>&
+template <class CharT, class Traits, class A>
+inline std::basic_istream<CharT, Traits>&
getline(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,A>& s)
{
return getline(is, s, '\n');
diff --git a/boost/container/vector.hpp b/boost/container/vector.hpp
index 742d00d37e..c6e5b51c30 100644
--- a/boost/container/vector.hpp
+++ b/boost/container/vector.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -38,7 +38,7 @@
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/algorithms.hpp>
#include <boost/container/detail/destroyers.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/container/container_fwd.hpp>
#include <boost/move/move.hpp>
#include <boost/move/move_helpers.hpp>
@@ -46,6 +46,7 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/container/detail/advanced_insert_int.hpp>
+#include <boost/assert.hpp>
namespace boost {
namespace container {
@@ -54,7 +55,7 @@ namespace container {
namespace container_detail {
-//! Const vector_iterator used to iterate through a vector.
+//! Const vector_iterator used to iterate through a vector.
template <class Pointer>
class vector_const_iterator
{
@@ -81,20 +82,20 @@ class vector_const_iterator
vector_const_iterator() : m_ptr(0){}
//Pointer like operators
- reference operator*() const
+ reference operator*() const
{ return *m_ptr; }
- const value_type * operator->() const
+ const value_type * operator->() const
{ return container_detail::to_raw_pointer(m_ptr); }
reference operator[](difference_type off) const
{ return m_ptr[off]; }
//Increment / Decrement
- vector_const_iterator& operator++()
+ vector_const_iterator& operator++()
{ ++m_ptr; return *this; }
- vector_const_iterator operator++(int)
+ vector_const_iterator operator++(int)
{ Pointer tmp = m_ptr; ++*this; return vector_const_iterator(tmp); }
vector_const_iterator& operator--()
@@ -164,22 +165,22 @@ class vector_iterator
{}
//Pointer like operators
- reference operator*() const
+ reference operator*() const
{ return *this->m_ptr; }
- value_type* operator->() const
+ value_type* operator->() const
{ return container_detail::to_raw_pointer(this->m_ptr); }
- reference operator[](difference_type off) const
+ reference operator[](difference_type off) const
{ return this->m_ptr[off]; }
//Increment / Decrement
- vector_iterator& operator++()
+ vector_iterator& operator++()
{ ++this->m_ptr; return *this; }
vector_iterator operator++(int)
{ pointer tmp = this->m_ptr; ++*this; return vector_iterator(tmp); }
-
+
vector_iterator& operator--()
{ --this->m_ptr; return *this; }
@@ -248,7 +249,7 @@ struct vector_value_traits
//!This struct deallocates and allocated memory
template <class A>
-struct vector_alloc_holder
+struct vector_alloc_holder
{
typedef boost::container::allocator_traits<A> allocator_traits_type;
typedef typename allocator_traits_type::pointer pointer;
@@ -281,7 +282,7 @@ struct vector_alloc_holder
boost::container::container_detail::version<A>::value> alloc_version;
std::pair<pointer, bool>
allocation_command(allocation_type command,
- size_type limit_size,
+ size_type limit_size,
size_type preferred_size,
size_type &received_size, const pointer &reuse = 0)
{
@@ -291,7 +292,7 @@ struct vector_alloc_holder
std::pair<pointer, bool>
allocation_command(allocation_type command,
- size_type limit_size,
+ size_type limit_size,
size_type preferred_size,
size_type &received_size,
const pointer &reuse,
@@ -307,7 +308,7 @@ struct vector_alloc_holder
std::pair<pointer, bool>
allocation_command(allocation_type command,
- size_type limit_size,
+ size_type limit_size,
size_type preferred_size,
size_type &received_size,
const pointer &reuse,
@@ -393,9 +394,9 @@ struct vector_alloc_holder
/// @endcond
//! \class vector
-//! A vector is a sequence that supports random access to elements, constant
-//! time insertion and removal of elements at the end, and linear time insertion
-//! and removal of elements at the beginning or in the middle. The number of
+//! A vector is a sequence that supports random access to elements, constant
+//! time insertion and removal of elements at the end, and linear time insertion
+//! and removal of elements at the beginning or in the middle. The number of
//! elements in a vector may vary dynamically; memory management is automatic.
//! boost::container::vector is similar to std::vector but it's compatible
//! with shared memory and memory mapped files.
@@ -433,11 +434,11 @@ class vector : private container_detail::vector_alloc_holder<A>
//! The random access const_iterator
typedef container_detail::vector_const_iterator<pointer> const_iterator;
- //! Iterator used to iterate backwards through a vector.
- typedef std::reverse_iterator<iterator>
+ //! Iterator used to iterate backwards through a vector.
+ typedef std::reverse_iterator<iterator>
reverse_iterator;
- //! Const iterator used to iterate backwards through a vector.
- typedef std::reverse_iterator<const_iterator>
+ //! Const iterator used to iterate backwards through a vector.
+ typedef std::reverse_iterator<const_iterator>
const_reverse_iterator;
//! The stored allocator type
typedef allocator_type stored_allocator_type;
@@ -460,9 +461,9 @@ class vector : private container_detail::vector_alloc_holder<A>
public:
//! <b>Effects</b>: Constructs a vector taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
vector()
BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor<A>::value)
@@ -470,9 +471,9 @@ class vector : private container_detail::vector_alloc_holder<A>
{}
//! <b>Effects</b>: Constructs a vector taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
explicit vector(const A& a) BOOST_CONTAINER_NOEXCEPT
: base_t(a)
@@ -483,7 +484,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Throws</b>: If allocator_type's default constructor or allocation
//! throws or T's default constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
explicit vector(size_type n)
: base_t()
@@ -510,21 +511,21 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Throws</b>: If allocator_type's default constructor or allocation
//! throws or T's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
- vector(size_type n, const T& value, const allocator_type& a = allocator_type())
+ vector(size_type n, const T& value, const allocator_type& a = allocator_type())
: base_t(a)
{ this->insert(this->cend(), n, value); }
//! <b>Effects</b>: Copy constructs a vector.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor or allocation
//! throws or T's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
- vector(const vector &x)
+ vector(const vector &x)
: base_t(allocator_traits_type::select_on_container_copy_construction(x.alloc()))
{
this->assign( container_detail::to_raw_pointer(x.members_.m_start)
@@ -534,12 +535,46 @@ class vector : private container_detail::vector_alloc_holder<A>
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
vector(BOOST_RV_REF(vector) mx) BOOST_CONTAINER_NOEXCEPT
: base_t(boost::move(mx.alloc()))
{ this->swap_members(mx); }
+ //! <b>Effects</b>: Copy constructs a vector using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Throws</b>: If allocation
+ //! throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ vector(const vector &x, const allocator_type &a)
+ : base_t(a)
+ {
+ this->assign( container_detail::to_raw_pointer(x.members_.m_start)
+ , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
+ }
+
+ //! <b>Effects</b>: Move constructor using the specified allocator.
+ //! Moves mx's resources to *this if a == allocator_type().
+ //! Otherwise copies values from x to *this.
+ //!
+ //! <b>Throws</b>: If allocation or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == mx.get_allocator(), linear otherwise.
+ vector(BOOST_RV_REF(vector) mx, const allocator_type &a)
+ : base_t(a)
+ {
+ if(mx.alloc() == a){
+ this->swap_members(mx);
+ }
+ else{
+ this->assign( container_detail::to_raw_pointer(mx.members_.m_start)
+ , container_detail::to_raw_pointer(mx.members_.m_start + mx.members_.m_size));
+ }
+ }
+
//! <b>Effects</b>: Constructs a vector that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the vector.
//!
@@ -562,103 +597,103 @@ class vector : private container_detail::vector_alloc_holder<A>
{} //vector_alloc_holder clears the data
//! <b>Effects</b>: Returns an iterator to the first element contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator begin() BOOST_CONTAINER_NOEXCEPT
{ return iterator(this->members_.m_start); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
{ return const_iterator(this->members_.m_start); }
//! <b>Effects</b>: Returns an iterator to the end of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end() BOOST_CONTAINER_NOEXCEPT
{ return iterator(this->members_.m_start + this->members_.m_size); }
//! <b>Effects</b>: Returns a const_iterator to the end of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator end() const BOOST_CONTAINER_NOEXCEPT
{ return this->cend(); }
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed vector.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
{ return reverse_iterator(this->end()); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
{ return this->crbegin(); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed vector.
- //!
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
{ return reverse_iterator(this->begin()); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed vector.
- //!
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
{ return this->crend(); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
{ return const_iterator(this->members_.m_start); }
//! <b>Effects</b>: Returns a const_iterator to the end of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
{ return const_iterator(this->members_.m_start + this->members_.m_size); }
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
{ return const_reverse_iterator(this->end());}
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed vector.
- //!
+ //! of the reversed vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
{ return const_reverse_iterator(this->begin()); }
@@ -667,9 +702,9 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Effects</b>: Returns a reference to the first
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference front() BOOST_CONTAINER_NOEXCEPT
{ return *this->members_.m_start; }
@@ -678,9 +713,9 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Effects</b>: Returns a const reference to the first
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference front() const BOOST_CONTAINER_NOEXCEPT
{ return *this->members_.m_start; }
@@ -689,9 +724,9 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Effects</b>: Returns a reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference back() BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start[this->members_.m_size - 1]; }
@@ -700,132 +735,132 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Effects</b>: Returns a const reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference back() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start[this->members_.m_size - 1]; }
//! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
//! For a non-empty vector, data() == &front().
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
pointer data() BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start; }
//! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
//! For a non-empty vector, data() == &front().
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_pointer data() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start; }
//! <b>Effects</b>: Returns the number of the elements contained in the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type size() const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_size; }
//! <b>Effects</b>: Returns the largest possible size of the vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type max_size() const BOOST_CONTAINER_NOEXCEPT
{ return allocator_traits_type::max_size(this->alloc()); }
//! <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 BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_capacity; }
//! <b>Effects</b>: Returns true if the vector contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
bool empty() const BOOST_CONTAINER_NOEXCEPT
{ return !this->members_.m_size; }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reference operator[](size_type n)
+ reference operator[](size_type n)
{ return this->members_.m_start[n]; }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
{ return this->members_.m_start[n]; }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
- reference at(size_type n)
+ reference at(size_type n)
{ this->priv_check_range(n); return this->members_.m_start[n]; }
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference at(size_type n) const
{ this->priv_check_range(n); return this->members_.m_start[n]; }
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
{ return this->alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
{ return this->alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
{ return this->alloc(); }
@@ -834,7 +869,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//! 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/move constructor throws.
void reserve(size_type new_cap)
{
@@ -893,8 +928,8 @@ class vector : private container_detail::vector_alloc_holder<A>
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment throws.
//!
@@ -967,7 +1002,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Complexity</b>: Linear to n.
template <class InIt>
- void assign(InIt first, InIt last)
+ void assign(InIt first, InIt last)
{
//Dispatch depending on integer/iterator
const bool aux_boolean = container_detail::is_convertible<InIt, size_type>::value;
@@ -1078,7 +1113,7 @@ class vector : private container_detail::vector_alloc_holder<A>
#include BOOST_PP_LOCAL_ITERATE()
#endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
+
//! <b>Effects</b>: Swaps the contents of *this and x.
//!
//! <b>Throws</b>: Nothing.
@@ -1149,7 +1184,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant time.
- void pop_back()
+ void pop_back()
{
//Destroy last element
--this->members_.m_size;
@@ -1160,9 +1195,9 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Throws</b>: Nothing.
//!
- //! <b>Complexity</b>: Linear to the elements between pos and the
+ //! <b>Complexity</b>: Linear to the elements between pos and the
//! last element. Constant if pos is the last element.
- iterator erase(const_iterator position)
+ iterator erase(const_iterator position)
{
T *pos = container_detail::to_raw_pointer(position.get_ptr());
T *beg = container_detail::to_raw_pointer(this->members_.m_start);
@@ -1179,7 +1214,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//!
//! <b>Complexity</b>: Linear to the distance between first and last
//! plus linear to the elements between pos and the last element.
- iterator erase(const_iterator first, const_iterator last)
+ iterator erase(const_iterator first, const_iterator last)
{
if (first != last){ // worth doing, copy down over hole
T* end_pos = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size;
@@ -1201,7 +1236,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size, const T& x)
+ void resize(size_type new_size, const T& x)
{
pointer finish = this->members_.m_start + this->members_.m_size;
if (new_size < size()){
@@ -1220,7 +1255,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size)
+ void resize(size_type new_size)
{
if (new_size < this->size()){
//Destroy last elements
@@ -1253,8 +1288,23 @@ class vector : private container_detail::vector_alloc_holder<A>
/// @cond
+ //Absolutely experimental. This function might change, disappear or simply crash!
+ template<class BiDirPosConstIt, class BiDirValueIt>
+ void insert_ordered_at(size_type element_count, BiDirPosConstIt last_position_it, BiDirValueIt last_value_it)
+ {
+ const size_type *dummy = 0;
+ this->priv_insert_ordered_at(element_count, last_position_it, false, &dummy[0], last_value_it);
+ }
+
+ //Absolutely experimental. This function might change, disappear or simply crash!
+ template<class BiDirPosConstIt, class BiDirSkipConstIt, class BiDirValueIt>
+ void insert_ordered_at(size_type element_count, BiDirPosConstIt last_position_it, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
+ {
+ this->priv_insert_ordered_at(element_count, last_position_it, true, last_skip_it, last_value_it);
+ }
+
private:
- iterator priv_insert(const_iterator position, const T &x)
+ iterator priv_insert(const_iterator position, const T &x)
{
//Just call more general insert(pos, size, value) and return iterator
size_type pos_n = position - cbegin();
@@ -1262,7 +1312,7 @@ class vector : private container_detail::vector_alloc_holder<A>
return iterator(this->members_.m_start + pos_n);
}
- iterator priv_insert(const_iterator position, BOOST_RV_REF(T) x)
+ iterator priv_insert(const_iterator position, BOOST_RV_REF(T) x)
{
//Just call more general insert(pos, size, value) and return iterator
size_type pos_n = position - cbegin();
@@ -1352,7 +1402,7 @@ class vector : private container_detail::vector_alloc_holder<A>
template <class FwdIt>
void priv_range_insert(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
{
- if(first != last){
+ if(first != last){
const size_type n = std::distance(first, last);
container_detail::advanced_insert_aux_proxy<A, FwdIt, T*> proxy(this->alloc(), first, last);
priv_range_insert(pos.get_ptr(), n, proxy);
@@ -1393,7 +1443,7 @@ class vector : private container_detail::vector_alloc_holder<A>
this->members_.m_capacity = real_cap;
}
}
-
+
//If we had room or we have expanded forward
if (same_buffer_start){
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
@@ -1428,6 +1478,156 @@ class vector : private container_detail::vector_alloc_holder<A>
}
}
+ //Absolutely experimental. This function might change, disappear or simply crash!
+ template<class BiDirPosConstIt, class BiDirSkipConstIt, class BiDirValueIt>
+ void priv_insert_ordered_at( size_type element_count, BiDirPosConstIt last_position_it
+ , bool do_skip, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
+ {
+ const size_type old_size_pos = this->size();
+ this->reserve(old_size_pos + element_count);
+ T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+ size_type insertions_left = element_count;
+ size_type next_pos = old_size_pos;
+ size_type hole_size = element_count;
+
+ //Exception rollback. If any copy throws before the hole is filled, values
+ //already inserted/copied at the end of the buffer will be destroyed.
+ typename value_traits::ArrayDestructor past_hole_values_destroyer
+ (begin_ptr + old_size_pos + element_count, this->alloc(), size_type(0u));
+ //Loop for each insertion backwards, first moving the elements after the insertion point,
+ //then inserting the element.
+ while(insertions_left){
+ const size_type pos = static_cast<size_type>(*(--last_position_it));
+ BOOST_ASSERT(pos <= old_size_pos);
+ //If needed shift the range after the insertion point and the previous insertion point.
+ //Function will take care if the shift crosses the size() boundary, using copy/move
+ //or uninitialized copy/move if necessary.
+ size_type new_hole_size = (pos != next_pos)
+ ? priv_insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left)
+ : hole_size
+ ;
+ if(new_hole_size > 0){
+ //The hole was reduced by priv_insert_ordered_at_shift_range so expand exception rollback range backwards
+ past_hole_values_destroyer.increment_size_backwards(next_pos - pos);
+ //Insert the new value in the hole
+ allocator_traits_type::construct(this->alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it));
+ --new_hole_size;
+ if(new_hole_size == 0){
+ //Hole was just filled, disable exception rollback and change vector size
+ past_hole_values_destroyer.release();
+ this->members_.m_size += element_count;
+ }
+ else{
+ //The hole was reduced by the new insertion by one
+ past_hole_values_destroyer.increment_size_backwards(size_type(1u));
+ }
+ }
+ else{
+ if(hole_size){
+ //Hole was just filled by priv_insert_ordered_at_shift_range, disable exception rollback and change vector size
+ past_hole_values_destroyer.release();
+ this->members_.m_size += element_count;
+ }
+ //Insert the new value in the already constructed range
+ begin_ptr[pos + insertions_left - 1] = *(--last_value_it);
+ }
+ if(do_skip){
+ size_type n = *(--last_skip_it);
+ while(n--){
+ --last_value_it;
+ }
+ }
+ --insertions_left;
+ hole_size = new_hole_size;
+ next_pos = pos;
+ }
+ }
+
+ //Takes the range pointed by [first_pos, last_pos) and shifts it to the right
+ //by 'shift_count'. 'limit_pos' marks the end of constructed elements.
+ //
+ //Precondition: first_pos <= last_pos <= limit_pos
+ //
+ //The shift operation might cross limit_pos so elements to moved beyond limit_pos
+ //are uninitialized_moved with an allocator. Other elements are moved.
+ //
+ //The shift operation might left uninitialized elements after limit_pos
+ //and the number of uninitialized elements is returned by the function.
+ //
+ //Old situation:
+ // first_pos last_pos old_limit
+ // | | |
+ // ____________V_______V__________________V_____________
+ //| prefix | range | suffix |raw_mem ~
+ //|____________|_______|__________________|_____________~
+ //
+ //New situation in Case A (hole_size == 0):
+ // range is moved through move assignments
+ //
+ // first_pos last_pos old_limit
+ // | | |
+ // ____________V_______V__________________V_____________
+ //| prefix' | | | range |suffix'|raw_mem ~
+ //|________________+______|___^___|_______|_____________~
+ // | |
+ // |_>_>_>_>_>^
+ //
+ //
+ //New situation in Case B (hole_size >= 0):
+ // range is moved through uninitialized moves
+ //
+ // first_pos last_pos old_limit
+ // | | |
+ // ____________V_______V__________________V________________
+ //| prefix' | | | [hole] | range |
+ //|_______________________________________|________|___^___|
+ // | |
+ // |_>_>_>_>_>_>_>_>_>_>_>_>_>_>_>_>_>_^
+ //
+ //New situation in Case C (hole_size == 0):
+ // range is moved through move assignments and uninitialized moves
+ //
+ // first_pos last_pos old_limit
+ // | | |
+ // ____________V_______V__________________V___
+ //| prefix' | | | range |
+ //|___________________________________|___^___|
+ // | |
+ // |_>_>_>_>_>_>_>_>_>_>_>^
+ size_type priv_insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
+ {
+ BOOST_ASSERT(first_pos <= last_pos);
+ BOOST_ASSERT(last_pos <= limit_pos);
+ //
+ T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+
+ size_type hole_size = 0;
+ //Case A:
+ if((last_pos + shift_count) <= limit_pos){
+ //All move assigned
+ boost::move_backward(begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + last_pos + shift_count);
+ }
+ //Case B:
+ else if((first_pos + shift_count) >= limit_pos){
+ //All uninitialized_moved
+ ::boost::container::uninitialized_move_alloc
+ (this->alloc(), begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + first_pos + shift_count);
+ hole_size = last_pos + shift_count - limit_pos;
+ }
+ //Case C:
+ else{
+ //Some uninitialized_moved
+ T* const limit_ptr = begin_ptr + limit_pos;
+ T* const boundary_ptr = limit_ptr - shift_count;
+ ::boost::container::uninitialized_move_alloc
+ (this->alloc(), boundary_ptr, begin_ptr + last_pos, limit_ptr);
+ //The rest is move assigned
+ boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr);
+ }
+ return hole_size;
+ }
+
+ private:
void priv_range_insert_expand_forward(T* pos, size_type n, advanced_insert_aux_int_t &interf)
{
//n can't be 0, because there is nothing to do in that case
@@ -1471,7 +1671,7 @@ class vector : private container_detail::vector_alloc_holder<A>
typename value_traits::ArrayDeallocator scoped_alloc(new_start, this->alloc(), new_cap);
typename value_traits::ArrayDestructor constructed_values_destroyer(new_start, this->alloc(), 0u);
- //Initialize with [begin(), pos) old buffer
+ //Initialize with [begin(), pos) old buffer
//the start of the new buffer
T *old_buffer = container_detail::to_raw_pointer(this->members_.m_start);
if(old_buffer){
@@ -1483,7 +1683,7 @@ class vector : private container_detail::vector_alloc_holder<A>
interf.uninitialized_copy_remaining_to(old_finish = new_finish);
new_finish += n;
constructed_values_destroyer.increment_size(new_finish - old_finish);
- //Initialize from the rest of the old buffer,
+ //Initialize from the rest of the old buffer,
//starting from previous point
if(old_buffer){
new_finish = ::boost::container::uninitialized_move_alloc
@@ -1491,7 +1691,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//Destroy and deallocate old elements
//If there is allocated memory, destroy and deallocate
if(!value_traits::trivial_dctr_after_move)
- this->destroy_n(old_buffer, this->members_.m_size);
+ this->destroy_n(old_buffer, this->members_.m_size);
this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
}
this->members_.m_start = new_start;
@@ -1637,7 +1837,7 @@ class vector : private container_detail::vector_alloc_holder<A>
//|___________|_____|_________|_____________________|
//
//Copy the first part of old_begin to raw_mem
- T *start_n = old_start + difference_type(s_before);
+ T *start_n = old_start + difference_type(s_before);
::boost::container::uninitialized_move_alloc
(this->alloc(), old_start, start_n, new_start);
//The buffer is all constructed until old_end,
@@ -1846,7 +2046,7 @@ class vector : private container_detail::vector_alloc_holder<A>
this->members_.m_capacity = real_cap;
}
}
-
+
if(same_buffer_start){
T *start = container_detail::to_raw_pointer(this->members_.m_start);
if (this->size() >= n){
@@ -1875,7 +2075,7 @@ class vector : private container_detail::vector_alloc_holder<A>
scoped_alloc.release();
//Destroy and deallocate old buffer
if(this->members_.m_start != 0){
- this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
+ this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
}
this->members_.m_start = ret.first;
@@ -1893,7 +2093,7 @@ class vector : private container_detail::vector_alloc_holder<A>
this->members_.m_size = 0;
this->members_.m_start = ret.first;
this->members_.m_capacity = real_cap;
-
+
//Backup old buffer data
size_type old_offset = old_start - container_detail::to_raw_pointer(ret.first);
size_type first_count = container_detail::min_value(n, old_offset);
@@ -1904,7 +2104,7 @@ class vector : private container_detail::vector_alloc_holder<A>
(this->alloc(), first, mid, container_detail::to_raw_pointer(ret.first));
if(old_offset > n){
- //All old elements will be destroyed by "old_values_destroyer"
+ //All old elements will be destroyed by "old_values_destroyer"
this->members_.m_size = n;
}
else{
@@ -1919,7 +2119,7 @@ class vector : private container_detail::vector_alloc_holder<A>
std::advance(mid2, second_count);
// iG std::copy(mid, mid2, old_start);
std::copy(mid, mid2, old_start);
-
+
//Check if we still have to append elements in the
//uninitialized end
if(second_count == old_size){
@@ -1932,7 +2132,7 @@ class vector : private container_detail::vector_alloc_holder<A>
(old_start + second_count, old_size - second_count);
this->members_.m_size = n;
}
- this->members_.m_size = n;
+ this->members_.m_size = n;
}
}
}
@@ -1943,18 +2143,18 @@ class vector : private container_detail::vector_alloc_holder<A>
template <class InIt>
void priv_assign_dispatch(InIt first, InIt last, container_detail::false_)
- {
+ {
//Dispatch depending on integer/iterator
typedef typename std::iterator_traits<InIt>::iterator_category ItCat;
- this->priv_assign_aux(first, last, ItCat());
+ this->priv_assign_aux(first, last, ItCat());
}
template <class Integer>
- void priv_insert_dispatch(const_iterator pos, Integer n, Integer val, container_detail::true_)
+ void priv_insert_dispatch(const_iterator pos, Integer n, Integer val, container_detail::true_)
{ this->insert(pos, (size_type)n, (T)val); }
template <class InIt>
- void priv_insert_dispatch(const_iterator pos, InIt first,
+ void priv_insert_dispatch(const_iterator pos, InIt first,
InIt last, container_detail::false_)
{
//Dispatch depending on integer/iterator
@@ -1962,7 +2162,7 @@ class vector : private container_detail::vector_alloc_holder<A>
this->priv_range_insert(pos, first, last, ItCat());
}
- void priv_check_range(size_type n) const
+ void priv_check_range(size_type n) const
{
//If n is out of range, throw an out_of_range exception
if (n >= size())
@@ -1982,7 +2182,7 @@ class vector : private container_detail::vector_alloc_holder<A>
};
template <class T, class A>
-inline bool
+inline bool
operator==(const vector<T, A>& x, const vector<T, A>& y)
{
//Check first size and each element if needed
@@ -1990,7 +2190,7 @@ operator==(const vector<T, A>& x, const vector<T, A>& y)
}
template <class T, class A>
-inline bool
+inline bool
operator!=(const vector<T, A>& x, const vector<T, A>& y)
{
//Check first size and each element if needed
@@ -1998,7 +2198,7 @@ operator!=(const vector<T, A>& x, const vector<T, A>& y)
}
template <class T, class A>
-inline bool
+inline bool
operator<(const vector<T, A>& x, const vector<T, A>& y)
{
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());