diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2014-06-03 18:27:14 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2014-06-04 14:46:26 -0400 |
commit | f40d275dc14d8fcecde23c077d36305232177d9a (patch) | |
tree | 327d3442eb8d11eba3e2f01e5d84c75d081cfd67 /src/third_party | |
parent | 659d9ecb48f0bbddfac486962c1622737641ebc7 (diff) | |
download | mongo-f40d275dc14d8fcecde23c077d36305232177d9a.tar.gz |
SERVER-14152 Import sufficient components of boost 1.49 to support boost::container::list<T>.
Diffstat (limited to 'src/third_party')
217 files changed, 76347 insertions, 0 deletions
diff --git a/src/third_party/boost/boost/container/allocator/allocator_traits.hpp b/src/third_party/boost/boost/container/allocator/allocator_traits.hpp new file mode 100644 index 00000000000..01921615cf8 --- /dev/null +++ b/src/third_party/boost/boost/container/allocator/allocator_traits.hpp @@ -0,0 +1,382 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (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_ALLOCATOR_TRAITS_HPP +#define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_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/intrusive/pointer_traits.hpp> +#include <boost/container/allocator/memory_util.hpp> +#include <boost/type_traits/integral_constant.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/move/move.hpp> +#include <limits> //numeric_limits<>::max() +#include <new> //placement new +#include <memory> //std::allocator +#include <boost/container/detail/preprocessor.hpp> + +///@cond + +namespace boost { +namespace container { +namespace container_detail { + +//workaround needed for C++03 compilers with no construct() +//supporting rvalue references +template<class A> +struct is_std_allocator +{ static const bool value = false; }; + +template<class T> +struct is_std_allocator< std::allocator<T> > +{ static const bool value = true; }; + +} //namespace container_detail { + +///@endcond + +template <typename Alloc> +struct allocator_traits +{ + //allocator_type + typedef Alloc allocator_type; + //value_type + typedef typename Alloc::value_type value_type; + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //!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 + //! + 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>. + //! + typedef unspecified void_pointer; + //!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. + //! + typedef unspecified difference_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. + 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. + 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. + 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. + //! + //!In C++03 compilers <pre>rebind_alloc</pre> 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`. + 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`. + template <class T> + struct portable_rebind_alloc + { typedef unspecified_type type; }; + #else + //pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + pointer, value_type*) + pointer; + //const_pointer + 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; + //reference + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + reference, typename container_detail::unvoid<value_type>::type&) + reference; + //const_reference + 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, + void_pointer, typename boost::intrusive::pointer_traits<pointer>::template + rebind_pointer<void>) + void_pointer; + //const_void_pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, + const_void_pointer, typename boost::intrusive::pointer_traits<pointer>::template + rebind_pointer<const void>) + const_void_pointer; + //difference_type + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + difference_type, std::ptrdiff_t) + difference_type; + //size_type + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + size_type, std::size_t) + size_type; + //propagate_on_container_copy_assignment + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + propagate_on_container_copy_assignment, boost::false_type) + propagate_on_container_copy_assignment; + //propagate_on_container_move_assignment + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + propagate_on_container_move_assignment, boost::false_type) + propagate_on_container_move_assignment; + //propagate_on_container_swap + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + propagate_on_container_swap, boost::false_type) + propagate_on_container_swap; + + #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_traits = allocator_traits< rebind_alloc<T> >; + #else //!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 + { + typedef typename boost::intrusive::detail::type_rebinder<Alloc,T>::type Base; + #if !defined(BOOST_NO_VARIADIC_TEMPLATES) + template <typename... Args> + rebind_alloc(Args&&... args) + : Base(boost::forward<Args>(args)...) + {} + #else //!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, _)) \ + : Base(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \ + {} \ + // + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + #endif //!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) + 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) + //! + static pointer allocate(Alloc &a, size_type n) + { return a.allocate(n); } + + //!<b>Returns</b>: a.deallocate(p, n) + //! + //!<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)...)` + static pointer allocate(Alloc &a, size_type n, const_void_pointer p) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_allocate + <Alloc, const size_type, const const_void_pointer>::value; + ::boost::integral_constant<bool, value> flag; + 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()`. + template<class T> + static void destroy(Alloc &a, T*p) + { + typedef T* destroy_pointer; + const bool value = boost::container::container_detail:: + has_member_function_callable_with_destroy + <Alloc, const destroy_pointer>::value; + ::boost::integral_constant<bool, value> flag; + 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()`. + static size_type max_size(const Alloc &a) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_max_size + <const Alloc>::value; + ::boost::integral_constant<bool, value> flag; + 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. + static Alloc select_on_container_copy_construction(const Alloc &a) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_select_on_container_copy_construction + <const Alloc>::value; + ::boost::integral_constant<bool, value> flag; + 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)...)` + template <class T, class ...Args> + static void construct(Alloc & a, T* p, 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 + + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + private: + static pointer priv_allocate(boost::true_type, Alloc &a, size_type n, const_void_pointer p) + { return a.allocate(n, p); } + + static pointer priv_allocate(boost::false_type, Alloc &a, size_type n, const_void_pointer) + { return allocator_traits::allocate(a, n); } + + template<class T> + static void priv_destroy(boost::true_type, Alloc &a, T* p) + { a.destroy(p); } + + template<class T> + static void priv_destroy(boost::false_type, Alloc &, T* p) + { p->~T(); (void)p; } + + static size_type priv_max_size(boost::true_type, const Alloc &a) + { return a.max_size(); } + + static size_type priv_max_size(boost::false_type, const Alloc &) + { return (std::numeric_limits<size_type>::max)(); } + + static Alloc priv_select_on_container_copy_construction(boost::true_type, const Alloc &a) + { return a.select_on_container_copy_construction(); } + + static Alloc priv_select_on_container_copy_construction(boost::false_type, const Alloc &a) + { return a; } + + #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) + template<class T, class ...Args> + static void priv_construct(boost::false_type, Alloc &a, T *p, Args && ...args) + { + const bool value = boost::container::container_detail:: + has_member_function_callable_with_construct + < Alloc, T*, Args... >::value; + ::boost::integral_constant<bool, value> flag; + priv_construct_dispatch2(flag, a, p, ::boost::forward<Args>(args)...); + } + + template<class T, class ...Args> + static void priv_construct(boost::true_type, Alloc &a, T *p, 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) + { 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) + { ::new((void*)p) T(::boost::forward<Args>(args)...); } + #else + public: + #define BOOST_PP_LOCAL_MACRO(n) \ + template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \ + static void construct(Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + ::boost::integral_constant<bool, container_detail::is_std_allocator<Alloc>::value> flag; \ + allocator_traits::priv_construct(flag, a, 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() + + private: + #define BOOST_PP_LOCAL_MACRO(n) \ + template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \ + static void priv_construct(boost::false_type, Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ + { \ + const bool value = \ + boost::container::container_detail::has_member_function_callable_with_construct \ + < Alloc, T* BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_FWD_TYPE, _) >::value; \ + ::boost::integral_constant<bool, value> flag; \ + priv_construct_dispatch2(flag, a, p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ + } \ + \ + template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \ + static void priv_construct(boost::true_type, Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ + { \ + priv_construct_dispatch2(boost::false_type(), a, p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ + } \ + \ + template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \ + static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ + { a.construct( p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); } \ + \ + template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \ + static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ + { ::new((void*)p) T(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + // + #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_CONTAINER_DOXYGEN_INVOKED) + + ///@endcond +}; + +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP) diff --git a/src/third_party/boost/boost/container/allocator/memory_util.hpp b/src/third_party/boost/boost/container/allocator/memory_util.hpp new file mode 100644 index 00000000000..ea4bc05548c --- /dev/null +++ b/src/third_party/boost/boost/container/allocator/memory_util.hpp @@ -0,0 +1,77 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (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_MEMORY_UTIL_HPP +#define BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_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/detail/preprocessor.hpp> +#include <boost/intrusive/detail/has_member_function_callable_with.hpp> + + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 2, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 3, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME max_size +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME select_on_container_copy_construction +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS+1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +namespace boost { +namespace container { +namespace container_detail { + + +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP) diff --git a/src/third_party/boost/boost/container/allocator/scoped_allocator.hpp b/src/third_party/boost/boost/container/allocator/scoped_allocator.hpp new file mode 100644 index 00000000000..03e12d1d1ca --- /dev/null +++ b/src/third_party/boost/boost/container/allocator/scoped_allocator.hpp @@ -0,0 +1,651 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (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/src/third_party/boost/boost/container/deque.hpp b/src/third_party/boost/boost/container/deque.hpp new file mode 100644 index 00000000000..9ee0ee13715 --- /dev/null +++ b/src/third_party/boost/boost/container/deque.hpp @@ -0,0 +1,2011 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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. +// +////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 1996,1997 +// Silicon Graphics Computer Systems, Inc. +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. Silicon Graphics makes no +// representations about the suitability of this software for any +// purpose. It is provided "as is" without express or implied warranty. +// +// +// Copyright (c) 1994 +// Hewlett-Packard Company +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. Hewlett-Packard Company makes no +// representations about the suitability of this software for any +// purpose. It is provided "as is" without express or implied warranty. + +#ifndef BOOST_CONTAINER_DEQUE_HPP +#define BOOST_CONTAINER_DEQUE_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/detail/utilities.hpp> +#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/container_fwd.hpp> +#include <cstddef> +#include <iterator> +#include <boost/assert.hpp> +#include <memory> +#include <algorithm> +#include <stdexcept> +#include <boost/detail/no_exceptions_support.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/type_traits/has_trivial_copy.hpp> +#include <boost/type_traits/has_trivial_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/move/move.hpp> +#include <boost/move/move_helpers.hpp> +#include <boost/container/detail/advanced_insert_int.hpp> + +namespace boost { +namespace container { + +/// @cond +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +template <class T, class A = std::allocator<T> > +#else +template <class T, class A> +#endif +class deque; + +template <class T, class A> +struct deque_value_traits +{ + typedef T value_type; + typedef A allocator_type; + static const bool trivial_dctr = boost::has_trivial_destructor<value_type>::value; + static const bool trivial_dctr_after_move = false; + //::boost::has_trivial_destructor_after_move<value_type>::value || trivial_dctr; + static const bool trivial_copy = has_trivial_copy<value_type>::value; + static const bool nothrow_copy = has_nothrow_copy<value_type>::value; + static const bool trivial_assign = has_trivial_assign<value_type>::value; + //static const bool nothrow_assign = has_nothrow_assign<value_type>::value; + static const bool nothrow_assign = false; +}; + +// 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) + { return size < 512 ? std::size_t(512 / size) : std::size_t(1); } + +// Deque base class. It has two purposes. First, its constructor +// and destructor allocate (but don't initialize) storage. This makes +// exception safety easier. +template <class T, class A> +class deque_base +{ + BOOST_COPYABLE_AND_MOVABLE(deque_base) + public: + typedef allocator_traits<A> val_alloc_traits_type; + typedef typename val_alloc_traits_type::value_type val_alloc_val; + typedef typename val_alloc_traits_type::pointer val_alloc_ptr; + typedef typename val_alloc_traits_type::const_pointer val_alloc_cptr; + typedef typename val_alloc_traits_type::reference val_alloc_ref; + typedef typename val_alloc_traits_type::const_reference val_alloc_cref; + typedef typename val_alloc_traits_type::difference_type val_alloc_diff; + typedef typename val_alloc_traits_type::size_type val_alloc_size; + typedef typename val_alloc_traits_type::template + portable_rebind_alloc<val_alloc_ptr>::type ptr_alloc_t; + typedef allocator_traits<ptr_alloc_t> ptr_alloc_traits_type; + typedef typename ptr_alloc_traits_type::value_type ptr_alloc_val; + typedef typename ptr_alloc_traits_type::pointer ptr_alloc_ptr; + typedef typename ptr_alloc_traits_type::const_pointer ptr_alloc_cptr; + typedef typename ptr_alloc_traits_type::reference ptr_alloc_ref; + typedef typename ptr_alloc_traits_type::const_reference ptr_alloc_cref; + typedef A allocator_type; + typedef allocator_type stored_allocator_type; + typedef val_alloc_size size_type; + + protected: + + typedef deque_value_traits<T, A> traits_t; + typedef ptr_alloc_t map_allocator_type; + + static size_type s_buffer_size() { return deque_buf_size(sizeof(T)); } + + val_alloc_ptr priv_allocate_node() + { return this->alloc().allocate(s_buffer_size()); } + + void priv_deallocate_node(val_alloc_ptr p) + { this->alloc().deallocate(p, s_buffer_size()); } + + 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) + { this->ptr_alloc().deallocate(p, n); } + + public: + // Class invariants: + // 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.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 + // pointer, even if i is a past-the-end iterator. + // Start and Finish are always nonsingular iterators. NOTE: this means + // that an empty deque must have one node, and that a deque + // with N elements, where N is the buffer size, must have two nodes. + // For every node other than start.node and finish.node, every element + // in the node is an initialized object. If start.node == finish.node, + // then [start.cur, finish.cur) are initialized objects, and + // the elements outside that range are uninitialized storage. Otherwise, + // [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). + // 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, + val_alloc_cptr, val_alloc_cref> + { + public: + static size_type s_buffer_size() { return deque_base<T, A>::s_buffer_size(); } + + typedef std::random_access_iterator_tag iterator_category; + typedef val_alloc_val value_type; + typedef val_alloc_cptr pointer; + typedef val_alloc_cref reference; + typedef val_alloc_diff difference_type; + + typedef ptr_alloc_ptr index_pointer; + typedef const_iterator self_t; + + friend class deque<T, A>; + friend class deque_base<T, A>; + + 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) + : 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_last(x.m_last), m_node(x.m_node) {} + + reference operator*() const + { return *this->m_cur; } + + pointer operator->() const + { return this->m_cur; } + + difference_type operator-(const self_t& x) const + { + if(!this->m_cur && !x.m_cur){ + return 0; + } + return difference_type(this->s_buffer_size()) * (this->m_node - x.m_node - 1) + + (this->m_cur - this->m_first) + (x.m_last - x.m_cur); + } + + 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; + } + + self_t operator++(int) + { + self_t tmp = *this; + ++*this; + return tmp; + } + + self_t& operator--() + { + if (this->m_cur == this->m_first) { + this->priv_set_node(this->m_node - 1); + this->m_cur = this->m_last; + } + --this->m_cur; + return *this; + } + + self_t operator--(int) + { + self_t tmp = *this; + --*this; + return tmp; + } + + self_t& operator+=(difference_type n) + { + difference_type offset = n + (this->m_cur - this->m_first); + if (offset >= 0 && offset < difference_type(this->s_buffer_size())) + this->m_cur += n; + else { + difference_type node_offset = + 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 + + (offset - node_offset * difference_type(this->s_buffer_size())); + } + return *this; + } + + self_t operator+(difference_type n) const + { self_t tmp = *this; return tmp += n; } + + self_t& operator-=(difference_type n) + { return *this += -n; } + + self_t operator-(difference_type n) const + { self_t tmp = *this; return tmp -= n; } + + reference operator[](difference_type n) const + { return *(*this + n); } + + bool operator==(const self_t& x) const + { return this->m_cur == x.m_cur; } + + bool operator!=(const self_t& x) const + { return !(*this == x); } + + bool operator<(const self_t& x) const + { + 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 + { return x < *this; } + + bool operator<=(const self_t& x) const + { return !(x < *this); } + + bool operator>=(const self_t& x) const + { return !(*this < x); } + + void priv_set_node(index_pointer new_node) + { + this->m_node = new_node; + this->m_first = *new_node; + this->m_last = this->m_first + difference_type(this->s_buffer_size()); + } + + friend const_iterator operator+(difference_type n, const const_iterator& x) + { return x + n; } + }; + + //Deque iterator + class iterator : public const_iterator + { + public: + typedef std::random_access_iterator_tag iterator_category; + typedef val_alloc_val value_type; + typedef val_alloc_ptr pointer; + typedef val_alloc_ref reference; + typedef val_alloc_diff difference_type; + typedef ptr_alloc_ptr index_pointer; + typedef const_iterator self_t; + + friend class deque<T, A>; + friend class deque_base<T, A>; + + private: + explicit iterator(const const_iterator& x) : const_iterator(x){} + + public: + //Constructors + iterator(val_alloc_ptr x, index_pointer y) : const_iterator(x, y){} + iterator() : const_iterator(){} + //iterator(const const_iterator &cit) : const_iterator(cit){} + iterator(const iterator& x) : const_iterator(x){} + + //Pointer like operators + reference operator*() const { return *this->m_cur; } + pointer operator->() const { return this->m_cur; } + + reference operator[](difference_type n) const { return *(*this + n); } + + //Increment / Decrement + 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; } + + iterator operator--(int) + { iterator tmp = *this; --*this; return tmp; } + + // Arithmetic + iterator& operator+=(difference_type off) + { this->const_iterator::operator+=(off); return *this; } + + iterator operator+(difference_type off) const + { return iterator(this->const_iterator::operator+(off)); } + + friend iterator operator+(difference_type off, const iterator& right) + { return iterator(off+static_cast<const const_iterator &>(right)); } + + iterator& operator-=(difference_type off) + { this->const_iterator::operator-=(off); return *this; } + + iterator operator-(difference_type off) const + { return iterator(this->const_iterator::operator-(off)); } + + difference_type operator-(const const_iterator& right) const + { return static_cast<const const_iterator&>(*this) - right; } + }; + + deque_base(size_type num_elements, const allocator_type& a) + : members_(a) + { this->priv_initialize_map(num_elements); } + + explicit deque_base(const allocator_type& a) + : members_(a) + {} + + deque_base() + : members_() + {} + + explicit deque_base(BOOST_RV_REF(deque_base) x) + : members_( boost::move(x.ptr_alloc()) + , boost::move(x.alloc()) ) + {} + + ~deque_base() + { + if (this->members_.m_map) { + this->priv_destroy_nodes(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1); + this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); + } + } + + private: + deque_base(const deque_base&); + + protected: + + void swap_members(deque_base &x) + { + std::swap(this->members_.m_start, x.members_.m_start); + std::swap(this->members_.m_finish, x.members_.m_finish); + std::swap(this->members_.m_map, x.members_.m_map); + std::swap(this->members_.m_map_size, x.members_.m_map_size); + } + + void priv_initialize_map(size_type num_elements) + { +// if(num_elements){ + size_type num_nodes = num_elements / s_buffer_size() + 1; + + this->members_.m_map_size = container_detail::max_value((size_type) InitialMapSize, num_nodes + 2); + this->members_.m_map = this->priv_allocate_map(this->members_.m_map_size); + + 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); + } + BOOST_CATCH(...){ + this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); + this->members_.m_map = 0; + this->members_.m_map_size = 0; + BOOST_RETHROW + } + BOOST_CATCH_END + + this->members_.m_start.priv_set_node(nstart); + this->members_.m_finish.priv_set_node(nfinish - 1); + this->members_.m_start.m_cur = this->members_.m_start.m_first; + this->members_.m_finish.m_cur = this->members_.m_finish.m_first + + num_elements % s_buffer_size(); +// } + } + + void priv_create_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish) + { + ptr_alloc_ptr cur; + BOOST_TRY { + for (cur = nstart; cur < nfinish; ++cur) + *cur = this->priv_allocate_node(); + } + BOOST_CATCH(...){ + this->priv_destroy_nodes(nstart, cur); + BOOST_RETHROW + } + BOOST_CATCH_END + } + + void priv_destroy_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish) + { + for (ptr_alloc_ptr n = nstart; n < nfinish; ++n) + this->priv_deallocate_node(*n); + } + + void priv_clear_map() + { + if (this->members_.m_map) { + this->priv_destroy_nodes(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1); + this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); + this->members_.m_map = 0; + this->members_.m_map_size = 0; + this->members_.m_start = iterator(); + this->members_.m_finish = this->members_.m_start; + } + } + + enum { InitialMapSize = 8 }; + + protected: + struct members_holder + : public ptr_alloc_t + , public allocator_type + { + members_holder() + : map_allocator_type(), allocator_type() + , m_map(0), m_map_size(0) + , m_start(), m_finish(m_start) + {} + + explicit members_holder(const allocator_type &a) + : map_allocator_type(a), allocator_type(a) + , m_map(0), m_map_size(0) + , m_start(), m_finish(m_start) + {} + + template<class ValAllocConvertible, class PtrAllocConvertible> + members_holder(BOOST_FWD_REF(PtrAllocConvertible) pa, BOOST_FWD_REF(ValAllocConvertible) va) + : map_allocator_type(boost::forward<PtrAllocConvertible>(pa)) + , allocator_type (boost::forward<ValAllocConvertible>(va)) + , m_map(0), m_map_size(0) + , m_start(), m_finish(m_start) + {} + + ptr_alloc_ptr m_map; + val_alloc_size m_map_size; + iterator m_start; + iterator m_finish; + } members_; + + ptr_alloc_t &ptr_alloc() + { return members_; } + + const ptr_alloc_t &ptr_alloc() const + { return members_; } + + allocator_type &alloc() + { return members_; } + + const allocator_type &alloc() const + { return members_; } +}; +/// @endcond + +//! Deque class +//! +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +template <class T, class A = std::allocator<T> > +#else +template <class T, class A> +#endif +class deque : protected deque_base<T, A> +{ + /// @cond + private: + typedef deque_base<T, A> Base; + typedef typename Base::val_alloc_val val_alloc_val; + typedef typename Base::val_alloc_ptr val_alloc_ptr; + typedef typename Base::val_alloc_cptr val_alloc_cptr; + typedef typename Base::val_alloc_ref val_alloc_ref; + typedef typename Base::val_alloc_cref val_alloc_cref; + typedef typename Base::val_alloc_size val_alloc_size; + typedef typename Base::val_alloc_diff val_alloc_diff; + + typedef typename Base::ptr_alloc_t ptr_alloc_t; + typedef typename Base::ptr_alloc_val ptr_alloc_val; + typedef typename Base::ptr_alloc_ptr ptr_alloc_ptr; + typedef typename Base::ptr_alloc_cptr ptr_alloc_cptr; + typedef typename Base::ptr_alloc_ref ptr_alloc_ref; + typedef typename Base::ptr_alloc_cref ptr_alloc_cref; + /// @endcond + + public: // Basic types + typedef T value_type; + typedef val_alloc_ptr pointer; + typedef val_alloc_cptr const_pointer; + typedef val_alloc_ref reference; + typedef val_alloc_cref const_reference; + typedef val_alloc_size size_type; + typedef val_alloc_diff difference_type; + typedef typename Base::allocator_type allocator_type; + + public: // Iterators + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + typedef std::reverse_iterator<iterator> reverse_iterator; + + typedef allocator_type stored_allocator_type; + + /// @cond + + private: // Internal typedefs + BOOST_COPYABLE_AND_MOVABLE(deque) + typedef ptr_alloc_ptr index_pointer; + 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; + typedef boost::move_iterator<r_iterator> move_it; + typedef allocator_traits<A> allocator_traits_type; + + /// @endcond + + 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>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. + //! + //! <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>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. + //! + //! <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>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. + //! + //! <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 + //! 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 + //! 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 + //! 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 + //! 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]; } + + //! <b>Requires</b>: !empty() + //! + //! <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 + //! 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; } + + //! <b>Requires</b>: !empty() + //! + //! <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); } + + //! <b>Requires</b>: !empty() + //! + //! <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() + : 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) + : Base(a) + {} + + //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a + //! and inserts n default contructed values. + //! + //! <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()) + { + container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n); + proxy.uninitialized_copy_remaining_to(this->begin()); + //deque_base will deallocate in case of exception... + } + + //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a + //! and inserts n copies of value. + //! + //! <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()) + : Base(n, a) + { this->priv_fill_initialize(value); } + + //! <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())) + { + 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. 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) + : Base(boost::move(static_cast<Base&>(x))) + { this->swap_members(x); } + + //! <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. + //! + //! <b>Throws</b>: If allocator_type's default constructor or copy constructor + //! throws or T's constructor taking an dereferenced InIt throws. + //! + //! <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) + { + //Dispatch depending on integer/iterator + const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_initialize_dispatch(first, last, Result()); + } + + //! <b>Effects</b>: Destroys the deque. All stored values are destroyed + //! and used memory is deallocated. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements. + ~deque() BOOST_CONTAINER_NOEXCEPT + { + priv_destroy_range(this->members_.m_start, this->members_.m_finish); + } + + //! <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>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) + { + if (&x != this){ + allocator_type &this_alloc = this->alloc(); + const allocator_type &x_alloc = x.alloc(); + container_detail::bool_<allocator_traits_type:: + propagate_on_container_copy_assignment::value> flag; + if(flag && this_alloc != x_alloc){ + this->clear(); + this->shrink_to_fit(); + } + container_detail::assign_alloc(this->alloc(), x.alloc(), flag); + container_detail::assign_alloc(this->ptr_alloc(), x.ptr_alloc(), flag); + this->assign(x.cbegin(), x.cend()); + } + return *this; + } + + //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this. + //! + //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had + //! before the function. + //! + //! <b>Throws</b>: If allocator_type's copy constructor throws. + //! + //! <b>Complexity</b>: Linear. + deque& operator= (BOOST_RV_REF(deque) x) + { + if (&x != this){ + allocator_type &this_alloc = this->alloc(); + allocator_type &x_alloc = x.alloc(); + //If allocators are equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy objects but retain memory in case x reuses it in the future + this->clear(); + this->swap_members(x); + //Move allocator if needed + container_detail::bool_<allocator_traits_type:: + propagate_on_container_move_assignment::value> flag; + container_detail::move_alloc(this_alloc, x_alloc, flag); + container_detail::move_alloc(this->ptr_alloc(), x.ptr_alloc(), flag); + } + //If unequal allocators, then do a one by one move + else{ + typedef typename std::iterator_traits<iterator>::iterator_category ItCat; + this->assign( boost::make_move_iterator(x.begin()) + , boost::make_move_iterator(x.end())); + } + } + return *this; + } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + void swap(deque &x) + { + this->swap_members(x); + container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag; + container_detail::swap_alloc(this->alloc(), x.alloc(), flag); + container_detail::swap_alloc(this->ptr_alloc(), x.ptr_alloc(), flag); + } + + //! <b>Effects</b>: Assigns the n copies of val to *this. + //! + //! <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) + { this->priv_fill_assign(n, val); } + + //! <b>Effects</b>: Assigns the the range [first, last) to *this. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's constructor from dereferencing InpIt throws. + //! + //! <b>Complexity</b>: Linear to n. + template <class InpIt> + void assign(InpIt first, InpIt last) + { + //Dispatch depending on integer/iterator + const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_assign_dispatch(first, last, Result()); + } + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! <b>Effects</b>: Inserts a copy of x at the end of the deque. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_back(const T &x); + + //! <b>Effects</b>: Constructs a new element in the end of the deque + //! and moves the resources of mx to this new element. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_back(T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back) + #endif + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! <b>Effects</b>: Inserts a copy of x at the front of the deque. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_front(const T &x); + + //! <b>Effects</b>: Constructs a new element in the front of the deque + //! and moves the resources of mx to this new element. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_front(T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front) + #endif + + //! <b>Effects</b>: Removes the last element from the deque. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + void pop_back() BOOST_CONTAINER_NOEXCEPT + { + if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) { + --this->members_.m_finish.m_cur; + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_finish.m_cur) + ); + } + else + this->priv_pop_back_aux(); + } + + //! <b>Effects</b>: Removes the first element from the deque. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + void pop_front() BOOST_CONTAINER_NOEXCEPT + { + if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) { + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_start.m_cur) + ); + ++this->members_.m_start.m_cur; + } + else + this->priv_pop_front_aux(); + } + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of x before position. + //! + //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + iterator insert(const_iterator position, const T &x); + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a new element before position with mx's resources. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + iterator insert(const_iterator position, T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator) + #endif + + //! <b>Requires</b>: pos must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert n copies of x before pos. + //! + //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to n. + void insert(const_iterator pos, size_type n, const value_type& x) + { this->priv_fill_insert(pos, n, x); } + + //! <b>Requires</b>: pos must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of the [first, last) range before pos. + //! + //! <b>Throws</b>: If memory allocation throws, T's constructor from a + //! dereferenced InpIt throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to std::distance [first, last). + template <class InpIt> + 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; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_insert_dispatch(pos, first, last, Result()); + } + + #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)... in the end of the deque. + //! + //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time + template <class... Args> + void emplace_back(Args&&... args) + { + if(this->priv_push_back_simple_available()){ + allocator_traits_type::construct + ( this->alloc() + , this->priv_push_back_simple_pos() + , boost::forward<Args>(args)...); + this->priv_push_back_simple_commit(); + } + else{ + typedef container_detail::advanced_insert_aux_non_movable_emplace<A, iterator, Args...> type; + type &&proxy = type(this->alloc(), boost::forward<Args>(args)...); + this->priv_insert_back_aux_impl(1, proxy); + } + } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... in the beginning of the deque. + //! + //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time + template <class... Args> + void emplace_front(Args&&... args) + { + if(this->priv_push_front_simple_available()){ + allocator_traits_type::construct + ( this->alloc() + , this->priv_push_front_simple_pos() + , boost::forward<Args>(args)...); + this->priv_push_front_simple_commit(); + } + else{ + typedef container_detail::advanced_insert_aux_non_movable_emplace<A, iterator, Args...> type; + type &&proxy = type(this->alloc(), boost::forward<Args>(args)...); + this->priv_insert_front_aux_impl(1, proxy); + } + } + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... before position + //! + //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + template <class... Args> + iterator emplace(const_iterator p, Args&&... args) + { + if(p == this->cbegin()){ + this->emplace_front(boost::forward<Args>(args)...); + return this->begin(); + } + else if(p == this->cend()){ + this->emplace_back(boost::forward<Args>(args)...); + return (this->end()-1); + } + else{ + size_type n = p - this->cbegin(); + typedef container_detail::advanced_insert_aux_emplace<A, iterator, Args...> type; + type &&proxy = type(this->alloc(), boost::forward<Args>(args)...); + this->priv_insert_aux_impl(p, 1, proxy); + return iterator(this->begin() + n); + } + } + + #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //advanced_insert_int.hpp includes all necessary preprocessor machinery... + #define BOOST_PP_LOCAL_MACRO(n) \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + if(priv_push_back_simple_available()){ \ + allocator_traits_type::construct \ + ( this->alloc() \ + , this->priv_push_back_simple_pos() \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + priv_push_back_simple_commit(); \ + } \ + else{ \ + container_detail::BOOST_PP_CAT(BOOST_PP_CAT( \ + advanced_insert_aux_non_movable_emplace, n), arg) \ + <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \ + (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + priv_insert_back_aux_impl(1, proxy); \ + } \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, > ) \ + void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + if(priv_push_front_simple_available()){ \ + allocator_traits_type::construct \ + ( this->alloc() \ + , this->priv_push_front_simple_pos() \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + priv_push_front_simple_commit(); \ + } \ + else{ \ + container_detail::BOOST_PP_CAT(BOOST_PP_CAT \ + (advanced_insert_aux_non_movable_emplace, n), arg) \ + <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \ + (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + priv_insert_front_aux_impl(1, proxy); \ + } \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace(const_iterator p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + if(p == this->cbegin()){ \ + this->emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + return this->begin(); \ + } \ + else if(p == cend()){ \ + this->emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + return (this->end()-1); \ + } \ + else{ \ + size_type pos_num = p - this->cbegin(); \ + container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ + <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \ + (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + this->priv_insert_aux_impl(p, 1, proxy); \ + return iterator(this->begin() + pos_num); \ + } \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are copy constructed from x. + //! + //! <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) + { + const size_type len = size(); + 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); + } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are default constructed. + //! + //! <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 size_type len = size(); + if (new_size < len) + this->priv_erase_last_n(len - new_size); + else{ + size_type n = new_size - this->size(); + container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n); + priv_insert_back_aux_impl(n, proxy); + } + } + + //! <b>Effects</b>: Erases the element at position pos. + //! + //! <b>Throws</b>: Nothing. + //! + //! <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. + iterator erase(const_iterator pos) BOOST_CONTAINER_NOEXCEPT + { + const_iterator next = pos; + ++next; + difference_type index = pos - this->members_.m_start; + if (size_type(index) < (this->size() >> 1)) { + boost::move_backward(begin(), iterator(pos), iterator(next)); + pop_front(); + } + else { + boost::move(iterator(next), end(), iterator(pos)); + pop_back(); + } + return this->members_.m_start + index; + } + + //! <b>Effects</b>: Erases the elements pointed by [first, last). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the distance between first and + //! 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 + { + if (first == this->members_.m_start && last == this->members_.m_finish) { + this->clear(); + return this->members_.m_finish; + } + else { + difference_type n = last - first; + difference_type elems_before = first - this->members_.m_start; + if (elems_before < static_cast<difference_type>(this->size() - n) - elems_before) { + boost::move_backward(begin(), iterator(first), iterator(last)); + iterator new_start = this->members_.m_start + n; + if(!Base::traits_t::trivial_dctr_after_move) + this->priv_destroy_range(this->members_.m_start, new_start); + this->priv_destroy_nodes(this->members_.m_start.m_node, new_start.m_node); + this->members_.m_start = new_start; + } + else { + boost::move(iterator(last), end(), iterator(first)); + iterator new_finish = this->members_.m_finish - n; + if(!Base::traits_t::trivial_dctr_after_move) + this->priv_destroy_range(new_finish, this->members_.m_finish); + this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1); + this->members_.m_finish = new_finish; + } + return this->members_.m_start + elems_before; + } + } + + void priv_erase_last_n(size_type n) + { + if(n == this->size()) { + this->clear(); + } + else { + iterator new_finish = this->members_.m_finish - n; + if(!Base::traits_t::trivial_dctr_after_move) + this->priv_destroy_range(new_finish, this->members_.m_finish); + this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1); + this->members_.m_finish = new_finish; + } + } + + //! <b>Effects</b>: Erases all the elements of the deque. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements in the deque. + void clear() BOOST_CONTAINER_NOEXCEPT + { + for (index_pointer node = this->members_.m_start.m_node + 1; + node < this->members_.m_finish.m_node; + ++node) { + this->priv_destroy_range(*node, *node + this->s_buffer_size()); + this->priv_deallocate_node(*node); + } + + if (this->members_.m_start.m_node != this->members_.m_finish.m_node) { + this->priv_destroy_range(this->members_.m_start.m_cur, this->members_.m_start.m_last); + this->priv_destroy_range(this->members_.m_finish.m_first, this->members_.m_finish.m_cur); + this->priv_deallocate_node(this->members_.m_finish.m_first); + } + else + this->priv_destroy_range(this->members_.m_start.m_cur, this->members_.m_finish.m_cur); + + this->members_.m_finish = this->members_.m_start; + } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + //! with previous allocations. The size of the deque is unchanged + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Constant. + void shrink_to_fit() + { + //This deque implementation already + //deallocates excess nodes when erasing + //so there is nothing to do except for + //empty deque + if(this->empty()){ + this->priv_clear_map(); + } + } + + /// @cond + private: + 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) + { + if (position == cbegin()){ + this->push_front(x); + return begin(); + } + else if (position == cend()){ + this->push_back(x); + return (end()-1); + } + else { + size_type n = position - cbegin(); + this->priv_insert_aux(position, size_type(1), x); + return iterator(this->begin() + n); + } + } + + iterator priv_insert(const_iterator position, BOOST_RV_REF(value_type) mx) + { + if (position == cbegin()) { + this->push_front(boost::move(mx)); + return begin(); + } + else if (position == cend()) { + this->push_back(boost::move(mx)); + return(end()-1); + } + else { + //Just call more general insert(pos, size, value) and return iterator + size_type n = position - begin(); + this->priv_insert_aux(position, move_it(r_iterator(mx, 1)), move_it(r_iterator())); + return iterator(this->begin() + n); + } + } + + void priv_push_front(const value_type &t) + { + if(this->priv_push_front_simple_available()){ + allocator_traits_type::construct + ( this->alloc(), this->priv_push_front_simple_pos(), t); + this->priv_push_front_simple_commit(); + } + else{ + this->priv_insert_aux(cbegin(), size_type(1), t); + } + } + + void priv_push_front(BOOST_RV_REF(value_type) t) + { + if(this->priv_push_front_simple_available()){ + allocator_traits_type::construct + ( this->alloc(), this->priv_push_front_simple_pos(), boost::move(t)); + this->priv_push_front_simple_commit(); + } + else{ + this->priv_insert_aux(cbegin(), move_it(r_iterator(t, 1)), move_it(r_iterator())); + } + } + + void priv_push_back(const value_type &t) + { + if(this->priv_push_back_simple_available()){ + allocator_traits_type::construct + ( this->alloc(), this->priv_push_back_simple_pos(), t); + this->priv_push_back_simple_commit(); + } + else{ + this->priv_insert_aux(cend(), size_type(1), t); + } + } + + void priv_push_back(BOOST_RV_REF(T) t) + { + if(this->priv_push_back_simple_available()){ + allocator_traits_type::construct + ( this->alloc(), this->priv_push_back_simple_pos(), boost::move(t)); + this->priv_push_back_simple_commit(); + } + else{ + this->priv_insert_aux(cend(), move_it(r_iterator(t, 1)), move_it(r_iterator())); + } + } + + bool priv_push_back_simple_available() const + { + return this->members_.m_map && + (this->members_.m_finish.m_cur != (this->members_.m_finish.m_last - 1)); + } + + T *priv_push_back_simple_pos() const + { + return container_detail::to_raw_pointer(this->members_.m_finish.m_cur); + } + + void priv_push_back_simple_commit() + { + ++this->members_.m_finish.m_cur; + } + + bool priv_push_front_simple_available() const + { + return this->members_.m_map && + (this->members_.m_start.m_cur != this->members_.m_start.m_first); + } + + T *priv_push_front_simple_pos() const + { return container_detail::to_raw_pointer(this->members_.m_start.m_cur) - 1; } + + void priv_push_front_simple_commit() + { --this->members_.m_start.m_cur; } + + template <class InpIt> + void priv_insert_aux(const_iterator pos, InpIt first, InpIt last, std::input_iterator_tag) + { + for(;first != last; ++first){ + this->insert(pos, boost::move(value_type(*first))); + } + } + + template <class FwdIt> + 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 + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + void priv_fill_assign(size_type n, const T& val) + { + if (n > size()) { + std::fill(begin(), end(), val); + this->insert(cend(), n - size(), val); + } + else { + this->erase(cbegin() + n, cend()); + std::fill(begin(), end(), val); + } + } + + template <class Integer> + 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_) + { + typedef typename std::iterator_traits<InpIt>::iterator_category ItCat; + this->priv_range_initialize(first, last, ItCat()); + } + + void priv_destroy_range(iterator p, iterator p2) + { + for(;p != p2; ++p){ + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(&*p) + ); + } + } + + void priv_destroy_range(pointer p, pointer p2) + { + for(;p != p2; ++p){ + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(&*p) + ); + } + } + + template <class Integer> + void priv_assign_dispatch(Integer n, Integer val, container_detail::true_) + { this->priv_fill_assign((size_type) n, (value_type)val); } + + template <class InpIt> + 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()); + } + + template <class InpIt> + void priv_assign_aux(InpIt first, InpIt last, std::input_iterator_tag) + { + iterator cur = begin(); + for ( ; first != last && cur != end(); ++cur, ++first) + *cur = *first; + if (first == last) + this->erase(cur, cend()); + else + this->insert(cend(), first, last); + } + + template <class FwdIt> + void priv_assign_aux(FwdIt first, FwdIt last, std::forward_iterator_tag) + { + size_type len = std::distance(first, last); + if (len > size()) { + FwdIt mid = first; + std::advance(mid, size()); + boost::copy_or_move(first, mid, begin()); + this->insert(cend(), mid, last); + } + else + this->erase(boost::copy_or_move(first, last, begin()), cend()); + } + + template <class Integer> + 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_) + { + typedef typename std::iterator_traits<InpIt>::iterator_category ItCat; + this->priv_insert_aux(pos, first, last, ItCat()); + } + + void priv_insert_aux(const_iterator pos, size_type n, const value_type& x) + { + typedef constant_iterator<value_type, difference_type> c_it; + this->priv_insert_aux(pos, c_it(x, n), c_it()); + } + + //Just forward all operations to priv_insert_aux_impl + template <class FwdIt> + void priv_insert_aux(const_iterator p, FwdIt first, FwdIt last) + { + container_detail::advanced_insert_aux_proxy<A, FwdIt, iterator> proxy(this->alloc(), first, last); + priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy); + } + + void priv_insert_aux_impl(const_iterator p, size_type n, advanced_insert_aux_int_t &interf) + { + iterator pos(p); + if(!this->members_.m_map){ + this->priv_initialize_map(0); + pos = this->begin(); + } + + const difference_type elemsbefore = pos - this->members_.m_start; + size_type length = this->size(); + if (elemsbefore < static_cast<difference_type>(length / 2)) { + iterator new_start = this->priv_reserve_elements_at_front(n); + 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); + ::boost::container::uninitialized_move_alloc + (this->alloc(), this->members_.m_start, start_n, new_start); + this->members_.m_start = new_start; + boost::move(start_n, pos, old_start); + interf.copy_remaining_to(pos - difference_type(n)); + } + else { + difference_type mid_count = (difference_type(n) - elemsbefore); + iterator mid_start = old_start - mid_count; + interf.uninitialized_copy_some_and_update(mid_start, mid_count, true); + this->members_.m_start = mid_start; + ::boost::container::uninitialized_move_alloc + (this->alloc(), old_start, pos, new_start); + this->members_.m_start = new_start; + interf.copy_remaining_to(old_start); + } + } + else { + iterator new_finish = this->priv_reserve_elements_at_back(n); + iterator old_finish = this->members_.m_finish; + const difference_type elemsafter = + difference_type(length) - elemsbefore; + pos = this->members_.m_finish - elemsafter; + if (elemsafter >= difference_type(n)) { + iterator finish_n = this->members_.m_finish - difference_type(n); + ::boost::container::uninitialized_move_alloc + (this->alloc(), finish_n, this->members_.m_finish, this->members_.m_finish); + this->members_.m_finish = new_finish; + boost::move_backward(pos, finish_n, old_finish); + interf.copy_remaining_to(pos); + } + else { + interf.uninitialized_copy_some_and_update(old_finish, elemsafter, false); + this->members_.m_finish += n-elemsafter; + ::boost::container::uninitialized_move_alloc + (this->alloc(), pos, old_finish, this->members_.m_finish); + this->members_.m_finish = new_finish; + interf.copy_remaining_to(pos); + } + } + } + + void priv_insert_back_aux_impl(size_type n, advanced_insert_aux_int_t &interf) + { + if(!this->members_.m_map){ + this->priv_initialize_map(0); + } + + iterator new_finish = this->priv_reserve_elements_at_back(n); + iterator old_finish = this->members_.m_finish; + interf.uninitialized_copy_some_and_update(old_finish, n, true); + this->members_.m_finish = new_finish; + } + + void priv_insert_front_aux_impl(size_type n, advanced_insert_aux_int_t &interf) + { + if(!this->members_.m_map){ + this->priv_initialize_map(0); + } + + iterator new_start = this->priv_reserve_elements_at_front(n); + interf.uninitialized_copy_some_and_update(new_start, difference_type(n), true); + this->members_.m_start = new_start; + } + + + void priv_fill_insert(const_iterator pos, size_type n, const value_type& x) + { + typedef constant_iterator<value_type, difference_type> c_it; + this->insert(pos, c_it(x, n), c_it()); + } + + // 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) + { + index_pointer cur; + BOOST_TRY { + for (cur = this->members_.m_start.m_node; cur < this->members_.m_finish.m_node; ++cur){ + boost::container::uninitialized_fill_alloc + (this->alloc(), *cur, *cur + this->s_buffer_size(), value); + } + boost::container::uninitialized_fill_alloc + (this->alloc(), this->members_.m_finish.m_first, this->members_.m_finish.m_cur, value); + } + BOOST_CATCH(...){ + this->priv_destroy_range(this->members_.m_start, iterator(*cur, cur)); + BOOST_RETHROW + } + BOOST_CATCH_END + } + + template <class InpIt> + void priv_range_initialize(InpIt first, InpIt last, std::input_iterator_tag) + { + this->priv_initialize_map(0); + BOOST_TRY { + for ( ; first != last; ++first) + this->push_back(*first); + } + BOOST_CATCH(...){ + this->clear(); + BOOST_RETHROW + } + BOOST_CATCH_END + } + + template <class FwdIt> + void priv_range_initialize(FwdIt first, FwdIt last, std::forward_iterator_tag) + { + size_type n = 0; + n = std::distance(first, last); + this->priv_initialize_map(n); + + index_pointer cur_node; + BOOST_TRY { + 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()); + ::boost::container::uninitialized_copy_or_move_alloc + (this->alloc(), first, mid, *cur_node); + first = mid; + } + ::boost::container::uninitialized_copy_or_move_alloc + (this->alloc(), first, last, this->members_.m_finish.m_first); + } + BOOST_CATCH(...){ + this->priv_destroy_range(this->members_.m_start, iterator(*cur_node, cur_node)); + BOOST_RETHROW + } + BOOST_CATCH_END + } + + // Called only if this->members_.m_finish.m_cur == this->members_.m_finish.m_first. + void priv_pop_back_aux() + { + this->priv_deallocate_node(this->members_.m_finish.m_first); + this->members_.m_finish.priv_set_node(this->members_.m_finish.m_node - 1); + this->members_.m_finish.m_cur = this->members_.m_finish.m_last - 1; + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_finish.m_cur) + ); + } + + // 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() + { + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_start.m_cur) + ); + 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) + { + 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) / + this->s_buffer_size(); + size_type s = (size_type)(this->members_.m_start.m_node - this->members_.m_map); + if (new_nodes > s){ + this->priv_reallocate_map(new_nodes, true); + } + size_type i = 1; + BOOST_TRY { + for (; i <= new_nodes; ++i) + *(this->members_.m_start.m_node - i) = this->priv_allocate_node(); + } + BOOST_CATCH(...) { + for (size_type j = 1; j < i; ++j) + this->priv_deallocate_node(*(this->members_.m_start.m_node - j)); + BOOST_RETHROW + } + BOOST_CATCH_END + } + return this->members_.m_start - difference_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){ + size_type new_elems = n - vacancies; + size_type new_nodes = (new_elems + this->s_buffer_size() - 1)/s_buffer_size(); + size_type s = (size_type)(this->members_.m_map_size - (this->members_.m_finish.m_node - this->members_.m_map)); + if (new_nodes + 1 > s){ + this->priv_reallocate_map(new_nodes, false); + } + size_type i; + BOOST_TRY { + for (i = 1; i <= new_nodes; ++i) + *(this->members_.m_finish.m_node + i) = this->priv_allocate_node(); + } + BOOST_CATCH(...) { + for (size_type j = 1; j < i; ++j) + this->priv_deallocate_node(*(this->members_.m_finish.m_node + j)); + BOOST_RETHROW + } + BOOST_CATCH_END + } + return this->members_.m_finish + difference_type(n); + } + + void priv_reallocate_map(size_type nodes_to_add, bool add_at_front) + { + size_type old_num_nodes = this->members_.m_finish.m_node - this->members_.m_start.m_node + 1; + size_type new_num_nodes = old_num_nodes + nodes_to_add; + + 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 + + (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); + else + boost::move_backward + (this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart + old_num_nodes); + } + else { + 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); + new_nstart = new_map + (new_map_size - new_num_nodes) / 2 + + (add_at_front ? nodes_to_add : 0); + boost::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart); + this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); + + this->members_.m_map = new_map; + this->members_.m_map_size = new_map_size; + } + + this->members_.m_start.priv_set_node(new_nstart); + this->members_.m_finish.priv_set_node(new_nstart + old_num_nodes - 1); + } + /// @endcond +}; + +// Nonmember functions. +template <class T, class A> +inline bool operator==(const deque<T, A>& x, + const deque<T, A>& y) +{ + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template <class T, class A> +inline bool operator<(const deque<T, A>& x, + 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) + { return !(x == y); } + +template <class T, class A> +inline bool operator>(const deque<T, A>& x, + 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) + { return !(y < x); } + +template <class T, class A> +inline bool operator>=(const deque<T, A>& x, + const deque<T, A>& y) + { return !(x < y); } + + +template <class T, class A> +inline void swap(deque<T, A>& x, deque<T, A>& y) +{ x.swap(y); } + +}} + +/// @cond + +namespace boost { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class A> +struct has_trivial_destructor_after_move<boost::container::deque<T, A> > +{ + enum { value = has_trivial_destructor<A>::value }; +}; +*/ +} + +/// @endcond + +#include <boost/container/detail/config_end.hpp> + +#endif // #ifndef BOOST_CONTAINER_DEQUE_HPP diff --git a/src/third_party/boost/boost/container/detail/adaptive_node_pool_impl.hpp b/src/third_party/boost/boost/container/detail/adaptive_node_pool_impl.hpp new file mode 100644 index 00000000000..36495795fbb --- /dev/null +++ b/src/third_party/boost/boost/container/detail/adaptive_node_pool_impl.hpp @@ -0,0 +1,648 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP +#define BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/container_fwd.hpp> +#include <boost/container/detail/workaround.hpp> +#include <boost/container/detail/utilities.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/set.hpp> +#include <boost/intrusive/slist.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/math_functions.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/pool_common.hpp> +#include <boost/assert.hpp> +#include <cstddef> + +namespace boost { +namespace container { +namespace container_detail { + +template<class size_type> +struct hdr_offset_holder_t +{ + hdr_offset_holder_t(size_type offset = 0) + : hdr_offset(offset) + {} + size_type hdr_offset; +}; + +template<class VoidPointer, class SizeType> +struct adaptive_pool_types +{ + typedef VoidPointer void_pointer; + typedef typename bi::make_set_base_hook + < bi::void_pointer<void_pointer> + , 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 + { + typedef typename node_slist<void_pointer>::node_slist_t free_nodes_t; + //An intrusive list of free node from this block + free_nodes_t free_nodes; + friend bool operator <(const block_info_t &l, const block_info_t &r) + { +// { return l.free_nodes.size() < r.free_nodes.size(); } + //Let's order blocks first by free nodes and then by address + //so that highest address fully free blocks are deallocated. + //This improves returning memory to the OS (trimming). + const bool is_less = l.free_nodes.size() < r.free_nodes.size(); + const bool is_equal = l.free_nodes.size() == r.free_nodes.size(); + return is_less || (is_equal && (&l < &r)); + } + + friend bool operator ==(const block_info_t &l, const block_info_t &r) + { return &l == &r; } + }; + typedef typename bi::make_multiset + <block_info_t, bi::base_hook<multiset_hook_t> >::type block_multiset_t; +}; + +template<class size_type> +inline size_type calculate_alignment + ( size_type overhead_percent, size_type real_node_size + , size_type hdr_size, size_type hdr_offset_size, size_type payload_per_allocation) +{ + //to-do: handle real_node_size != node_size + 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 = + 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 + const size_type max_subblock_overhead = hdr_size + payload_per_allocation; + while(!overhead_satisfied){ + elements_per_subblock = (candidate_power_of_2 - max_subblock_overhead)/real_node_size; + const size_type overhead_size = candidate_power_of_2 - elements_per_subblock*real_node_size; + if(overhead_size*100/candidate_power_of_2 < overhead_percent){ + overhead_satisfied = true; + } + else{ + candidate_power_of_2 <<= 1; + } + } + return candidate_power_of_2; +} + +template<class size_type> +inline void calculate_num_subblocks + (size_type alignment, size_type real_node_size, size_type elements_per_block + , size_type &num_subblocks, size_type &real_num_node, size_type overhead_percent + , size_type hdr_size, size_type hdr_offset_size, size_type payload_per_allocation) +{ + size_type elements_per_subblock = (alignment - hdr_offset_size)/real_node_size; + size_type possible_num_subblock = (elements_per_block - 1)/elements_per_subblock + 1; + size_type hdr_subblock_elements = (alignment - hdr_size - payload_per_allocation)/real_node_size; + while(((possible_num_subblock-1)*elements_per_subblock + hdr_subblock_elements) < elements_per_block){ + ++possible_num_subblock; + } + elements_per_subblock = (alignment - hdr_offset_size)/real_node_size; + bool overhead_satisfied = false; + while(!overhead_satisfied){ + const size_type total_data = (elements_per_subblock*(possible_num_subblock-1) + hdr_subblock_elements)*real_node_size; + const size_type total_size = alignment*possible_num_subblock; + if((total_size - total_data)*100/total_size < overhead_percent){ + overhead_satisfied = true; + } + else{ + ++possible_num_subblock; + } + } + num_subblocks = possible_num_subblock; + real_num_node = (possible_num_subblock-1)*elements_per_subblock + hdr_subblock_elements; +} + +template<class SegmentManagerBase, bool AlignOnly = false> +class private_adaptive_node_pool_impl +{ + //Non-copyable + private_adaptive_node_pool_impl(); + private_adaptive_node_pool_impl(const private_adaptive_node_pool_impl &); + private_adaptive_node_pool_impl &operator=(const private_adaptive_node_pool_impl &); + typedef private_adaptive_node_pool_impl this_type; + + typedef typename SegmentManagerBase::void_pointer void_pointer; + static const typename SegmentManagerBase:: + size_type PayloadPerAllocation = SegmentManagerBase::PayloadPerAllocation; + typedef bool_<AlignOnly> IsAlignOnly; + typedef true_ AlignOnlyTrue; + typedef false_ AlignOnlyFalse; + + public: + typedef typename node_slist<void_pointer>::node_t node_t; + typedef typename node_slist<void_pointer>::node_slist_t free_nodes_t; + typedef typename SegmentManagerBase::multiallocation_chain multiallocation_chain; + typedef typename SegmentManagerBase::size_type size_type; + + private: + typedef typename adaptive_pool_types<void_pointer, size_type>::block_info_t block_info_t; + typedef typename adaptive_pool_types<void_pointer, size_type>::block_multiset_t block_multiset_t; + typedef typename block_multiset_t::iterator block_iterator; + typedef typename adaptive_pool_types<void_pointer, size_type>::hdr_offset_holder hdr_offset_holder; + + static const size_type MaxAlign = alignment_of<node_t>::value; + static const size_type HdrSize = ((sizeof(block_info_t)-1)/MaxAlign+1)*MaxAlign; + static const size_type HdrOffsetSize = ((sizeof(hdr_offset_holder)-1)/MaxAlign+1)*MaxAlign; + + + public: + //!Segment manager typedef + typedef SegmentManagerBase segment_manager_base_type; + + //!Constructor from a segment manager. Never throws + private_adaptive_node_pool_impl + ( segment_manager_base_type *segment_mngr_base + , size_type node_size + , size_type nodes_per_block + , size_type max_free_blocks + , unsigned char overhead_percent + ) + : m_max_free_blocks(max_free_blocks) + , m_real_node_size(lcm(node_size, size_type(alignment_of<node_t>::value))) + //Round the size to a power of two value. + //This is the total memory size (including payload) that we want to + //allocate from the general-purpose allocator + , m_real_block_alignment + (AlignOnly ? + upper_power_of_2(HdrSize + m_real_node_size*nodes_per_block) : + calculate_alignment( (size_type)overhead_percent, m_real_node_size + , HdrSize, HdrOffsetSize, PayloadPerAllocation)) + //This is the real number of nodes per block + , m_num_subblocks(0) + , m_real_num_node(AlignOnly ? (m_real_block_alignment - PayloadPerAllocation - HdrSize)/m_real_node_size : 0) + //General purpose allocator + , mp_segment_mngr_base(segment_mngr_base) + , m_block_multiset() + , m_totally_free_blocks(0) + { + if(!AlignOnly){ + calculate_num_subblocks + ( m_real_block_alignment + , m_real_node_size + , nodes_per_block + , m_num_subblocks + , m_real_num_node + , (size_type)overhead_percent + , HdrSize + , HdrOffsetSize + , PayloadPerAllocation); + } + } + + //!Destructor. Deallocates all allocated blocks. Never throws + ~private_adaptive_node_pool_impl() + { priv_clear(); } + + size_type get_real_num_node() const + { return m_real_num_node; } + + //!Returns the segment manager. Never throws + segment_manager_base_type* get_segment_manager_base()const + { return container_detail::to_raw_pointer(mp_segment_mngr_base); } + + //!Allocates array of count elements. Can throw + void *allocate_node() + { + priv_invariants(); + //If there are no free nodes we allocate a new block + if (m_block_multiset.empty()){ + priv_alloc_block(1); + } + //We take the first free node the multiset can't be empty + return priv_take_first_node(); + } + + //!Deallocates an array pointed by ptr. Never throws + void deallocate_node(void *pElem) + { + multiallocation_chain chain; + chain.push_front(void_pointer(pElem)); + this->priv_reinsert_nodes_in_block(chain, 1); + //Update free block count< + if(m_totally_free_blocks > m_max_free_blocks){ + this->priv_deallocate_free_blocks(m_max_free_blocks); + } + priv_invariants(); + } + + //!Allocates n nodes. + //!Can throw + multiallocation_chain allocate_nodes(const size_type n) + { + multiallocation_chain chain; + size_type i = 0; + try{ + priv_invariants(); + while(i != n){ + //If there are no free nodes we allocate all needed blocks + if (m_block_multiset.empty()){ + priv_alloc_block(((n - i) - 1)/m_real_num_node + 1); + } + free_nodes_t &free_nodes = m_block_multiset.begin()->free_nodes; + const size_type free_nodes_count_before = free_nodes.size(); + if(free_nodes_count_before == m_real_num_node){ + --m_totally_free_blocks; + } + const size_type num_elems = ((n-i) < free_nodes_count_before) ? (n-i) : free_nodes_count_before; + for(size_type j = 0; j != num_elems; ++j){ + void *new_node = &free_nodes.front(); + free_nodes.pop_front(); + chain.push_back(new_node); + } + + if(free_nodes.empty()){ + m_block_multiset.erase(m_block_multiset.begin()); + } + i += num_elems; + } + } + catch(...){ + this->deallocate_nodes(boost::move(chain)); + throw; + } + priv_invariants(); + return boost::move(chain); + } + + //!Deallocates a linked list of nodes. Never throws + void deallocate_nodes(multiallocation_chain nodes) + { + this->priv_reinsert_nodes_in_block(nodes, nodes.size()); + if(m_totally_free_blocks > m_max_free_blocks){ + this->priv_deallocate_free_blocks(m_max_free_blocks); + } + } + + void deallocate_free_blocks() + { this->priv_deallocate_free_blocks(0); } + + size_type num_free_nodes() + { + typedef typename block_multiset_t::const_iterator citerator; + size_type count = 0; + citerator it (m_block_multiset.begin()), itend(m_block_multiset.end()); + for(; it != itend; ++it){ + count += it->free_nodes.size(); + } + return count; + } + + void swap(private_adaptive_node_pool_impl &other) + { + BOOST_ASSERT(m_max_free_blocks == other.m_max_free_blocks); + BOOST_ASSERT(m_real_node_size == other.m_real_node_size); + BOOST_ASSERT(m_real_block_alignment == other.m_real_block_alignment); + BOOST_ASSERT(m_real_num_node == other.m_real_num_node); + std::swap(mp_segment_mngr_base, other.mp_segment_mngr_base); + std::swap(m_totally_free_blocks, other.m_totally_free_blocks); + m_block_multiset.swap(other.m_block_multiset); + } + + //Deprecated, use deallocate_free_blocks + void deallocate_free_chunks() + { this->priv_deallocate_free_blocks(0); } + + private: + void priv_deallocate_free_blocks(size_type max_free_blocks) + { + priv_invariants(); + //Now check if we've reached the free nodes limit + //and check if we have free blocks. If so, deallocate as much + //as we can to stay below the limit + for( block_iterator itend = m_block_multiset.end() + ; m_totally_free_blocks > max_free_blocks + ; --m_totally_free_blocks + ){ + BOOST_ASSERT(!m_block_multiset.empty()); + block_iterator it = itend; + --it; + BOOST_ASSERT(it->free_nodes.size() == m_real_num_node); + m_block_multiset.erase_and_dispose(it, block_destroyer(this)); + } + } + + void priv_reinsert_nodes_in_block(multiallocation_chain &chain, size_type n) + { + block_iterator block_it(m_block_multiset.end()); + while(n--){ + void *pElem = container_detail::to_raw_pointer(chain.front()); + chain.pop_front(); + priv_invariants(); + block_info_t *block_info = this->priv_block_from_node(pElem); + BOOST_ASSERT(block_info->free_nodes.size() < m_real_num_node); + //We put the node at the beginning of the free node list + node_t * to_deallocate = static_cast<node_t*>(pElem); + block_info->free_nodes.push_front(*to_deallocate); + + block_iterator this_block(block_multiset_t::s_iterator_to(*block_info)); + block_iterator next_block(this_block); + ++next_block; + + //Cache the free nodes from the block + size_type this_block_free_nodes = this_block->free_nodes.size(); + + if(this_block_free_nodes == 1){ + m_block_multiset.insert(m_block_multiset.begin(), *block_info); + } + else{ + block_iterator next_block(this_block); + ++next_block; + if(next_block != block_it){ + size_type next_free_nodes = next_block->free_nodes.size(); + if(this_block_free_nodes > next_free_nodes){ + //Now move the block to the new position + m_block_multiset.erase(this_block); + m_block_multiset.insert(*block_info); + } + } + } + //Update free block count + if(this_block_free_nodes == m_real_num_node){ + ++m_totally_free_blocks; + } + priv_invariants(); + } + } + + node_t *priv_take_first_node() + { + BOOST_ASSERT(m_block_multiset.begin() != m_block_multiset.end()); + //We take the first free node the multiset can't be empty + free_nodes_t &free_nodes = m_block_multiset.begin()->free_nodes; + node_t *first_node = &free_nodes.front(); + const size_type free_nodes_count = free_nodes.size(); + BOOST_ASSERT(0 != free_nodes_count); + free_nodes.pop_front(); + if(free_nodes_count == 1){ + m_block_multiset.erase(m_block_multiset.begin()); + } + else if(free_nodes_count == m_real_num_node){ + --m_totally_free_blocks; + } + priv_invariants(); + return first_node; + } + + class block_destroyer; + friend class block_destroyer; + + class block_destroyer + { + public: + block_destroyer(const this_type *impl) + : mp_impl(impl) + {} + + void operator()(typename block_multiset_t::pointer to_deallocate) + { return this->do_destroy(to_deallocate, IsAlignOnly()); } + + private: + void do_destroy(typename block_multiset_t::pointer to_deallocate, AlignOnlyTrue) + { + size_type free_nodes = to_deallocate->free_nodes.size(); + (void)free_nodes; + BOOST_ASSERT(free_nodes == mp_impl->m_real_num_node); + mp_impl->mp_segment_mngr_base->deallocate(to_deallocate); + } + + void do_destroy(typename block_multiset_t::pointer to_deallocate, AlignOnlyFalse) + { + size_type free_nodes = to_deallocate->free_nodes.size(); + (void)free_nodes; + BOOST_ASSERT(free_nodes == mp_impl->m_real_num_node); + BOOST_ASSERT(0 == to_deallocate->hdr_offset); + hdr_offset_holder *hdr_off_holder = mp_impl->priv_first_subblock_from_block(container_detail::to_raw_pointer(to_deallocate)); + mp_impl->mp_segment_mngr_base->deallocate(hdr_off_holder); + } + + const this_type *mp_impl; + }; + + //This macro will activate invariant checking. Slow, but helpful for debugging the code. + //#define BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS + void priv_invariants() + #ifdef BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS + #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()), + itend(m_block_multiset.end()), to_deallocate; + if(it != itend){ + for(++it; it != itend; ++it){ + block_iterator prev(it); + --prev; + size_type sp = prev->free_nodes.size(), + si = it->free_nodes.size(); + BOOST_ASSERT(sp <= si); + (void)sp; (void)si; + } + } + //Check that the total free nodes are correct + it = m_block_multiset.begin(); + itend = m_block_multiset.end(); + size_type total_free_nodes = 0; + for(; it != itend; ++it){ + total_free_nodes += it->free_nodes.size(); + } + BOOST_ASSERT(total_free_nodes >= m_totally_free_blocks*m_real_num_node); + + //Check that the total totally free blocks are correct + it = m_block_multiset.begin(); + itend = m_block_multiset.end(); + total_free = 0; + for(; it != itend; ++it){ + total_free += it->free_nodes.size() == m_real_num_node; + } + BOOST_ASSERT(total_free >= m_totally_free_blocks); + + if(!AlignOnly){ + //Check that header offsets are correct + it = m_block_multiset.begin(); + for(; it != itend; ++it){ + hdr_offset_holder *hdr_off_holder = priv_first_subblock_from_block(&*it); + for(size_type i = 0, max = m_num_subblocks; i < max; ++i){ + BOOST_ASSERT(hdr_off_holder->hdr_offset == size_type(reinterpret_cast<char*>(&*it)- reinterpret_cast<char*>(hdr_off_holder))); + BOOST_ASSERT(0 == ((size_type)hdr_off_holder & (m_real_block_alignment - 1))); + BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1))); + hdr_off_holder = reinterpret_cast<hdr_offset_holder *>(reinterpret_cast<char*>(hdr_off_holder) + m_real_block_alignment); + } + } + } + } + #else + {} //empty + #endif + + //!Deallocates all used memory. Never throws + void priv_clear() + { + #ifndef NDEBUG + block_iterator it = m_block_multiset.begin(); + block_iterator itend = m_block_multiset.end(); + size_type num_free_nodes = 0; + for(; it != itend; ++it){ + //Check for memory leak + BOOST_ASSERT(it->free_nodes.size() == m_real_num_node); + ++num_free_nodes; + } + BOOST_ASSERT(num_free_nodes == m_totally_free_blocks); + #endif + //Check for memory leaks + priv_invariants(); + m_block_multiset.clear_and_dispose(block_destroyer(this)); + m_totally_free_blocks = 0; + } + + block_info_t *priv_block_from_node(void *node, AlignOnlyFalse) const + { + hdr_offset_holder *hdr_off_holder = + reinterpret_cast<hdr_offset_holder*>((std::size_t)node & size_type(~(m_real_block_alignment - 1))); + BOOST_ASSERT(0 == ((std::size_t)hdr_off_holder & (m_real_block_alignment - 1))); + BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1))); + block_info_t *block = reinterpret_cast<block_info_t *> + (reinterpret_cast<char*>(hdr_off_holder) + hdr_off_holder->hdr_offset); + BOOST_ASSERT(block->hdr_offset == 0); + return block; + } + + block_info_t *priv_block_from_node(void *node, AlignOnlyTrue) const + { + return (block_info_t *)((std::size_t)node & std::size_t(~(m_real_block_alignment - 1))); + } + + block_info_t *priv_block_from_node(void *node) const + { return priv_block_from_node(node, IsAlignOnly()); } + + hdr_offset_holder *priv_first_subblock_from_block(block_info_t *block) const + { + hdr_offset_holder *hdr_off_holder = reinterpret_cast<hdr_offset_holder*> + (reinterpret_cast<char*>(block) - (m_num_subblocks-1)*m_real_block_alignment); + BOOST_ASSERT(hdr_off_holder->hdr_offset == size_type(reinterpret_cast<char*>(block) - reinterpret_cast<char*>(hdr_off_holder))); + BOOST_ASSERT(0 == ((std::size_t)hdr_off_holder & (m_real_block_alignment - 1))); + BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1))); + return hdr_off_holder; + } + + //!Allocates a several blocks of nodes. Can throw + void priv_alloc_block(size_type n, AlignOnlyTrue) + { + size_type real_block_size = m_real_block_alignment - PayloadPerAllocation; + for(size_type i = 0; i != n; ++i){ + //We allocate a new NodeBlock and put it the last + //element of the tree + char *mem_address = static_cast<char*> + (mp_segment_mngr_base->allocate_aligned(real_block_size, m_real_block_alignment)); + if(!mem_address) throw std::bad_alloc(); + ++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 + //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){ + prev_insert_pos = c_info->free_nodes.insert_after(prev_insert_pos, *(node_t*)mem_address); + mem_address += m_real_node_size; + } + } + } + + void priv_alloc_block(size_type n, AlignOnlyFalse) + { + size_type real_block_size = m_real_block_alignment*m_num_subblocks - PayloadPerAllocation; + size_type elements_per_subblock = (m_real_block_alignment - HdrOffsetSize)/m_real_node_size; + size_type hdr_subblock_elements = (m_real_block_alignment - HdrSize - PayloadPerAllocation)/m_real_node_size; + + for(size_type i = 0; i != n; ++i){ + //We allocate a new NodeBlock and put it the last + //element of the tree + char *mem_address = static_cast<char*> + (mp_segment_mngr_base->allocate_aligned(real_block_size, m_real_block_alignment)); + if(!mem_address) throw std::bad_alloc(); + ++m_totally_free_blocks; + + //First initialize header information on the last subblock + char *hdr_addr = mem_address + m_real_block_alignment*(m_num_subblocks-1); + block_info_t *c_info = new(hdr_addr)block_info_t(); + //Some structural checks + BOOST_ASSERT(static_cast<void*>(&static_cast<hdr_offset_holder*>(c_info)->hdr_offset) == + static_cast<void*>(c_info)); + typename free_nodes_t::iterator prev_insert_pos = c_info->free_nodes.before_begin(); + for( size_type subblock = 0, maxsubblock = m_num_subblocks - 1 + ; subblock < maxsubblock + ; ++subblock, mem_address += m_real_block_alignment){ + //Initialize header offset mark + new(mem_address) hdr_offset_holder(size_type(hdr_addr - mem_address)); + char *pNode = mem_address + HdrOffsetSize; + for(size_type i = 0; i < elements_per_subblock; ++i){ + prev_insert_pos = c_info->free_nodes.insert_after(prev_insert_pos, *new (pNode) node_t); + pNode += m_real_node_size; + } + } + { + char *pNode = hdr_addr + HdrSize; + //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); + pNode += m_real_node_size; + } + } + //Insert the block after the free node list is full + m_block_multiset.insert(m_block_multiset.end(), *c_info); + } + } + + //!Allocates a block of nodes. Can throw std::bad_alloc + void priv_alloc_block(size_type n) + { return priv_alloc_block(n, IsAlignOnly()); } + + private: + typedef typename boost::intrusive::pointer_traits + <void_pointer>::template rebind_pointer<segment_manager_base_type>::type segment_mngr_base_ptr_t; + const size_type m_max_free_blocks; + const size_type m_real_node_size; + //Round the size to a power of two value. + //This is the total memory size (including payload) that we want to + //allocate from the general-purpose allocator + const size_type m_real_block_alignment; + size_type m_num_subblocks; + //This is the real number of nodes per block + //const + size_type m_real_num_node; + segment_mngr_base_ptr_t mp_segment_mngr_base; //Segment manager + block_multiset_t m_block_multiset; //Intrusive block list + size_type m_totally_free_blocks; //Free blocks +}; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP diff --git a/src/third_party/boost/boost/container/detail/advanced_insert_int.hpp b/src/third_party/boost/boost/container/detail/advanced_insert_int.hpp new file mode 100644 index 00000000000..58199c7aa8c --- /dev/null +++ b/src/third_party/boost/boost/container/detail/advanced_insert_int.hpp @@ -0,0 +1,428 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-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_ADVANCED_INSERT_INT_HPP +#define BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> +#include <boost/container/allocator/allocator_traits.hpp> +#include <boost/move/move.hpp> +#include <iterator> //std::iterator_traits +#include <boost/assert.hpp> + +namespace boost { namespace container { namespace container_detail { + +//This class will be interface for operations dependent on FwdIt types used advanced_insert_aux_impl +template<class Iterator> +struct advanced_insert_aux_int +{ + typedef typename std::iterator_traits<Iterator>::difference_type difference_type; + virtual void copy_remaining_to(Iterator p) = 0; + virtual void uninitialized_copy_remaining_to(Iterator p) = 0; + virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first) = 0; + virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first) = 0; + virtual ~advanced_insert_aux_int() {} +}; + +//This class template will adapt each FwIt types to advanced_insert_aux_int +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; + + advanced_insert_aux_proxy(A& a, FwdIt first, FwdIt last) + : a_(a), first_(first), last_(last) + {} + + virtual ~advanced_insert_aux_proxy() + {} + + virtual void copy_remaining_to(Iterator p) + { ::boost::copy_or_move(first_, last_, p); } + + virtual void uninitialized_copy_remaining_to(Iterator p) + { ::boost::container::uninitialized_copy_or_move_alloc(a_, first_, last_, p); } + + virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n) + { + FwdIt mid = first_; + std::advance(mid, division_count); + if(first_n){ + ::boost::container::uninitialized_copy_or_move_alloc(a_, first_, mid, pos); + first_ = mid; + } + else{ + ::boost::container::uninitialized_copy_or_move_alloc(a_, mid, last_, pos); + last_ = mid; + } + } + + virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first_n) + { + FwdIt mid = first_; + std::advance(mid, division_count); + if(first_n){ + ::boost::copy_or_move(first_, mid, pos); + first_ = mid; + } + else{ + ::boost::copy_or_move(mid, last_, pos); + last_ = mid; + } + } + A &a_; + FwdIt first_, last_; +}; + +//This class template will adapt default construction insertions to advanced_insert_aux_int +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 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; + + default_construct_aux_proxy(A &a, size_type count) + : a_(a), count_(count) + {} + + virtual ~default_construct_aux_proxy() + {} + + virtual void copy_remaining_to(Iterator) + { //This should never be called with any count + BOOST_ASSERT(count_ == 0); + } + + virtual void uninitialized_copy_remaining_to(Iterator p) + { this->priv_uninitialized_copy(p, count_); } + + virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n) + { + size_type new_count; + if(first_n){ + new_count = division_count; + } + else{ + BOOST_ASSERT(difference_type(count_)>= division_count); + new_count = 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); + size_type new_count; + if(first_n){ + new_count = division_count; + } + else{ + BOOST_ASSERT(difference_type(count_)>= division_count); + new_count = count_ - division_count; + } + //This function should never called with a count different to zero + BOOST_ASSERT(new_count == 0); + (void)new_count; + } + + private: + void priv_uninitialized_copy(Iterator p, const size_type n) + { + BOOST_ASSERT(n <= 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)); + } + } + catch(...){ + while(i--){ + alloc_traits::destroy(a_, container_detail::to_raw_pointer(&*orig_p++)); + } + throw; + } + count_ -= n; + } + A &a_; + size_type count_; +}; + +}}} //namespace boost { namespace container { namespace container_detail { + +#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + +#include <boost/container/detail/variadic_templates_tools.hpp> +#include <boost/container/detail/stored_ref.hpp> +#include <boost/move/move.hpp> +#include <typeinfo> +//#include <iostream> //For debugging purposes + +namespace boost { +namespace container { +namespace container_detail { + + +//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 + : 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; + typedef typename build_number_seq<sizeof...(Args)>::type index_tuple_t; + + explicit advanced_insert_aux_non_movable_emplace(A &a, Args&&... args) + : a_(a) + , args_(args...) + , used_(false) + {} + + ~advanced_insert_aux_non_movable_emplace() + {} + + virtual void copy_remaining_to(Iterator) + //This code can't be called since value_type is not movable or copyable + { BOOST_ASSERT(false); } + + virtual void uninitialized_copy_remaining_to(Iterator p) + { this->priv_uninitialized_copy_remaining_to(index_tuple_t(), p); } + + virtual void uninitialized_copy_some_and_update(Iterator p, difference_type division_count, bool first_n) + { this->priv_uninitialized_copy_some_and_update(index_tuple_t(), p, division_count, first_n); } + + virtual void copy_some_and_update(Iterator, difference_type, bool ) + //This code can't be called since value_type is not movable or copyable + { BOOST_ASSERT(false); } + + private: + template<int ...IdxPack> + void priv_uninitialized_copy_some_and_update(const index_tuple<IdxPack...>&, Iterator p, difference_type division_count, bool first_n) + { + BOOST_ASSERT(division_count <=1); + if((first_n && division_count == 1) || (!first_n && division_count == 0)){ + if(!used_){ + alloc_traits::construct( a_ + , container_detail::to_raw_pointer(&*p) + , ::boost::container::container_detail:: + stored_ref<Args>::forward(get<IdxPack>(args_))... + ); + used_ = true; + } + } + } + + template<int ...IdxPack> + void priv_uninitialized_copy_remaining_to(const index_tuple<IdxPack...>&, Iterator p) + { + if(!used_){ + alloc_traits::construct( a_ + , container_detail::to_raw_pointer(&*p) + , ::boost::container::container_detail:: + stored_ref<Args>::forward(get<IdxPack>(args_))... + ); + used_ = true; + } + } + + protected: + A &a_; + tuple<Args&...> args_; + bool used_; +}; + +//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 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)...) + {} + + ~advanced_insert_aux_emplace() + {} + + //Override only needed functions + virtual void copy_remaining_to(Iterator p) + { this->priv_copy_remaining_to(index_tuple_t(), p); } + + virtual void copy_some_and_update(Iterator p, difference_type division_count, bool first_n) + { this->priv_copy_some_and_update(index_tuple_t(), p, division_count, first_n); } + + private: + template<int ...IdxPack> + 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_))...)); + this->used_ = true; + } + } + + template<int ...IdxPack> + void priv_copy_some_and_update(const index_tuple<IdxPack...>&, Iterator p, difference_type division_count, bool first_n) + { + 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_))...)); + this->used_ = true; + } + } + } +}; + +}}} //namespace boost { namespace container { namespace container_detail { + +#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + +#include <boost/container/detail/preprocessor.hpp> +#include <boost/container/detail/value_init.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +#define BOOST_PP_LOCAL_MACRO(n) \ +template<class A, class Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \ +struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), arg) \ + : 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; \ + \ + BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), arg) \ + ( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ + : a_(a) \ + , used_(false) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_INIT, _) \ + {} \ + \ + virtual void copy_remaining_to(Iterator) \ + { BOOST_ASSERT(false); } \ + \ + virtual void uninitialized_copy_remaining_to(Iterator p) \ + { \ + if(!used_){ \ + alloc_traits::construct \ + ( a_ \ + , container_detail::to_raw_pointer(&*p) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \ + ); \ + used_ = true; \ + } \ + } \ + \ + virtual void uninitialized_copy_some_and_update \ + (Iterator p, difference_type division_count, bool first_n) \ + { \ + BOOST_ASSERT(division_count <=1); \ + if((first_n && division_count == 1) || (!first_n && division_count == 0)){ \ + if(!used_){ \ + alloc_traits::construct \ + ( a_ \ + , container_detail::to_raw_pointer(&*p) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \ + ); \ + used_ = true; \ + } \ + } \ + } \ + \ + virtual void copy_some_and_update(Iterator, difference_type, bool) \ + { BOOST_ASSERT(false); } \ + \ + A &a_; \ + bool used_; \ + BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \ +}; \ + \ +template<class A, class Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \ +struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ + : BOOST_PP_CAT(BOOST_PP_CAT( \ + advanced_insert_aux_non_movable_emplace, n), arg) \ + < A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P) > \ +{ \ + typedef BOOST_PP_CAT(BOOST_PP_CAT( \ + advanced_insert_aux_non_movable_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; \ + \ + BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ + ( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ + : base_t(a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ) \ + {} \ + \ + 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); \ + this->used_ = true; \ + } \ + } \ + \ + virtual void copy_some_and_update \ + (Iterator p, difference_type division_count, bool first_n) \ + { \ + 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); \ + this->used_ = true; \ + } \ + } \ + } \ +}; \ +//! + +#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) +#include BOOST_PP_LOCAL_ITERATE() + +}}} //namespace boost { namespace container { namespace container_detail { + +#endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP diff --git a/src/third_party/boost/boost/container/detail/algorithms.hpp b/src/third_party/boost/boost/container/detail/algorithms.hpp new file mode 100644 index 00000000000..a2713f50f11 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/algorithms.hpp @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_ALGORITHMS_HPP +#define BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> + +#include <boost/type_traits/has_trivial_copy.hpp> +#include <boost/type_traits/has_trivial_assign.hpp> +#include <boost/detail/no_exceptions_support.hpp> + +#include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/iterators.hpp> + + +#include <cstring> + +namespace boost { +namespace container { + +template<class A, class T, class InpIt> +inline void construct_in_place(A &a, T* dest, InpIt source) +{ boost::container::allocator_traits<A>::construct(a, dest, *source); } +//#endif + +template<class A, class T, class U, class D> +inline void construct_in_place(A &a, T *dest, default_construct_iterator<U, D>) +{ + boost::container::allocator_traits<A>::construct(a, dest); +} + +template<class A, class T, class U, class EF, class D> +inline void construct_in_place(A &a, T *dest, emplace_iterator<U, EF, D> ei) +{ + ei.construct_in_place(a, dest); +} + +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP + diff --git a/src/third_party/boost/boost/container/detail/allocation_type.hpp b/src/third_party/boost/boost/container/detail/allocation_type.hpp new file mode 100644 index 00000000000..edad487c57a --- /dev/null +++ b/src/third_party/boost/boost/container/detail/allocation_type.hpp @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_ALLOCATION_TYPE_HPP +#define BOOST_CONTAINER_ALLOCATION_TYPE_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> + +namespace boost { +namespace container { + +/// @cond +enum allocation_type_v +{ + // constants for allocation commands + allocate_new_v = 0x01, + expand_fwd_v = 0x02, + expand_bwd_v = 0x04, +// expand_both = expand_fwd | expand_bwd, +// expand_or_new = allocate_new | expand_both, + shrink_in_place_v = 0x08, + nothrow_allocation_v = 0x10, + zero_memory_v = 0x20, + try_shrink_in_place_v = 0x40 +}; + +typedef int allocation_type; +/// @endcond +static const allocation_type allocate_new = (allocation_type)allocate_new_v; +static const allocation_type expand_fwd = (allocation_type)expand_fwd_v; +static const allocation_type expand_bwd = (allocation_type)expand_bwd_v; +static const allocation_type shrink_in_place = (allocation_type)shrink_in_place_v; +static const allocation_type try_shrink_in_place= (allocation_type)try_shrink_in_place_v; +static const allocation_type nothrow_allocation = (allocation_type)nothrow_allocation_v; +static const allocation_type zero_memory = (allocation_type)zero_memory_v; + +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //BOOST_CONTAINER_ALLOCATION_TYPE_HPP diff --git a/src/third_party/boost/boost/container/detail/config_begin.hpp b/src/third_party/boost/boost/container/detail/config_begin.hpp new file mode 100644 index 00000000000..bd44daacfe5 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/config_begin.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_CONTAINER_DETAIL_CONFIG_INCLUDED +#define BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED +#include <boost/config.hpp> + +#endif //BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED + +#ifdef BOOST_MSVC + #ifndef _CRT_SECURE_NO_DEPRECATE + #define BOOST_CONTAINER_DETAIL_CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE + #endif + #pragma warning (push) + #pragma warning (disable : 4702) // unreachable code + #pragma warning (disable : 4706) // assignment within conditional expression + #pragma warning (disable : 4127) // conditional expression is constant + #pragma warning (disable : 4146) // unary minus operator applied to unsigned type, result still unsigned + #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4244) // possible loss of data + #pragma warning (disable : 4251) // "identifier" : class "type" needs to have dll-interface to be used by clients of class "type2" + #pragma warning (disable : 4267) // conversion from "X" to "Y", possible loss of data + #pragma warning (disable : 4275) // non DLL-interface classkey "identifier" used as base for DLL-interface classkey "identifier" + #pragma warning (disable : 4355) // "this" : used in base member initializer list + #pragma warning (disable : 4503) // "identifier" : decorated name length exceeded, name was truncated + #pragma warning (disable : 4511) // copy constructor could not be generated + #pragma warning (disable : 4512) // assignment operator could not be generated + #pragma warning (disable : 4514) // unreferenced inline removed + #pragma warning (disable : 4521) // Disable "multiple copy constructors specified" + #pragma warning (disable : 4522) // "class" : multiple assignment operators specified + #pragma warning (disable : 4675) // "method" should be declared "static" and have exactly one parameter + #pragma warning (disable : 4710) // function not inlined + #pragma warning (disable : 4711) // function selected for automatic inline expansion + #pragma warning (disable : 4786) // identifier truncated in debug info + #pragma warning (disable : 4996) // "function": was declared deprecated + #pragma warning (disable : 4197) // top-level volatile in cast is ignored + #pragma warning (disable : 4541) // 'typeid' used on polymorphic type 'boost::exception' + // 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 +#endif //BOOST_MSVC diff --git a/src/third_party/boost/boost/container/detail/config_end.hpp b/src/third_party/boost/boost/container/detail/config_end.hpp new file mode 100644 index 00000000000..b71fabcdaec --- /dev/null +++ b/src/third_party/boost/boost/container/detail/config_end.hpp @@ -0,0 +1,17 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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. +// +////////////////////////////////////////////////////////////////////////////// +#if defined BOOST_MSVC + #pragma warning (pop) + #ifdef BOOST_CONTAINER_DETAIL_CRT_SECURE_NO_DEPRECATE + #undef BOOST_CONTAINER_DETAIL_CRT_SECURE_NO_DEPRECATE + #undef _CRT_SECURE_NO_DEPRECATE + #endif +#endif + diff --git a/src/third_party/boost/boost/container/detail/destroyers.hpp b/src/third_party/boost/boost/container/detail/destroyers.hpp new file mode 100644 index 00000000000..26ae089aa6a --- /dev/null +++ b/src/third_party/boost/boost/container/detail/destroyers.hpp @@ -0,0 +1,163 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DESTROYERS_HPP +#define BOOST_CONTAINER_DESTROYERS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#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> + +namespace boost { +namespace container { +namespace container_detail { + +//!A deleter for scoped_ptr that deallocates the memory +//!allocated for an array of objects using a STL allocator. +template <class Allocator> +struct scoped_array_deallocator +{ + typedef boost::container::allocator_traits<Allocator> AllocTraits; + typedef typename AllocTraits::pointer pointer; + typedef typename AllocTraits::size_type size_type; + + scoped_array_deallocator(pointer p, Allocator& a, size_type length) + : m_ptr(p), m_alloc(a), m_length(length) {} + + ~scoped_array_deallocator() + { if (m_ptr) m_alloc.deallocate(m_ptr, m_length); } + + void release() + { m_ptr = 0; } + + private: + pointer m_ptr; + Allocator& m_alloc; + size_type m_length; +}; + +template <class Allocator> +struct null_scoped_array_deallocator +{ + typedef boost::container::allocator_traits<Allocator> AllocTraits; + typedef typename AllocTraits::pointer pointer; + typedef typename AllocTraits::size_type size_type; + + null_scoped_array_deallocator(pointer, Allocator&, size_type) + {} + + void release() + {} +}; + + +//!A deleter for scoped_ptr that destroys +//!an object using a STL allocator. +template <class Allocator> +struct scoped_destructor_n +{ + typedef boost::container::allocator_traits<Allocator> AllocTraits; + typedef typename AllocTraits::pointer pointer; + typedef typename AllocTraits::value_type value_type; + typedef typename AllocTraits::size_type size_type; + + scoped_destructor_n(pointer p, Allocator& a, size_type n) + : m_p(p), m_a(a), m_n(n) + {} + + void release() + { m_p = 0; } + + void increment_size(size_type inc) + { m_n += inc; } + + ~scoped_destructor_n() + { + if(!m_p) return; + value_type *raw_ptr = container_detail::to_raw_pointer(m_p); + for(size_type i = 0; i < m_n; ++i, ++raw_ptr) + AllocTraits::destroy(m_a, raw_ptr); + } + + private: + pointer m_p; + Allocator & m_a; + size_type m_n; +}; + +//!A deleter for scoped_ptr that destroys +//!an object using a STL allocator. +template <class Allocator> +struct null_scoped_destructor_n +{ + typedef boost::container::allocator_traits<Allocator> AllocTraits; + typedef typename AllocTraits::pointer pointer; + typedef typename AllocTraits::size_type size_type; + + null_scoped_destructor_n(pointer, Allocator&, size_type) + {} + + void increment_size(size_type) + {} + + void release() + {} +}; + +template <class Allocator> +class allocator_destroyer +{ + typedef boost::container::allocator_traits<Allocator> AllocTraits; + typedef typename AllocTraits::value_type value_type; + typedef typename AllocTraits::pointer pointer; + 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; + + private: + Allocator & a_; + + private: + void priv_deallocate(const pointer &p, allocator_v1) + { AllocTraits::deallocate(a_,p, 1); } + + void priv_deallocate(const pointer &p, allocator_v2) + { a_.deallocate_one(p); } + + public: + allocator_destroyer(Allocator &a) + : a_(a) + {} + + void operator()(const pointer &p) + { + AllocTraits::destroy(a_, container_detail::to_raw_pointer(p)); + priv_deallocate(p, alloc_version()); + } +}; + + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DESTROYERS_HPP diff --git a/src/third_party/boost/boost/container/detail/flat_tree.hpp b/src/third_party/boost/boost/container/detail/flat_tree.hpp new file mode 100644 index 00000000000..44438386a3a --- /dev/null +++ b/src/third_party/boost/boost/container/detail/flat_tree.hpp @@ -0,0 +1,822 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_FLAT_TREE_HPP +#define BOOST_CONTAINER_FLAT_TREE_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> + +#include <boost/container/container_fwd.hpp> + +#include <algorithm> +#include <functional> +#include <utility> + +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/move/move.hpp> + +#include <boost/container/detail/utilities.hpp> +#include <boost/container/detail/pair.hpp> +#include <boost/container/vector.hpp> +#include <boost/container/detail/value_init.hpp> +#include <boost/container/detail/destroyers.hpp> + +namespace boost { + +namespace container { + +namespace container_detail { + +template<class Compare, class Value, class KeyOfValue> +class flat_tree_value_compare + : private Compare +{ + typedef Value first_argument_type; + typedef Value second_argument_type; + typedef bool return_type; + public: + flat_tree_value_compare() + : Compare() + {} + + 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)); + } + + const Compare &get_comp() const + { return *this; } + + Compare &get_comp() + { return *this; } +}; + +template<class Pointer> +struct get_flat_tree_iterators +{ + typedef typename container_detail:: + vector_iterator<Pointer> iterator; + typedef typename container_detail:: + vector_const_iterator<Pointer> const_iterator; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; +}; + +template <class Key, class Value, class KeyOfValue, + class Compare, class A> +class flat_tree +{ + typedef boost::container::vector<Value, A> vector_t; + typedef A allocator_t; + + public: + typedef flat_tree_value_compare<Compare, Value, KeyOfValue> value_compare; + + private: + struct Data + //Inherit from value_compare to do EBO + : public value_compare + { + BOOST_COPYABLE_AND_MOVABLE(Data) + + public: + Data() + : value_compare(), m_vect() + {} + + Data(const Data &d) + : 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)) + {} + + Data(const Compare &comp) + : value_compare(comp), m_vect() + {} + + Data(const Compare &comp, + const allocator_t &alloc) + : value_compare(comp), m_vect(alloc) + {} + + Data& operator=(BOOST_COPY_ASSIGN_REF(Data) d) + { + this->value_compare::operator=(d); + m_vect = d.m_vect; + return *this; + } + + Data& operator=(BOOST_RV_REF(Data) d) + { + this->value_compare::operator=(boost::move(static_cast<value_compare &>(d))); + m_vect = boost::move(d.m_vect); + return *this; + } + + void swap(Data &d) + { + value_compare& mycomp = *this, & othercomp = d; + container_detail::do_swap(mycomp, othercomp); + this->m_vect.swap(d.m_vect); + } + + vector_t m_vect; + }; + + Data m_data; + BOOST_COPYABLE_AND_MOVABLE(flat_tree) + + public: + + typedef typename vector_t::value_type value_type; + typedef typename vector_t::pointer pointer; + typedef typename vector_t::const_pointer const_pointer; + typedef typename vector_t::reference reference; + typedef typename vector_t::const_reference const_reference; + typedef Key key_type; + typedef Compare key_compare; + typedef typename vector_t::allocator_type allocator_type; + typedef typename vector_t::size_type size_type; + typedef typename vector_t::difference_type difference_type; + typedef typename vector_t::iterator iterator; + typedef typename vector_t::const_iterator const_iterator; + typedef typename vector_t::reverse_iterator reverse_iterator; + typedef typename vector_t::const_reverse_iterator const_reverse_iterator; + + //!Standard extension + typedef allocator_type stored_allocator_type; + + flat_tree() + : m_data() + { } + + explicit flat_tree(const Compare& comp) + : m_data(comp) + { } + + flat_tree(const Compare& comp, const allocator_type& a) + : m_data(comp, a) + { } + + flat_tree(const flat_tree& x) + : m_data(x.m_data) + { } + + flat_tree(BOOST_RV_REF(flat_tree) x) + : m_data(boost::move(x.m_data)) + { } + + template <class InputIterator> + flat_tree( ordered_range_t, InputIterator first, InputIterator last + , const Compare& comp = Compare() + , const allocator_type& a = allocator_type()) + : m_data(comp, a) + { this->m_data.m_vect.insert(this->m_data.m_vect.end(), first, last); } + + ~flat_tree() + { } + + flat_tree& operator=(BOOST_COPY_ASSIGN_REF(flat_tree) x) + { m_data = x.m_data; return *this; } + + flat_tree& operator=(BOOST_RV_REF(flat_tree) mx) + { m_data = boost::move(mx.m_data); return *this; } + + public: + // accessors: + Compare key_comp() const + { return this->m_data.get_comp(); } + + allocator_type get_allocator() const + { return this->m_data.m_vect.get_allocator(); } + + 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() + { return this->m_data.m_vect.begin(); } + + const_iterator begin() const + { return this->cbegin(); } + + const_iterator cbegin() const + { return this->m_data.m_vect.begin(); } + + iterator end() + { return this->m_data.m_vect.end(); } + + const_iterator end() const + { return this->cend(); } + + const_iterator cend() const + { return this->m_data.m_vect.end(); } + + reverse_iterator rbegin() + { return reverse_iterator(this->end()); } + + const_reverse_iterator rbegin() const + { return this->crbegin(); } + + const_reverse_iterator crbegin() const + { return const_reverse_iterator(this->cend()); } + + reverse_iterator rend() + { return reverse_iterator(this->begin()); } + + const_reverse_iterator rend() const + { return this->crend(); } + + const_reverse_iterator crend() const + { return const_reverse_iterator(this->cbegin()); } + + bool empty() const + { return this->m_data.m_vect.empty(); } + + size_type size() const + { return this->m_data.m_vect.size(); } + + size_type max_size() const + { return this->m_data.m_vect.max_size(); } + + void swap(flat_tree& other) + { this->m_data.swap(other.m_data); } + + public: + // insert/erase + std::pair<iterator,bool> insert_unique(const value_type& val) + { + insert_commit_data data; + std::pair<iterator,bool> ret = priv_insert_unique_prepare(val, data); + if(ret.second){ + ret.first = priv_insert_commit(data, val); + } + return ret; + } + + std::pair<iterator,bool> insert_unique(BOOST_RV_REF(value_type) val) + { + insert_commit_data data; + std::pair<iterator,bool> ret = priv_insert_unique_prepare(val, data); + if(ret.second){ + ret.first = priv_insert_commit(data, boost::move(val)); + } + return ret; + } + + + iterator insert_equal(const value_type& val) + { + iterator i = this->upper_bound(KeyOfValue()(val)); + i = this->m_data.m_vect.insert(i, val); + return i; + } + + iterator insert_equal(BOOST_RV_REF(value_type) mval) + { + iterator i = this->upper_bound(KeyOfValue()(mval)); + i = this->m_data.m_vect.insert(i, boost::move(mval)); + return i; + } + + iterator insert_unique(const_iterator pos, const value_type& val) + { + insert_commit_data data; + std::pair<iterator,bool> ret = priv_insert_unique_prepare(pos, val, data); + if(ret.second){ + ret.first = priv_insert_commit(data, val); + } + return ret.first; + } + + iterator insert_unique(const_iterator pos, BOOST_RV_REF(value_type) mval) + { + insert_commit_data data; + std::pair<iterator,bool> ret = priv_insert_unique_prepare(pos, mval, data); + if(ret.second){ + ret.first = priv_insert_commit(data, boost::move(mval)); + } + return ret.first; + } + + iterator insert_equal(const_iterator pos, const value_type& val) + { + insert_commit_data data; + 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); + return priv_insert_commit(data, boost::move(mval)); + } + + template <class InIt> + void insert_unique(InIt first, InIt last) + { + for ( ; first != last; ++first) + this->insert_unique(*first); + } + + template <class InIt> + void insert_equal(InIt first, InIt last) + { + typedef typename + std::iterator_traits<InIt>::iterator_category ItCat; + priv_insert_equal(first, last, ItCat()); + } + + #ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + template <class... Args> + std::pair<iterator, bool> emplace_unique(Args&&... args) + { + value_type && val = value_type(boost::forward<Args>(args)...); + insert_commit_data data; + std::pair<iterator,bool> ret = + priv_insert_unique_prepare(val, data); + if(ret.second){ + ret.first = priv_insert_commit(data, boost::move(val)); + } + return ret; + } + + template <class... Args> + iterator emplace_hint_unique(const_iterator hint, Args&&... args) + { + value_type && val = value_type(boost::forward<Args>(args)...); + insert_commit_data data; + std::pair<iterator,bool> ret = priv_insert_unique_prepare(hint, val, data); + if(ret.second){ + ret.first = priv_insert_commit(data, boost::move(val)); + } + return ret.first; + } + + template <class... Args> + iterator emplace_equal(Args&&... args) + { + value_type &&val = value_type(boost::forward<Args>(args)...); + iterator i = this->upper_bound(KeyOfValue()(val)); + i = this->m_data.m_vect.insert(i, boost::move(val)); + return i; + } + + template <class... Args> + iterator emplace_hint_equal(const_iterator hint, Args&&... args) + { + value_type &&val = value_type(boost::forward<Args>(args)...); + insert_commit_data data; + priv_insert_equal_prepare(hint, val, data); + return priv_insert_commit(data, boost::move(val)); + } + + #else //#ifdef 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, >) \ + 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; \ + insert_commit_data data; \ + std::pair<iterator,bool> ret = priv_insert_unique_prepare(val, data); \ + if(ret.second){ \ + ret.first = priv_insert_commit(data, boost::move(val)); \ + } \ + return ret; \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + 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; \ + insert_commit_data data; \ + std::pair<iterator,bool> ret = priv_insert_unique_prepare(hint, val, data); \ + if(ret.second){ \ + ret.first = priv_insert_commit(data, boost::move(val)); \ + } \ + return ret.first; \ + } \ + \ + 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; \ + iterator i = this->upper_bound(KeyOfValue()(val)); \ + i = this->m_data.m_vect.insert(i, boost::move(val)); \ + return i; \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + 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; \ + insert_commit_data data; \ + priv_insert_equal_prepare(hint, val, data); \ + return priv_insert_commit(data, boost::move(val)); \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + iterator erase(const_iterator position) + { return this->m_data.m_vect.erase(position); } + + size_type erase(const key_type& k) + { + std::pair<iterator,iterator > itp = this->equal_range(k); + size_type ret = static_cast<size_type>(itp.second-itp.first); + if (ret){ + this->m_data.m_vect.erase(itp.first, itp.second); + } + return ret; + } + + iterator erase(const_iterator first, const_iterator last) + { return this->m_data.m_vect.erase(first, last); } + + void clear() + { this->m_data.m_vect.clear(); } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + // with previous allocations. The size of the vector is unchanged + //! + //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { this->m_data.m_vect.shrink_to_fit(); } + + // set operations: + iterator find(const key_type& k) + { + 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(); + } + return i; + } + + const_iterator find(const key_type& k) const + { + 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(); + } + return i; + } + + size_type count(const key_type& k) const + { + std::pair<const_iterator, const_iterator> p = this->equal_range(k); + size_type n = p.second - p.first; + return n; + } + + iterator lower_bound(const key_type& k) + { return this->priv_lower_bound(this->begin(), this->end(), k); } + + const_iterator lower_bound(const key_type& k) const + { return this->priv_lower_bound(this->begin(), this->end(), k); } + + iterator upper_bound(const key_type& k) + { return this->priv_upper_bound(this->begin(), this->end(), k); } + + const_iterator upper_bound(const key_type& k) const + { return this->priv_upper_bound(this->begin(), this->end(), k); } + + std::pair<iterator,iterator> equal_range(const key_type& k) + { return this->priv_equal_range(this->begin(), this->end(), k); } + + 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 + { return this->m_data.m_vect.capacity(); } + + void reserve(size_type count) + { this->m_data.m_vect.reserve(count); } + + private: + struct insert_commit_data + { + const_iterator position; + }; + + // insert/erase + void priv_insert_equal_prepare + (const_iterator pos, const value_type& val, insert_commit_data &data) + { + // N1780 + // To insert val at pos: + // if pos == end || val <= *pos + // if pos == begin || val >= *(pos-1) + // insert val before pos + // else + // insert val before upper_bound(val) + // else + // insert val before lower_bound(val) + const value_compare &value_comp = this->m_data; + + if(pos == this->cend() || !value_comp(*pos, val)){ + if (pos == this->cbegin() || !value_comp(val, pos[-1])){ + data.position = pos; + } + else{ + data.position = + this->priv_upper_bound(this->cbegin(), pos, KeyOfValue()(val)); + } + } + else{ + data.position = + this->priv_lower_bound(pos, this->cend(), KeyOfValue()(val)); + } + } + + std::pair<iterator,bool> priv_insert_unique_prepare + (const_iterator beg, const_iterator end, const value_type& val, insert_commit_data &commit_data) + { + const value_compare &value_comp = this->m_data; + commit_data.position = this->priv_lower_bound(beg, end, KeyOfValue()(val)); + return std::pair<iterator,bool> + ( *reinterpret_cast<iterator*>(&commit_data.position) + , commit_data.position == end || value_comp(val, *commit_data.position)); + } + + std::pair<iterator,bool> priv_insert_unique_prepare + (const value_type& val, insert_commit_data &commit_data) + { return priv_insert_unique_prepare(this->begin(), this->end(), val, commit_data); } + + std::pair<iterator,bool> priv_insert_unique_prepare + (const_iterator pos, const value_type& val, insert_commit_data &commit_data) + { + //N1780. Props to Howard Hinnant! + //To insert val at pos: + //if pos == end || val <= *pos + // if pos == begin || val >= *(pos-1) + // insert val before pos + // else + // insert val before upper_bound(val) + //else if pos+1 == end || val <= *(pos+1) + // insert val after pos + //else + // insert val before lower_bound(val) + const value_compare &value_comp = this->m_data; + + if(pos == this->cend() || value_comp(val, *pos)){ + if(pos != this->cbegin() && !value_comp(val, pos[-1])){ + if(value_comp(pos[-1], val)){ + commit_data.position = pos; + return std::pair<iterator,bool>(*reinterpret_cast<iterator*>(&pos), true); + } + else{ + return std::pair<iterator,bool>(*reinterpret_cast<iterator*>(&pos), false); + } + } + return this->priv_insert_unique_prepare(this->cbegin(), pos, val, commit_data); + } + + // Works, but increases code complexity + //Next check + //else if (value_comp(*pos, val) && !value_comp(pos[1], val)){ + // if(value_comp(val, pos[1])){ + // commit_data.position = pos+1; + // return std::pair<iterator,bool>(pos+1, true); + // } + // else{ + // return std::pair<iterator,bool>(pos+1, false); + // } + //} + else{ + //[... pos ... val ... ] + //The hint is before the insertion position, so insert it + //in the remaining range + return this->priv_insert_unique_prepare(pos, this->end(), val, commit_data); + } + } + + template<class Convertible> + iterator priv_insert_commit + (insert_commit_data &commit_data, BOOST_FWD_REF(Convertible) convertible) + { + return this->m_data.m_vect.insert + ( commit_data.position + , boost::forward<Convertible>(convertible)); + } + + template <class RanIt> + RanIt priv_lower_bound(RanIt first, RanIt last, + const key_type & key) const + { + const Compare &key_comp = this->m_data.get_comp(); + KeyOfValue key_extract; + difference_type len = last - first, half; + RanIt middle; + + while (len > 0) { + half = len >> 1; + middle = first; + middle += half; + + if (key_comp(key_extract(*middle), key)) { + ++middle; + first = middle; + len = len - half - 1; + } + else + len = half; + } + return first; + } + + template <class RanIt> + RanIt priv_upper_bound(RanIt first, RanIt last, + const key_type & key) const + { + const Compare &key_comp = this->m_data.get_comp(); + KeyOfValue key_extract; + difference_type len = last - first, half; + RanIt middle; + + while (len > 0) { + half = len >> 1; + middle = first; + middle += half; + + if (key_comp(key, key_extract(*middle))) { + len = half; + } + else{ + first = ++middle; + len = len - half - 1; + } + } + return first; + } + + template <class RanIt> + std::pair<RanIt, RanIt> + priv_equal_range(RanIt first, RanIt last, const key_type& key) const + { + const Compare &key_comp = this->m_data.get_comp(); + KeyOfValue key_extract; + difference_type len = last - first, half; + RanIt middle, left, right; + + while (len > 0) { + half = len >> 1; + middle = first; + middle += half; + + if (key_comp(key_extract(*middle), key)){ + first = middle; + ++first; + len = len - half - 1; + } + else if (key_comp(key, key_extract(*middle))){ + len = half; + } + else { + left = this->priv_lower_bound(first, middle, key); + first += len; + right = this->priv_upper_bound(++middle, first, key); + return std::pair<RanIt, RanIt>(left, right); + } + } + return std::pair<RanIt, RanIt>(first, first); + } + + template <class FwdIt> + void priv_insert_equal(FwdIt first, FwdIt last, std::forward_iterator_tag) + { + 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) + { + for ( ; first != last; ++first) + this->insert_equal(*first); + } +}; + +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) +{ + return x.size() == y.size() && + std::equal(x.begin(), x.end(), y.begin()); +} + +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) +{ + return std::lexicographical_compare(x.begin(), x.end(), + y.begin(), y.end()); +} + +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) + { return !(x == y); } + +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) + { return y < x; } + +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) + { return !(y < x); } + +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) + { return !(x < y); } + + +template <class Key, class Value, class KeyOfValue, + class Compare, class A> +inline void +swap(flat_tree<Key,Value,KeyOfValue,Compare,A>& x, + flat_tree<Key,Value,KeyOfValue,Compare,A>& y) + { x.swap(y); } + +} //namespace container_detail { + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +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> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif // BOOST_CONTAINER_FLAT_TREE_HPP diff --git a/src/third_party/boost/boost/container/detail/function_detector.hpp b/src/third_party/boost/boost/container/detail/function_detector.hpp new file mode 100644 index 00000000000..c37c766844f --- /dev/null +++ b/src/third_party/boost/boost/container/detail/function_detector.hpp @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2009-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. +// +///////////////////////////////////////////////////////////////////////////// +// This code was modified from the code posted by Alexandre Courpron in his +// article "Interface Detection" in The Code Project: +// http://www.codeproject.com/KB/architecture/Detector.aspx +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2007 Alexandre Courpron +// +// Permission to use, copy, modify, redistribute and sell this software, +// provided that this copyright notice appears on all copies of the software. +/////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP +#define BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP + +#include <boost/container/detail/config_begin.hpp> + +namespace boost { +namespace container { +namespace function_detector { + + typedef char NotFoundType; + struct StaticFunctionType { NotFoundType x [2]; }; + struct NonStaticFunctionType { NotFoundType x [3]; }; + + enum + { NotFound = 0, + StaticFunction = sizeof( StaticFunctionType ) - sizeof( NotFoundType ), + NonStaticFunction = sizeof( NonStaticFunctionType ) - sizeof( NotFoundType ) + }; + +} //namespace boost { +} //namespace container { +} //namespace function_detector { + +#define BOOST_CONTAINER_CREATE_FUNCTION_DETECTOR(Identifier, InstantiationKey) \ + namespace boost { \ + namespace container { \ + namespace function_detector { \ + template < class T, \ + class NonStaticType, \ + class NonStaticConstType, \ + class StaticType > \ + class DetectMember_##InstantiationKey_##Identifier { \ + template < NonStaticType > \ + struct TestNonStaticNonConst ; \ + \ + template < NonStaticConstType > \ + struct TestNonStaticConst ; \ + \ + template < StaticType > \ + struct TestStatic ; \ + \ + template <class U > \ + static NonStaticFunctionType Test( TestNonStaticNonConst<&U::Identifier>*, int ); \ + \ + template <class U > \ + static NonStaticFunctionType Test( TestNonStaticConst<&U::Identifier>*, int ); \ + \ + template <class U> \ + static StaticFunctionType Test( TestStatic<&U::Identifier>*, int ); \ + \ + template <class U> \ + static NotFoundType Test( ... ); \ + public : \ + static const int check = NotFound + (sizeof(Test<T>(0, 0)) - sizeof(NotFoundType));\ + };\ +}}} //namespace boost::container::function_detector { + +#define BOOST_CONTAINER_DETECT_FUNCTION(Class, InstantiationKey, ReturnType, Identifier, Params) \ + ::boost::container::function_detector::DetectMember_##InstantiationKey_##Identifier< Class,\ + ReturnType (Class::*)Params,\ + ReturnType (Class::*)Params const,\ + ReturnType (*)Params \ + >::check + +#include <boost/container/detail/config_end.hpp> + +#endif //@ifndef BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP diff --git a/src/third_party/boost/boost/container/detail/iterators.hpp b/src/third_party/boost/boost/container/detail/iterators.hpp new file mode 100644 index 00000000000..899cbe43490 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/iterators.hpp @@ -0,0 +1,548 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2011. +// (C) Copyright Gennaro Prota 2003 - 2004. +// +// 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_DETAIL_ITERATORS_HPP +#define BOOST_CONTAINER_DETAIL_ITERATORS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> +#include <boost/move/move.hpp> +#include <boost/container/allocator/allocator_traits.hpp> + +#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#include <boost/container/detail/variadic_templates_tools.hpp> +#include <boost/container/detail/stored_ref.hpp> +#else +#include <boost/container/detail/preprocessor.hpp> +#endif + +#include <iterator> + +namespace boost { +namespace container { + +template <class T, class Difference = std::ptrdiff_t> +class constant_iterator + : public std::iterator + <std::random_access_iterator_tag, T, Difference, const T*, const T &> +{ + typedef constant_iterator<T, Difference> this_type; + + public: + explicit constant_iterator(const T &ref, Difference range_size) + : m_ptr(&ref), m_num(range_size){} + + //Constructors + constant_iterator() + : m_ptr(0), m_num(0){} + + constant_iterator& operator++() + { increment(); return *this; } + + constant_iterator operator++(int) + { + constant_iterator result (*this); + increment(); + return result; + } + + constant_iterator& operator--() + { decrement(); return *this; } + + constant_iterator operator--(int) + { + constant_iterator result (*this); + decrement(); + return result; + } + + friend bool operator== (const constant_iterator& i, const constant_iterator& i2) + { return i.equal(i2); } + + friend bool operator!= (const constant_iterator& i, const constant_iterator& i2) + { return !(i == i2); } + + friend bool operator< (const constant_iterator& i, const constant_iterator& i2) + { return i.less(i2); } + + friend bool operator> (const constant_iterator& i, const constant_iterator& i2) + { return i2 < i; } + + friend bool operator<= (const constant_iterator& i, const constant_iterator& i2) + { return !(i > i2); } + + friend bool operator>= (const constant_iterator& i, const constant_iterator& i2) + { return !(i < i2); } + + friend Difference operator- (const constant_iterator& i, const constant_iterator& i2) + { return i2.distance_to(i); } + + //Arithmetic + constant_iterator& operator+=(Difference off) + { this->advance(off); return *this; } + + constant_iterator operator+(Difference off) const + { + constant_iterator other(*this); + other.advance(off); + return other; + } + + friend constant_iterator operator+(Difference off, const constant_iterator& right) + { return right + off; } + + constant_iterator& operator-=(Difference off) + { this->advance(-off); return *this; } + + constant_iterator operator-(Difference off) const + { return *this + (-off); } + + const T& operator*() const + { return dereference(); } + + const T& operator[] (Difference n) const + { return dereference(); } + + const T* operator->() const + { return &(dereference()); } + + private: + const T * m_ptr; + Difference m_num; + + void increment() + { --m_num; } + + void decrement() + { ++m_num; } + + bool equal(const this_type &other) const + { return m_num == other.m_num; } + + bool less(const this_type &other) const + { return other.m_num < m_num; } + + const T & dereference() const + { return *m_ptr; } + + void advance(Difference n) + { m_num -= n; } + + Difference distance_to(const this_type &other)const + { return m_num - other.m_num; } +}; + +template <class T, class Difference = std::ptrdiff_t> +class default_construct_iterator + : public std::iterator + <std::random_access_iterator_tag, T, Difference, const T*, const T &> +{ + typedef default_construct_iterator<T, Difference> this_type; + + public: + explicit default_construct_iterator(Difference range_size) + : m_num(range_size){} + + //Constructors + default_construct_iterator() + : m_num(0){} + + default_construct_iterator& operator++() + { increment(); return *this; } + + default_construct_iterator operator++(int) + { + default_construct_iterator result (*this); + increment(); + return result; + } + + default_construct_iterator& operator--() + { decrement(); return *this; } + + default_construct_iterator operator--(int) + { + default_construct_iterator result (*this); + decrement(); + return result; + } + + friend bool operator== (const default_construct_iterator& i, const default_construct_iterator& i2) + { return i.equal(i2); } + + friend bool operator!= (const default_construct_iterator& i, const default_construct_iterator& i2) + { return !(i == i2); } + + friend bool operator< (const default_construct_iterator& i, const default_construct_iterator& i2) + { return i.less(i2); } + + friend bool operator> (const default_construct_iterator& i, const default_construct_iterator& i2) + { return i2 < i; } + + friend bool operator<= (const default_construct_iterator& i, const default_construct_iterator& i2) + { return !(i > i2); } + + friend bool operator>= (const default_construct_iterator& i, const default_construct_iterator& i2) + { return !(i < i2); } + + friend Difference operator- (const default_construct_iterator& i, const default_construct_iterator& i2) + { return i2.distance_to(i); } + + //Arithmetic + default_construct_iterator& operator+=(Difference off) + { this->advance(off); return *this; } + + default_construct_iterator operator+(Difference off) const + { + default_construct_iterator other(*this); + other.advance(off); + return other; + } + + friend default_construct_iterator operator+(Difference off, const default_construct_iterator& right) + { return right + off; } + + default_construct_iterator& operator-=(Difference off) + { this->advance(-off); return *this; } + + default_construct_iterator operator-(Difference off) const + { return *this + (-off); } + + const T& operator*() const + { return dereference(); } + + const T* operator->() const + { return &(dereference()); } + + const T& operator[] (Difference n) const + { return dereference(); } + + private: + Difference m_num; + + void increment() + { --m_num; } + + void decrement() + { ++m_num; } + + bool equal(const this_type &other) const + { return m_num == other.m_num; } + + bool less(const this_type &other) const + { return other.m_num < m_num; } + + const T & dereference() const + { + static T dummy; + return dummy; + } + + void advance(Difference n) + { m_num -= n; } + + Difference distance_to(const this_type &other)const + { return m_num - other.m_num; } +}; + +template <class T, class Difference = std::ptrdiff_t> +class repeat_iterator + : public std::iterator + <std::random_access_iterator_tag, T, Difference> +{ + typedef repeat_iterator<T, Difference> this_type; + public: + explicit repeat_iterator(T &ref, Difference range_size) + : m_ptr(&ref), m_num(range_size){} + + //Constructors + repeat_iterator() + : m_ptr(0), m_num(0){} + + this_type& operator++() + { increment(); return *this; } + + this_type operator++(int) + { + this_type result (*this); + increment(); + return result; + } + + this_type& operator--() + { increment(); return *this; } + + this_type operator--(int) + { + this_type result (*this); + increment(); + return result; + } + + friend bool operator== (const this_type& i, const this_type& i2) + { return i.equal(i2); } + + friend bool operator!= (const this_type& i, const this_type& i2) + { return !(i == i2); } + + friend bool operator< (const this_type& i, const this_type& i2) + { return i.less(i2); } + + friend bool operator> (const this_type& i, const this_type& i2) + { return i2 < i; } + + friend bool operator<= (const this_type& i, const this_type& i2) + { return !(i > i2); } + + friend bool operator>= (const this_type& i, const this_type& i2) + { return !(i < i2); } + + friend Difference operator- (const this_type& i, const this_type& i2) + { return i2.distance_to(i); } + + //Arithmetic + this_type& operator+=(Difference off) + { this->advance(off); return *this; } + + this_type operator+(Difference off) const + { + this_type other(*this); + other.advance(off); + return other; + } + + friend this_type operator+(Difference off, const this_type& right) + { return right + off; } + + this_type& operator-=(Difference off) + { this->advance(-off); return *this; } + + this_type operator-(Difference off) const + { return *this + (-off); } + + T& operator*() const + { return dereference(); } + + T& operator[] (Difference n) const + { return dereference(); } + + T *operator->() const + { return &(dereference()); } + + private: + T * m_ptr; + Difference m_num; + + void increment() + { --m_num; } + + void decrement() + { ++m_num; } + + bool equal(const this_type &other) const + { return m_num == other.m_num; } + + bool less(const this_type &other) const + { return other.m_num < m_num; } + + T & dereference() const + { return *m_ptr; } + + void advance(Difference n) + { m_num -= n; } + + Difference distance_to(const this_type &other)const + { return m_num - other.m_num; } +}; + +template <class T, class EmplaceFunctor, class Difference /*= std::ptrdiff_t*/> +class emplace_iterator + : public std::iterator + <std::random_access_iterator_tag, T, Difference, const T*, const T &> +{ + typedef emplace_iterator this_type; + + public: + typedef Difference difference_type; + explicit emplace_iterator(EmplaceFunctor&e) + : m_num(1), m_pe(&e){} + + emplace_iterator() + : m_num(0), m_pe(0){} + + this_type& operator++() + { increment(); return *this; } + + this_type operator++(int) + { + this_type result (*this); + increment(); + return result; + } + + this_type& operator--() + { decrement(); return *this; } + + this_type operator--(int) + { + this_type result (*this); + decrement(); + return result; + } + + friend bool operator== (const this_type& i, const this_type& i2) + { return i.equal(i2); } + + friend bool operator!= (const this_type& i, const this_type& i2) + { return !(i == i2); } + + friend bool operator< (const this_type& i, const this_type& i2) + { return i.less(i2); } + + friend bool operator> (const this_type& i, const this_type& i2) + { return i2 < i; } + + friend bool operator<= (const this_type& i, const this_type& i2) + { return !(i > i2); } + + friend bool operator>= (const this_type& i, const this_type& i2) + { return !(i < i2); } + + friend difference_type operator- (const this_type& i, const this_type& i2) + { return i2.distance_to(i); } + + //Arithmetic + this_type& operator+=(difference_type off) + { this->advance(off); return *this; } + + this_type operator+(difference_type off) const + { + this_type other(*this); + other.advance(off); + return other; + } + + friend this_type operator+(difference_type off, const this_type& right) + { return right + off; } + + this_type& operator-=(difference_type off) + { this->advance(-off); return *this; } + + this_type operator-(difference_type off) const + { return *this + (-off); } + + const T& operator*() const + { return dereference(); } + + const T& operator[](difference_type) const + { return dereference(); } + + const T* operator->() const + { return &(dereference()); } + + template<class A> + void construct_in_place(A &a, T* ptr) + { (*m_pe)(a, ptr); } + + private: + difference_type m_num; + EmplaceFunctor * m_pe; + + void increment() + { --m_num; } + + void decrement() + { ++m_num; } + + bool equal(const this_type &other) const + { return m_num == other.m_num; } + + bool less(const this_type &other) const + { return other.m_num < m_num; } + + const T & dereference() const + { + static T dummy; + return dummy; + } + + void advance(difference_type n) + { m_num -= n; } + + difference_type distance_to(const this_type &other)const + { return difference_type(m_num - other.m_num); } +}; + +#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + +template<class ...Args> +struct emplace_functor +{ + typedef typename container_detail::build_number_seq<sizeof...(Args)>::type index_tuple_t; + + emplace_functor(Args&&... args) + : args_(args...) + {} + + template<class A, class T> + void operator()(A &a, T *ptr) + { emplace_functor::inplace_impl(a, ptr, index_tuple_t()); } + + template<class A, class T, int ...IdxPack> + void inplace_impl(A &a, T* ptr, const container_detail::index_tuple<IdxPack...>&) + { + allocator_traits<A>::construct + (a, ptr, container_detail::stored_ref<Args>::forward + (container_detail::get<IdxPack>(args_))...); + } + + container_detail::tuple<Args&...> args_; +}; + +#else + +#define BOOST_PP_LOCAL_MACRO(n) \ + BOOST_PP_EXPR_IF(n, template <) \ + BOOST_PP_ENUM_PARAMS(n, class P) \ + BOOST_PP_EXPR_IF(n, >) \ + 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, _){} \ + \ + 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, _) );\ + } \ + BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \ + }; \ + //! +#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) +#include BOOST_PP_LOCAL_ITERATE() + +#endif + +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP + diff --git a/src/third_party/boost/boost/container/detail/math_functions.hpp b/src/third_party/boost/boost/container/detail/math_functions.hpp new file mode 100644 index 00000000000..4613573d48b --- /dev/null +++ b/src/third_party/boost/boost/container/detail/math_functions.hpp @@ -0,0 +1,113 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Stephen Cleary 2000. +// (C) Copyright Ion Gaztanaga 2007-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. +// +// This file is a slightly modified file from Boost.Pool +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP +#define BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP + +#include "config_begin.hpp" +#include <climits> +#include <boost/static_assert.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +// Greatest common divisor and least common multiple + +// +// gcd is an algorithm that calculates the greatest common divisor of two +// integers, using Euclid's algorithm. +// +// Pre: A > 0 && B > 0 +// Recommended: A > B +template <typename Integer> +inline Integer gcd(Integer A, Integer B) +{ + do + { + const Integer tmp(B); + B = A % B; + A = tmp; + } while (B != 0); + + return A; +} + +// +// lcm is an algorithm that calculates the least common multiple of two +// integers. +// +// Pre: A > 0 && B > 0 +// Recommended: A > B +template <typename Integer> +inline Integer lcm(const Integer & A, const Integer & B) +{ + Integer ret = A; + ret /= gcd(A, B); + ret *= B; + return ret; +} + +template <typename Integer> +inline Integer log2_ceil(const Integer & A) +{ + Integer i = 0; + Integer power_of_2 = 1; + + while(power_of_2 < A){ + power_of_2 <<= 1; + ++i; + } + return i; +} + +template <typename Integer> +inline Integer upper_power_of_2(const Integer & A) +{ + Integer power_of_2 = 1; + + while(power_of_2 < A){ + power_of_2 <<= 1; + } + return power_of_2; +} + +//This function uses binary search to discover the +//highest set bit of the integer +inline std::size_t floor_log2 (std::size_t x) +{ + const std::size_t Bits = sizeof(std::size_t)*CHAR_BIT; + const bool Size_t_Bits_Power_2= !(Bits & (Bits-1)); + BOOST_STATIC_ASSERT(((Size_t_Bits_Power_2)== true)); + + 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) + log2 += shift, n = tmp; + } + + return log2; +} + +} // namespace container_detail +} // namespace container +} // namespace boost + +#include <boost/container/detail/config_end.hpp> + +#endif diff --git a/src/third_party/boost/boost/container/detail/mpl.hpp b/src/third_party/boost/boost/container/detail/mpl.hpp new file mode 100644 index 00000000000..c2d0ce41bbd --- /dev/null +++ b/src/third_party/boost/boost/container/detail/mpl.hpp @@ -0,0 +1,160 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_CONTAINER_DETAIL_MPL_HPP +#define BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include <cstddef> + +namespace boost { +namespace container { +namespace container_detail { + +template <class T, T val> +struct integral_constant +{ + static const T value = val; + typedef integral_constant<T,val> type; +}; + +template< bool C_ > +struct bool_ : integral_constant<bool, C_> +{ + static const bool value = C_; + operator bool() const { return bool_::value; } +}; + +typedef bool_<true> true_; +typedef bool_<false> false_; + +typedef true_ true_type; +typedef false_ false_type; + +typedef char yes_type; +struct no_type +{ + char padding[8]; +}; + +template <bool B, class T = void> +struct enable_if_c { + typedef T type; +}; + +template <class T> +struct enable_if_c<false, T> {}; + +template <class Cond, class T = void> +struct enable_if : public enable_if_c<Cond::value, T> {}; + +template <class Cond, class T = void> +struct disable_if : public enable_if_c<!Cond::value, T> {}; + +template <bool B, class T = void> +struct disable_if_c : public enable_if_c<!B, T> {}; + +template <class T, class U> +class is_convertible +{ + typedef char true_t; + class false_t { char dummy[2]; }; + static true_t dispatch(U); + static false_t dispatch(...); + static T trigger(); + public: + enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; +}; + +template< + bool C + , typename T1 + , typename T2 + > +struct if_c +{ + typedef T1 type; +}; + +template< + typename T1 + , typename T2 + > +struct if_c<false,T1,T2> +{ + typedef T2 type; +}; + +template< + typename T1 + , typename T2 + , typename T3 + > +struct if_ +{ + typedef typename if_c<0 != T1::value, T2, T3>::type type; +}; + + +template <class Pair> +struct select1st +// : public std::unary_function<Pair, typename Pair::first_type> +{ + template<class OtherPair> + 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 + { return x; } +}; + +// identity is an extension: it is not part of the standard. +template <class T> +struct identity +// : public std::unary_function<T,T> +{ + typedef T type; + const T& operator()(const T& x) const + { return x; } +}; + +template<std::size_t S> +struct ls_zeros +{ + static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value); +}; + +template<> +struct ls_zeros<0> +{ + static const std::size_t value = 0; +}; + +template<> +struct ls_zeros<1> +{ + static const std::size_t value = 0; +}; + +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 boost { + +#endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP + diff --git a/src/third_party/boost/boost/container/detail/multiallocation_chain.hpp b/src/third_party/boost/boost/container/detail/multiallocation_chain.hpp new file mode 100644 index 00000000000..a67fd770bd2 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/multiallocation_chain.hpp @@ -0,0 +1,254 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_MULTIALLOCATION_CHAIN_HPP +#define BOOST_CONTAINER_DETAIL_MULTIALLOCATION_CHAIN_HPP + +#include "config_begin.hpp" +#include <boost/container/container_fwd.hpp> +#include <boost/container/detail/utilities.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/transform_iterator.hpp> +#include <boost/intrusive/slist.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/type_traits/make_unsigned.hpp> +#include <boost/move/move.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +template<class VoidPointer> +class basic_multiallocation_chain +{ + private: + typedef bi::slist_base_hook<bi::void_pointer<VoidPointer> + ,bi::link_mode<bi::normal_link> + > node; + + typedef typename boost::intrusive::pointer_traits + <VoidPointer>::template rebind_pointer<char>::type char_ptr; + typedef typename boost::intrusive:: + pointer_traits<char_ptr>::difference_type difference_type; + + typedef bi::slist< node + , bi::linear<true> + , bi::cache_last<true> + , bi::size_type<typename boost::make_unsigned<difference_type>::type> + > slist_impl_t; + slist_impl_t slist_impl_; + + static node & to_node(VoidPointer p) + { return *static_cast<node*>(static_cast<void*>(container_detail::to_raw_pointer(p))); } + + BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain) + + public: + + + typedef VoidPointer void_pointer; + typedef typename slist_impl_t::iterator iterator; + typedef typename slist_impl_t::size_type size_type; + + basic_multiallocation_chain() + : slist_impl_() + {} + + basic_multiallocation_chain(BOOST_RV_REF(basic_multiallocation_chain) other) + : slist_impl_() + { slist_impl_.swap(other.slist_impl_); } + + basic_multiallocation_chain& operator=(BOOST_RV_REF(basic_multiallocation_chain) other) + { + basic_multiallocation_chain tmp(boost::move(other)); + this->swap(tmp); + return *this; + } + + bool empty() const + { return slist_impl_.empty(); } + + size_type size() const + { return slist_impl_.size(); } + + iterator before_begin() + { return slist_impl_.before_begin(); } + + iterator begin() + { return slist_impl_.begin(); } + + iterator end() + { return slist_impl_.end(); } + + iterator last() + { return slist_impl_.last(); } + + void clear() + { slist_impl_.clear(); } + + iterator insert_after(iterator it, void_pointer m) + { return slist_impl_.insert_after(it, to_node(m)); } + + void push_front(void_pointer m) + { return slist_impl_.push_front(to_node(m)); } + + void push_back(void_pointer m) + { return slist_impl_.push_back(to_node(m)); } + + void pop_front() + { return slist_impl_.pop_front(); } + + void *front() + { return &*slist_impl_.begin(); } + + void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin, iterator before_end) + { slist_impl_.splice_after(after_this, x.slist_impl_, before_begin, before_end); } + + void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin, iterator before_end, size_type n) + { slist_impl_.splice_after(after_this, x.slist_impl_, before_begin, before_end, n); } + + void splice_after(iterator after_this, basic_multiallocation_chain &x) + { slist_impl_.splice_after(after_this, x.slist_impl_); } + + void incorporate_after(iterator after_this, void_pointer begin , iterator before_end) + { slist_impl_.incorporate_after(after_this, &to_node(begin), &to_node(before_end)); } + + void incorporate_after(iterator after_this, void_pointer begin, void_pointer before_end, size_type n) + { slist_impl_.incorporate_after(after_this, &to_node(begin), &to_node(before_end), n); } + + void swap(basic_multiallocation_chain &x) + { slist_impl_.swap(x.slist_impl_); } + + static iterator iterator_to(void_pointer p) + { return slist_impl_t::s_iterator_to(to_node(p)); } + + std::pair<void_pointer, void_pointer> extract_data() + { + std::pair<void_pointer, void_pointer> ret + (slist_impl_.begin().operator->() + ,slist_impl_.last().operator->()); + slist_impl_.clear(); + return ret; + } +}; + +template<class T> +struct cast_functor +{ + typedef typename container_detail::add_reference<T>::type result_type; + template<class U> + result_type operator()(U &ptr) const + { return *static_cast<T*>(static_cast<void*>(&ptr)); } +}; + +template<class MultiallocationChain, class T> +class transform_multiallocation_chain +{ + private: + BOOST_MOVABLE_BUT_NOT_COPYABLE(transform_multiallocation_chain) + + MultiallocationChain holder_; + typedef typename MultiallocationChain::void_pointer void_pointer; + typedef typename boost::intrusive::pointer_traits + <void_pointer>::template rebind_pointer<T>::type pointer; + + static pointer cast(void_pointer p) + { + return pointer(static_cast<T*>(container_detail::to_raw_pointer(p))); + } + + public: + typedef transform_iterator + < typename MultiallocationChain::iterator + , container_detail::cast_functor <T> > iterator; + typedef typename MultiallocationChain::size_type size_type; + + transform_multiallocation_chain() + : holder_() + {} + + transform_multiallocation_chain(BOOST_RV_REF(transform_multiallocation_chain) other) + : holder_() + { this->swap(other); } + + transform_multiallocation_chain(BOOST_RV_REF(MultiallocationChain) other) + : holder_(boost::move(other)) + {} + + transform_multiallocation_chain& operator=(BOOST_RV_REF(transform_multiallocation_chain) other) + { + transform_multiallocation_chain tmp(boost::move(other)); + this->swap(tmp); + return *this; + } + + void push_front(pointer mem) + { holder_.push_front(mem); } + + void swap(transform_multiallocation_chain &other_chain) + { holder_.swap(other_chain.holder_); } + + void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_begin, iterator before_end, size_type n) + { holder_.splice_after(after_this.base(), x.holder_, before_begin.base(), before_end.base(), n); } + + void incorporate_after(iterator after_this, void_pointer begin, void_pointer before_end, size_type n) + { holder_.incorporate_after(after_this.base(), begin, before_end, n); } + + void pop_front() + { holder_.pop_front(); } + + pointer front() + { return cast(holder_.front()); } + + bool empty() const + { return holder_.empty(); } + + iterator before_begin() + { return iterator(holder_.before_begin()); } + + iterator begin() + { return iterator(holder_.begin()); } + + iterator end() + { return iterator(holder_.end()); } + + iterator last() + { return iterator(holder_.last()); } + + size_type size() const + { return holder_.size(); } + + void clear() + { holder_.clear(); } + + iterator insert_after(iterator it, pointer m) + { return iterator(holder_.insert_after(it.base(), m)); } + + static iterator iterator_to(pointer p) + { return iterator(MultiallocationChain::iterator_to(p)); } + + std::pair<void_pointer, void_pointer> extract_data() + { return holder_.extract_data(); } + + MultiallocationChain extract_multiallocation_chain() + { + return MultiallocationChain(boost::move(holder_)); + } +}; + +}}} + +// namespace container_detail { +// namespace container { +// namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //BOOST_CONTAINER_DETAIL_MULTIALLOCATION_CHAIN_HPP diff --git a/src/third_party/boost/boost/container/detail/node_alloc_holder.hpp b/src/third_party/boost/boost/container/detail/node_alloc_holder.hpp new file mode 100644 index 00000000000..9b0a0a524b0 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/node_alloc_holder.hpp @@ -0,0 +1,488 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_NODE_ALLOC_HPP_ +#define BOOST_CONTAINER_DETAIL_NODE_ALLOC_HPP_ + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> + +#include <utility> +#include <functional> + +#include <boost/move/move.hpp> +#include <boost/intrusive/options.hpp> + +#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/detail/mpl.hpp> +#include <boost/container/detail/destroyers.hpp> + +#ifndef BOOST_CONTAINER_PERFECT_FORWARDING +#include <boost/container/detail/preprocessor.hpp> +#endif + +#include <boost/container/detail/algorithms.hpp> + + +namespace boost { +namespace container { +namespace container_detail { + +//!A deleter for scoped_ptr that deallocates the memory +//!allocated for an object using a STL allocator. +template <class A> +struct scoped_deallocator +{ + typedef allocator_traits<A> allocator_traits_type; + typedef typename allocator_traits_type::pointer pointer; + typedef container_detail::integral_constant<unsigned, + boost::container::container_detail:: + version<A>::value> alloc_version; + typedef container_detail::integral_constant<unsigned, 1> allocator_v1; + typedef container_detail::integral_constant<unsigned, 2> allocator_v2; + + private: + void priv_deallocate(allocator_v1) + { m_alloc.deallocate(m_ptr, 1); } + + void priv_deallocate(allocator_v2) + { m_alloc.deallocate_one(m_ptr); } + + BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator) + + public: + + pointer m_ptr; + A& m_alloc; + + scoped_deallocator(pointer p, A& a) + : m_ptr(p), m_alloc(a) + {} + + ~scoped_deallocator() + { if (m_ptr)priv_deallocate(alloc_version()); } + + scoped_deallocator(BOOST_RV_REF(scoped_deallocator) o) + : m_ptr(o.m_ptr), m_alloc(o.m_alloc) + { o.release(); } + + pointer get() const + { return m_ptr; } + + void release() + { m_ptr = 0; } +}; + +template <class A> +class allocator_destroyer_and_chain_builder +{ + typedef allocator_traits<A> allocator_traits_type; + typedef typename allocator_traits_type::value_type value_type; + typedef typename A::multiallocation_chain multiallocation_chain; + + A & a_; + multiallocation_chain &c_; + + public: + allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c) + : a_(a), c_(c) + {} + + void operator()(const typename A::pointer &p) + { + allocator_traits<A>::destroy(a_, container_detail::to_raw_pointer(p)); + c_.push_front(p); + } +}; + +template <class A> +class allocator_multialloc_chain_node_deallocator +{ + typedef allocator_traits<A> allocator_traits_type; + typedef typename allocator_traits_type::value_type value_type; + typedef typename A::multiallocation_chain multiallocation_chain; + typedef allocator_destroyer_and_chain_builder<A> chain_builder; + + A & a_; + multiallocation_chain c_; + + public: + allocator_multialloc_chain_node_deallocator(A &a) + : a_(a), c_() + {} + + chain_builder get_chain_builder() + { return chain_builder(a_, c_); } + + ~allocator_multialloc_chain_node_deallocator() + { + if(!c_.empty()) + a_.deallocate_individual(boost::move(c_)); + } +}; + +template<class ValueCompare, class Node> +struct node_compare + : private ValueCompare +{ + typedef typename ValueCompare::key_type key_type; + typedef typename ValueCompare::value_type value_type; + typedef typename ValueCompare::key_of_value key_of_value; + + node_compare(const ValueCompare &pred) + : ValueCompare(pred) + {} + + ValueCompare &value_comp() + { return static_cast<ValueCompare &>(*this); } + + ValueCompare &value_comp() const + { return static_cast<const ValueCompare &>(*this); } + + bool operator()(const Node &a, const Node &b) const + { return ValueCompare::operator()(a.get_data(), b.get_data()); } +}; + +template<class A, class ICont, class Pred = container_detail::nat> +struct node_alloc_holder +{ + typedef allocator_traits<A> allocator_traits_type; + typedef node_alloc_holder<A, ICont> self_t; + typedef typename allocator_traits_type::value_type value_type; + typedef typename ICont::value_type Node; + typedef typename allocator_traits_type::template + portable_rebind_alloc<Node>::type NodeAlloc; + typedef allocator_traits<NodeAlloc> node_allocator_traits_type; + typedef A ValAlloc; + typedef typename node_allocator_traits_type::pointer NodePtr; + typedef container_detail::scoped_deallocator<NodeAlloc> Deallocator; + typedef typename node_allocator_traits_type::size_type size_type; + typedef typename node_allocator_traits_type::difference_type difference_type; + typedef container_detail::integral_constant<unsigned, 1> allocator_v1; + typedef container_detail::integral_constant<unsigned, 2> allocator_v2; + typedef container_detail::integral_constant<unsigned, + boost::container::container_detail:: + version<NodeAlloc>::value> alloc_version; + typedef typename ICont::iterator icont_iterator; + typedef typename ICont::const_iterator icont_citerator; + typedef allocator_destroyer<NodeAlloc> Destroyer; + typedef allocator_traits<NodeAlloc> NodeAllocTraits; + + private: + BOOST_COPYABLE_AND_MOVABLE(node_alloc_holder) + + public: + + //Constructors for sequence containers + node_alloc_holder() + : members_() + {} + + explicit node_alloc_holder(const ValAlloc &a) + : members_(a) + {} + + explicit node_alloc_holder(const node_alloc_holder &x) + : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc())) + {} + + explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x) + : members_(boost::move(x.node_alloc())) + { this->icont().swap(x.icont()); } + + //Constructors for associative containers + explicit node_alloc_holder(const ValAlloc &a, const Pred &c) + : members_(a, c) + {} + + explicit node_alloc_holder(const node_alloc_holder &x, const Pred &c) + : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc()), c) + {} + + explicit node_alloc_holder(const Pred &c) + : members_(c) + {} + + //helpers for move assignments + explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x, const Pred &c) + : members_(boost::move(x.node_alloc()), c) + { 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); + } + + void move_assign_alloc( node_alloc_holder &x) + { + container_detail::bool_<allocator_traits_type::propagate_on_container_move_assignment::value> flag; + container_detail::move_alloc( static_cast<NodeAlloc &>(this->members_) + , static_cast<NodeAlloc &>(x.members_), flag); + } + + ~node_alloc_holder() + { this->clear(alloc_version()); } + + size_type max_size() const + { return allocator_traits_type::max_size(this->node_alloc()); } + + NodePtr allocate_one() + { return this->allocate_one(alloc_version()); } + + NodePtr allocate_one(allocator_v1) + { return this->node_alloc().allocate(1); } + + NodePtr allocate_one(allocator_v2) + { return this->node_alloc().allocate_one(); } + + void deallocate_one(const NodePtr &p) + { return this->deallocate_one(p, alloc_version()); } + + void deallocate_one(const NodePtr &p, allocator_v1) + { this->node_alloc().deallocate(p, 1); } + + 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)...); + node_deallocator.release(); + return (p); + } + + #else //#ifdef 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, >) \ + NodePtr create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + 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_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + node_deallocator.release(); \ + return (p); \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + template<class It> + NodePtr create_node_from_it(const It &it) + { + 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); + node_deallocator.release(); + return (p); + } + + void destroy_node(const NodePtr &nodep) + { + allocator_traits<NodeAlloc>::destroy(this->node_alloc(), container_detail::to_raw_pointer(nodep)); + this->deallocate_one(nodep); + } + + void swap(node_alloc_holder &x) + { + this->icont().swap(x.icont()); + container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag; + container_detail::swap_alloc(this->node_alloc(), x.node_alloc(), flag); + } + + template<class FwdIterator, class Inserter> + FwdIterator allocate_many_and_construct + (FwdIterator beg, difference_type n, Inserter inserter) + { + if(n){ + typedef typename NodeAlloc::multiallocation_chain multiallocation_chain; + + //Try to allocate memory in a single block + multiallocation_chain mem(this->node_alloc().allocate_individual(n)); + int constructed = 0; + Node *p = 0; + BOOST_TRY{ + for(difference_type i = 0; i < n; ++i, ++beg, --constructed){ + p = container_detail::to_raw_pointer(mem.front()); + mem.pop_front(); + //This can throw + constructed = 0; + boost::container::construct_in_place(this->node_alloc(), p, beg); + ++constructed; + //This can throw in some containers (predicate might throw) + inserter(*p); + } + } + BOOST_CATCH(...){ + if(constructed){ + allocator_traits<NodeAlloc>::destroy(this->node_alloc(), container_detail::to_raw_pointer(p)); + } + this->node_alloc().deallocate_individual(boost::move(mem)); + BOOST_RETHROW + } + BOOST_CATCH_END + } + return beg; + } + + void clear(allocator_v1) + { this->icont().clear_and_dispose(Destroyer(this->node_alloc())); } + + void clear(allocator_v2) + { + typename NodeAlloc::multiallocation_chain chain; + allocator_destroyer_and_chain_builder<NodeAlloc> builder(this->node_alloc(), chain); + this->icont().clear_and_dispose(builder); + //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled<typename NodeAlloc::multiallocation_chain>::value == true)); + if(!chain.empty()) + this->node_alloc().deallocate_individual(boost::move(chain)); + } + + icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v1) + { return this->icont().erase_and_dispose(first, last, Destroyer(this->node_alloc())); } + + icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v2) + { + allocator_multialloc_chain_node_deallocator<NodeAlloc> chain_holder(this->node_alloc()); + return this->icont().erase_and_dispose(first, last, chain_holder.get_chain_builder()); + } + + template<class Key, class Comparator> + size_type erase_key(const Key& k, const Comparator &comp, allocator_v1) + { return this->icont().erase_and_dispose(k, comp, Destroyer(this->node_alloc())); } + + template<class Key, class Comparator> + size_type erase_key(const Key& k, const Comparator &comp, allocator_v2) + { + allocator_multialloc_chain_node_deallocator<NodeAlloc> chain_holder(this->node_alloc()); + return this->icont().erase_and_dispose(k, comp, chain_holder.get_chain_builder()); + } + + protected: + struct cloner + { + cloner(node_alloc_holder &holder) + : m_holder(holder) + {} + + NodePtr operator()(const Node &other) const + { return m_holder.create_node(other.get_data()); } + + node_alloc_holder &m_holder; + }; + + struct members_holder + : public NodeAlloc + { + private: + members_holder(const members_holder&); + members_holder & operator=(const members_holder&); + + public: + members_holder() + : NodeAlloc(), m_icont() + {} + + template<class ConvertibleToAlloc> + explicit members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc) + : NodeAlloc(boost::forward<ConvertibleToAlloc>(c2alloc)) + , m_icont() + {} + + template<class ConvertibleToAlloc> + members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc, const Pred &c) + : NodeAlloc(boost::forward<ConvertibleToAlloc>(c2alloc)) + , m_icont(typename ICont::value_compare(c)) + {} + + explicit members_holder(const Pred &c) + : NodeAlloc() + , m_icont(typename ICont::value_compare(c)) + {} + + //The intrusive container + ICont m_icont; + }; + + ICont &non_const_icont() const + { return const_cast<ICont&>(this->members_.m_icont); } + + ICont &icont() + { return this->members_.m_icont; } + + const ICont &icont() const + { return this->members_.m_icont; } + + NodeAlloc &node_alloc() + { return static_cast<NodeAlloc &>(this->members_); } + + const NodeAlloc &node_alloc() const + { return static_cast<const NodeAlloc &>(this->members_); } + + members_holder members_; +}; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif // BOOST_CONTAINER_DETAIL_NODE_ALLOC_HPP_ diff --git a/src/third_party/boost/boost/container/detail/node_pool_impl.hpp b/src/third_party/boost/boost/container/detail/node_pool_impl.hpp new file mode 100644 index 00000000000..9ee9e311c01 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/node_pool_impl.hpp @@ -0,0 +1,367 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_NODE_POOL_IMPL_HPP +#define BOOST_CONTAINER_DETAIL_NODE_POOL_IMPL_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/container_fwd.hpp> +#include <boost/container/detail/workaround.hpp> +#include <boost/container/detail/utilities.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/set.hpp> +#include <boost/intrusive/slist.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/math_functions.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/pool_common.hpp> +#include <boost/assert.hpp> +#include <cstddef> +#include <functional> //std::unary_function + +namespace boost { +namespace container { +namespace container_detail { + +template<class SegmentManagerBase> +class private_node_pool_impl +{ + //Non-copyable + private_node_pool_impl(); + private_node_pool_impl(const private_node_pool_impl &); + private_node_pool_impl &operator=(const private_node_pool_impl &); + + //A node object will hold node_t when it's not allocated + public: + typedef typename SegmentManagerBase::void_pointer void_pointer; + typedef typename node_slist<void_pointer>::slist_hook_t slist_hook_t; + typedef typename node_slist<void_pointer>::node_t node_t; + typedef typename node_slist<void_pointer>::node_slist_t free_nodes_t; + typedef typename SegmentManagerBase::multiallocation_chain multiallocation_chain; + typedef typename SegmentManagerBase::size_type size_type; + + private: + typedef typename bi::make_slist + < node_t, bi::base_hook<slist_hook_t> + , bi::linear<true> + , bi::constant_time_size<false> >::type blockslist_t; + public: + + //!Segment manager typedef + typedef SegmentManagerBase segment_manager_base_type; + + //!Constructor from a segment manager. Never throws + private_node_pool_impl(segment_manager_base_type *segment_mngr_base, size_type node_size, size_type nodes_per_block) + : m_nodes_per_block(nodes_per_block) + , m_real_node_size(lcm(node_size, size_type(alignment_of<node_t>::value))) + //General purpose allocator + , mp_segment_mngr_base(segment_mngr_base) + , m_blocklist() + , m_freelist() + //Debug node count + , m_allocated(0) + {} + + //!Destructor. Deallocates all allocated blocks. Never throws + ~private_node_pool_impl() + { this->purge_blocks(); } + + size_type get_real_num_node() const + { return m_nodes_per_block; } + + //!Returns the segment manager. Never throws + segment_manager_base_type* get_segment_manager_base()const + { return container_detail::to_raw_pointer(mp_segment_mngr_base); } + + 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. + multiallocation_chain allocate_nodes(const size_type n) + { + //Preallocate all needed blocks to fulfill the request + size_type cur_nodes = m_freelist.size(); + if(cur_nodes < n){ + priv_alloc_block(((n - cur_nodes) - 1)/m_nodes_per_block + 1); + } + + //We just iterate the needed nodes to get the last we'll erase + typedef typename free_nodes_t::iterator free_iterator; + free_iterator before_last_new_it = m_freelist.before_begin(); + for(size_type j = 0; j != n; ++j){ + ++before_last_new_it; + } + + //Cache the first node of the allocated range before erasing + free_iterator first_node(m_freelist.begin()); + free_iterator last_node (before_last_new_it); + + //Erase the range. Since we already have the distance, this is O(1) + m_freelist.erase_after( m_freelist.before_begin() + , ++free_iterator(before_last_new_it) + , n); + + //Now take the last erased node and just splice it in the end + //of the intrusive list that will be traversed by the multialloc iterator. + multiallocation_chain chain; + chain.incorporate_after(chain.before_begin(), &*first_node, &*last_node, n); + m_allocated += n; + return boost::move(chain); + } + + void deallocate_nodes(multiallocation_chain chain) + { + typedef typename multiallocation_chain::iterator iterator; + iterator it(chain.begin()), itend(chain.end()); + while(it != itend){ + void *pElem = &*it; + ++it; + priv_dealloc_node(pElem); + } + } + + //!Deallocates all the free blocks of memory. Never throws + void deallocate_free_blocks() + { + typedef typename free_nodes_t::iterator nodelist_iterator; + typename blockslist_t::iterator bit(m_blocklist.before_begin()), + it(m_blocklist.begin()), + itend(m_blocklist.end()); + free_nodes_t backup_list; + nodelist_iterator backup_list_last = backup_list.before_begin(); + + //Execute the algorithm and get an iterator to the last value + size_type blocksize = get_rounded_size + (m_real_node_size*m_nodes_per_block, (size_type) alignment_of<node_t>::value); + + while(it != itend){ + //Collect all the nodes from the block pointed by it + //and push them in the list + free_nodes_t free_nodes; + nodelist_iterator last_it = free_nodes.before_begin(); + const void *addr = get_block_from_hook(&*it, blocksize); + + m_freelist.remove_and_dispose_if + (is_between(addr, blocksize), push_in_list(free_nodes, last_it)); + + //If the number of nodes is equal to m_nodes_per_block + //this means that the block can be deallocated + if(free_nodes.size() == m_nodes_per_block){ + //Unlink the nodes + free_nodes.clear(); + it = m_blocklist.erase_after(bit); + mp_segment_mngr_base->deallocate((void*)addr); + } + //Otherwise, insert them in the backup list, since the + //next "remove_if" does not need to check them again. + else{ + //Assign the iterator to the last value if necessary + if(backup_list.empty() && !m_freelist.empty()){ + backup_list_last = last_it; + } + //Transfer nodes. This is constant time. + backup_list.splice_after + ( backup_list.before_begin() + , free_nodes + , free_nodes.before_begin() + , last_it + , free_nodes.size()); + bit = it; + ++it; + } + } + //We should have removed all the nodes from the free list + BOOST_ASSERT(m_freelist.empty()); + + //Now pass all the node to the free list again + m_freelist.splice_after + ( m_freelist.before_begin() + , backup_list + , backup_list.before_begin() + , backup_list_last + , backup_list.size()); + } + + size_type num_free_nodes() + { return m_freelist.size(); } + + //!Deallocates all used memory. Precondition: all nodes allocated from this pool should + //!already be deallocated. Otherwise, undefined behaviour. Never throws + void purge_blocks() + { + //check for memory leaks + BOOST_ASSERT(m_allocated==0); + size_type blocksize = get_rounded_size + (m_real_node_size*m_nodes_per_block, (size_type)alignment_of<node_t>::value); + typename blockslist_t::iterator + it(m_blocklist.begin()), itend(m_blocklist.end()), aux; + + //We iterate though the NodeBlock list to free the memory + while(!m_blocklist.empty()){ + void *addr = get_block_from_hook(&m_blocklist.front(), blocksize); + m_blocklist.pop_front(); + mp_segment_mngr_base->deallocate((void*)addr); + } + //Just clear free node list + m_freelist.clear(); + } + + void swap(private_node_pool_impl &other) + { + BOOST_ASSERT(m_nodes_per_block == other.m_nodes_per_block); + BOOST_ASSERT(m_real_node_size == other.m_real_node_size); + std::swap(mp_segment_mngr_base, other.mp_segment_mngr_base); + m_blocklist.swap(other.m_blocklist); + m_freelist.swap(other.m_freelist); + std::swap(m_allocated, other.m_allocated); + } + + private: + + struct push_in_list + { + 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); + if(slist_.size() == 1){ //Cache last element + ++last_it_ = slist_.begin(); + } + } + + private: + free_nodes_t &slist_; + typename free_nodes_t::iterator &last_it_; + }; + + struct is_between + : std::unary_function<typename free_nodes_t::value_type, bool> + { + 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) && + end_ > reinterpret_cast<const char *>(&v)); + } + private: + const char * beg_; + const char * end_; + }; + + //!Allocates one node, using single segregated storage algorithm. + //!Never throws + node_t *priv_alloc_node() + { + //If there are no free nodes we allocate a new block + if (m_freelist.empty()) + priv_alloc_block(); + //We take the first free node + node_t *n = (node_t*)&m_freelist.front(); + m_freelist.pop_front(); + ++m_allocated; + return n; + } + + //!Deallocates one node, using single segregated storage algorithm. + //!Never throws + void priv_dealloc_node(void *pElem) + { + //We put the node at the beginning of the free node list + node_t * to_deallocate = static_cast<node_t*>(pElem); + m_freelist.push_front(*to_deallocate); + BOOST_ASSERT(m_allocated>0); + --m_allocated; + } + + //!Allocates several blocks of nodes. Can throw + void priv_alloc_block(size_type num_blocks = 1) + { + if(!num_blocks) + return; + size_type blocksize = + get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of<node_t>::value); + + try{ + for(size_type i = 0; i != num_blocks; ++i){ + //We allocate a new NodeBlock and put it as first + //element in the free Node list + char *pNode = reinterpret_cast<char*> + (mp_segment_mngr_base->allocate(blocksize + sizeof(node_t))); + char *pBlock = pNode; + m_blocklist.push_front(get_block_hook(pBlock, blocksize)); + + //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); + } + } + } + catch(...){ + //to-do: if possible, an efficient way to deallocate allocated blocks + throw; + } + } + + //!Deprecated, use deallocate_free_blocks + void deallocate_free_chunks() + { this->deallocate_free_blocks(); } + + //!Deprecated, use purge_blocks + void purge_chunks() + { this->purge_blocks(); } + + 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); + } + + //!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); + } + + private: + typedef typename boost::intrusive::pointer_traits + <void_pointer>::template rebind_pointer<segment_manager_base_type>::type segment_mngr_base_ptr_t; + + const size_type m_nodes_per_block; + const size_type m_real_node_size; + segment_mngr_base_ptr_t mp_segment_mngr_base; //Segment manager + blockslist_t m_blocklist; //Intrusive container of blocks + free_nodes_t m_freelist; //Intrusive container of free nods + size_type m_allocated; //Used nodes for debugging +}; + + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP diff --git a/src/third_party/boost/boost/container/detail/pair.hpp b/src/third_party/boost/boost/container/detail/pair.hpp new file mode 100644 index 00000000000..1aeff911374 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/pair.hpp @@ -0,0 +1,320 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_CONTAINER_DETAIL_PAIR_HPP +#define BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> + +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/type_traits.hpp> + +#include <utility> //std::pair + +#include <boost/move/move.hpp> +#include <boost/type_traits/is_class.hpp> + +#ifndef BOOST_CONTAINER_PERFECT_FORWARDING +#include <boost/container/detail/preprocessor.hpp> +#endif + +namespace boost { +namespace container { +namespace container_detail { + +template <class T1, class T2> +struct pair; + +template <class T> +struct is_pair +{ + static const bool value = false; +}; + +template <class T1, class T2> +struct is_pair< pair<T1, T2> > +{ + static const bool value = true; +}; + +template <class T1, class T2> +struct is_pair< std::pair<T1, T2> > +{ + static const bool value = true; +}; + +struct pair_nat; + +struct piecewise_construct_t { }; +static const piecewise_construct_t piecewise_construct = piecewise_construct_t(); + +template <class T1, class T2> +struct pair +{ + private: + BOOST_COPYABLE_AND_MOVABLE(pair) + + public: + typedef T1 first_type; + typedef T2 second_type; + + T1 first; + T2 second; + + //Default constructor + 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) + {} + + 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) + : 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)) + {} + + //std::pair copy constructor + pair(const std::pair<T1, T2>& x) + : first(x.first), second(x.second) + {} + + template <class D, class S> + pair(const std::pair<D, S>& p) + : 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) + : first(::boost::move(p.first)), second(::boost::move(p.second)) + {} + + pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p) + : first(::boost::move(p.first)), second(::boost::move(p.second)) + {} + + //piecewise_construct missing +/* + //Variadic versions + template<class U> + pair(BOOST_CONTAINER_PP_PARAM(U, u), typename container_detail::disable_if + < container_detail::is_pair< typename container_detail::remove_ref_const<U>::type >, pair_nat>::type* = 0) + : first(::boost::forward<U>(u)) + , second() + {} + + #ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + template<class U, class V, class ...Args> + pair(U &&u, V &&v) + : first(::boost::forward<U>(u)) + , second(::boost::forward<V>(v), ::boost::forward<Args>(args)...) + {} + + #else + + #define BOOST_PP_LOCAL_MACRO(n) \ + template<class U, BOOST_PP_ENUM_PARAMS(n, class P)> \ + pair(BOOST_CONTAINER_PP_PARAM(U, u) \ + ,BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + : first(::boost::forward<U>(u)) \ + , second(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 +*/ + //pair copy assignment + pair& operator=(BOOST_COPY_ASSIGN_REF(pair) p) + { + first = p.first; + second = p.second; + 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) + { + first = ::boost::move(p.first); + second = ::boost::move(p.second); + return *this; + } + + template <class D, class S> + pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p) + { + first = ::boost::move(p.first); + second = ::boost::move(p.second); + return *this; + } + + //std::pair copy assignment + pair& operator=(const std::pair<T1, T2> &p) + { + first = p.first; + second = p.second; + return *this; + } + + template <class D, class S> + pair& operator=(const std::pair<D, S> &p) + { + first = ::boost::move(p.first); + second = ::boost::move(p.second); + return *this; + } + + //std::pair move assignment + pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p) + { + first = ::boost::move(p.first); + second = ::boost::move(p.second); + return *this; + } + + template <class D, class S> + pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p) + { + first = ::boost::move(p.first); + second = ::boost::move(p.second); + return *this; + } + + //swap + void swap(pair& p) + { + using std::swap; + swap(this->first, p.first); + swap(this->second, p.second); + } +}; + +template <class T1, class T2> +inline bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y) +{ return static_cast<bool>(x.first == y.first && x.second == y.second); } + +template <class T1, class T2> +inline bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y) +{ return static_cast<bool>(x.first < y.first || + (!(y.first < x.first) && x.second < y.second)); } + +template <class T1, class T2> +inline bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y) +{ return static_cast<bool>(!(x == y)); } + +template <class T1, class T2> +inline bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y) +{ return y < x; } + +template <class T1, class T2> +inline bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y) +{ return static_cast<bool>(!(x < y)); } + +template <class T1, class T2> +inline bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y) +{ return static_cast<bool>(!(y < x)); } + +template <class T1, class T2> +inline pair<T1, T2> make_pair(T1 x, T2 y) +{ return pair<T1, T2>(x, y); } + +template <class T1, class T2> +inline void swap(pair<T1, T2>& x, pair<T1, T2>& y) +{ + swap(x.first, y.first); + swap(x.second, y.second); +} + +} //namespace container_detail { +} //namespace container { + + +//Without this specialization recursive flat_(multi)map instantiation fails +//because is_enum needs to instantiate the recursive pair, leading to a compilation error). +//This breaks the cycle clearly stating that pair is not an enum avoiding any instantiation. +template<class T> +struct is_enum; + +template<class T, class U> +struct is_enum< ::boost::container::container_detail::pair<T, U> > +{ + static const bool value = false; +}; + +//This specialization is needed to avoid instantiation of pair in +//is_class, and allow recursive maps. +template <class T1, class T2> +struct is_class< ::boost::container::container_detail::pair<T1, T2> > + : public ::boost::true_type +{}; + +#ifdef BOOST_NO_RVALUE_REFERENCES + +template<class T1, class T2> +struct has_move_emulation_enabled< ::boost::container::container_detail::pair<T1, T2> > + : ::boost::true_type +{}; + +#endif + + +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_PAIR_HPP diff --git a/src/third_party/boost/boost/container/detail/pool_common.hpp b/src/third_party/boost/boost/container/detail/pool_common.hpp new file mode 100644 index 00000000000..c66e2cd18cd --- /dev/null +++ b/src/third_party/boost/boost/container/detail/pool_common.hpp @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_NODE_POOL_COMMON_HPP +#define BOOST_CONTAINER_DETAIL_NODE_POOL_COMMON_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/intrusive/slist.hpp> +#include <new> + +namespace boost { +namespace container { +namespace container_detail { + +template<class VoidPointer> +struct node_slist +{ + //This hook will be used to chain the individual nodes + typedef typename bi::make_slist_base_hook + <bi::void_pointer<VoidPointer>, bi::link_mode<bi::normal_link> >::type slist_hook_t; + + //A node object will hold node_t when it's not allocated + typedef slist_hook_t node_t; + + typedef typename bi::make_slist + <node_t, bi::linear<true>, bi::base_hook<slist_hook_t> >::type node_slist_t; +}; + +template<class T> +struct is_stateless_segment_manager +{ + static const bool value = false; +}; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP diff --git a/src/third_party/boost/boost/container/detail/preprocessor.hpp b/src/third_party/boost/boost/container/detail/preprocessor.hpp new file mode 100644 index 00000000000..9916fbac62b --- /dev/null +++ b/src/third_party/boost/boost/container/detail/preprocessor.hpp @@ -0,0 +1,178 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-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_DETAIL_PREPROCESSOR_HPP +#define BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include <boost/container/detail/config_begin.hpp> + +#ifndef BOOST_NO_RVALUE_REFERENCES +#include <boost/container/detail/stored_ref.hpp> +#endif //#ifndef BOOST_NO_RVALUE_REFERENCES + +#include <boost/container/detail/workaround.hpp> + +#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +//#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/punctuation/paren_if.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/control/expr_if.hpp> +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/repetition/enum.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing.hpp> +#include <boost/preprocessor/repetition/enum_shifted_params.hpp> +#include <boost/preprocessor/repetition/enum_shifted.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/logical/not.hpp> +#include <boost/preprocessor/arithmetic/sub.hpp> +#include <boost/preprocessor/arithmetic/add.hpp> +#include <boost/preprocessor/iteration/iterate.hpp> + +#define BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS 10 + +//Note: +//We define template parameters as const references to +//be able to bind temporaries. After that we will un-const them. +//This cast is ugly but it is necessary until "perfect forwarding" +//is achieved in C++0x. Meanwhile, if we want to be able to +//bind rvalues with non-const references, we have to be ugly +#ifndef BOOST_NO_RVALUE_REFERENCES + #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \ + BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \ + //! +#else + #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \ + const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \ + //! +#endif //#ifndef BOOST_NO_RVALUE_REFERENCES + +#ifndef BOOST_NO_RVALUE_REFERENCES + #define BOOST_CONTAINER_PP_PARAM(U, u) \ + U && u \ + //! +#else + #define BOOST_CONTAINER_PP_PARAM(U, u) \ + const U & u \ + //! +#endif //#ifndef BOOST_NO_RVALUE_REFERENCES + +#ifndef BOOST_NO_RVALUE_REFERENCES + + #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + + #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) )) \ + //! + + #else //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + + #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) )) \ + //! + + #endif //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + +#else //BOOST_NO_RVALUE_REFERENCES + + #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \ + BOOST_PP_CAT(m_p, n) (const_cast<BOOST_PP_CAT(P, n) &>(BOOST_PP_CAT(p, n))) \ + //! +#endif //#ifndef BOOST_NO_RVALUE_REFERENCES + +#ifndef BOOST_NO_RVALUE_REFERENCES + + #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) + + #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \ + BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \ + //! + + #else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG + + #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \ + BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \ + //! + + #endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) + +#else //BOOST_NO_RVALUE_REFERENCES + + #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \ + BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \ + //! +#endif //#ifndef BOOST_NO_RVALUE_REFERENCES + +#if !defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) + + #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \ + ::boost::container::container_detail::stored_ref< BOOST_PP_CAT(P, n) >::forward( BOOST_PP_CAT(this->m_p, n) ) \ + //! + +#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) ) \ + //! + +#endif //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) + +#define BOOST_CONTAINER_PP_PARAM_INC(z, n, data) \ + BOOST_PP_CAT(++this->m_p, n) \ +//! + +#define BOOST_CONTAINER_PP_IDENTITY(z, n, data) data + + +#define BOOST_CONTAINER_PP_PARAM_FORWARD(z, n, data) \ +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) >() \ +//! + +#define BOOST_CONTAINER_PP_MEMBER_IT_FORWARD(z, n, data) \ +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 \ +//! + +#define BOOST_CONTAINER_PP_STATIC_PARAM_REF_DECLARE(z, n, data) \ + static BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n); \ +//! + +#define BOOST_CONTAINER_PP_PARAM_PASS(z, n, data) \ + BOOST_PP_CAT(p, n) \ +//! + +#define BOOST_CONTAINER_PP_FWD_TYPE(z, n, data) \ + typename ::boost::move_detail::forward_type< BOOST_PP_CAT(P, n) >::type \ +//! + +#include <boost/container/detail/config_end.hpp> + +//#else + +//#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +//#error "This file is not needed when perfect forwarding is available" +//#endif //BOOST_CONTAINER_PERFECT_FORWARDING + +#endif //#ifndef BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP diff --git a/src/third_party/boost/boost/container/detail/stored_ref.hpp b/src/third_party/boost/boost/container/detail/stored_ref.hpp new file mode 100644 index 00000000000..df0faa85a0c --- /dev/null +++ b/src/third_party/boost/boost/container/detail/stored_ref.hpp @@ -0,0 +1,92 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-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_DETAIL_STORED_REF_HPP +#define BOOST_CONTAINER_DETAIL_STORED_REF_HPP + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> + +#ifndef BOOST_NO_RVALUE_REFERENCES + +namespace boost{ +namespace container{ +namespace container_detail{ + +template<class T> +struct stored_ref +{ + + static T && forward(T &t) + #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + { return t; } + #else + { return boost::move(t); } + #endif +}; + +template<class T> +struct stored_ref<const T> +{ + static const T && forward(const T &t) + #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + { return t; } + #else + { return static_cast<const T&&>(t); } + #endif +}; + +template<class T> +struct stored_ref<T&&> +{ + static T && forward(T &t) + #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + { return t; } + #else + { return boost::move(t); } + #endif +}; + +template<class T> +struct stored_ref<const T&&> +{ + static const T && forward(const T &t) + #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + { return t; } + #else + { return static_cast<const T &&>(t); } + #endif +}; + +template<class T> +struct stored_ref<const T&> +{ + static const T & forward(const T &t) + { return t; } +}; + +template<class T> +struct stored_ref<T&> +{ + static T & forward(T &t) + { return t; } +}; + +} //namespace container_detail{ +} //namespace container{ +} //namespace boost{ + +#else +#error "This header can be included only for compiler with rvalue references" +#endif //BOOST_NO_RVALUE_REFERENCES + +#include <boost/container/detail/config_end.hpp> + +#endif //BOOST_CONTAINER_DETAIL_STORED_REF_HPP diff --git a/src/third_party/boost/boost/container/detail/transform_iterator.hpp b/src/third_party/boost/boost/container/detail/transform_iterator.hpp new file mode 100644 index 00000000000..17eca9ef619 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/transform_iterator.hpp @@ -0,0 +1,176 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2011. +// (C) Copyright Gennaro Prota 2003 - 2004. +// +// 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_DETAIL_TRANSFORM_ITERATORS_HPP +#define BOOST_CONTAINER_DETAIL_TRANSFORM_ITERATORS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <iterator> + +namespace boost { +namespace container { + +template <class PseudoReference> +struct operator_arrow_proxy +{ + operator_arrow_proxy(const PseudoReference &px) + : m_value(px) + {} + + PseudoReference* operator->() const { return &m_value; } + // This function is needed for MWCW and BCC, which won't call operator-> + // again automatically per 13.3.1.2 para 8 +// operator T*() const { return &m_value; } + mutable PseudoReference m_value; +}; + +template <class T> +struct operator_arrow_proxy<T&> +{ + operator_arrow_proxy(T &px) + : m_value(px) + {} + + T* operator->() const { return const_cast<T*>(&m_value); } + // This function is needed for MWCW and BCC, which won't call operator-> + // again automatically per 13.3.1.2 para 8 +// operator T*() const { return &m_value; } + T &m_value; +}; + +template <class Iterator, class UnaryFunction> +class transform_iterator + : public UnaryFunction + , public std::iterator + < typename Iterator::iterator_category + , typename container_detail::remove_reference<typename UnaryFunction::result_type>::type + , typename Iterator::difference_type + , operator_arrow_proxy<typename UnaryFunction::result_type> + , typename UnaryFunction::result_type> +{ + public: + explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction()) + : UnaryFunction(f), m_it(it) + {} + + explicit transform_iterator() + : UnaryFunction(), m_it() + {} + + //Constructors + transform_iterator& operator++() + { increment(); return *this; } + + transform_iterator operator++(int) + { + transform_iterator result (*this); + increment(); + return result; + } + + friend bool operator== (const transform_iterator& i, const transform_iterator& i2) + { return i.equal(i2); } + + friend bool operator!= (const transform_iterator& i, const transform_iterator& i2) + { return !(i == i2); } + +/* + friend bool operator> (const transform_iterator& i, const transform_iterator& i2) + { return i2 < i; } + + friend bool operator<= (const transform_iterator& i, const transform_iterator& i2) + { return !(i > i2); } + + friend bool operator>= (const transform_iterator& i, const transform_iterator& i2) + { return !(i < i2); } +*/ + friend typename Iterator::difference_type operator- (const transform_iterator& i, const transform_iterator& i2) + { return i2.distance_to(i); } + + //Arithmetic + transform_iterator& operator+=(typename Iterator::difference_type off) + { this->advance(off); return *this; } + + transform_iterator operator+(typename Iterator::difference_type off) const + { + transform_iterator other(*this); + other.advance(off); + return other; + } + + friend transform_iterator operator+(typename Iterator::difference_type off, const transform_iterator& right) + { return right + off; } + + transform_iterator& operator-=(typename Iterator::difference_type off) + { this->advance(-off); return *this; } + + transform_iterator operator-(typename Iterator::difference_type off) const + { return *this + (-off); } + + typename UnaryFunction::result_type operator*() const + { return dereference(); } + + operator_arrow_proxy<typename UnaryFunction::result_type> + operator->() const + { return operator_arrow_proxy<typename UnaryFunction::result_type>(dereference()); } + + Iterator & base() + { return m_it; } + + const Iterator & base() const + { return m_it; } + + private: + Iterator m_it; + + void increment() + { ++m_it; } + + void decrement() + { --m_it; } + + bool equal(const transform_iterator &other) const + { return m_it == other.m_it; } + + bool less(const transform_iterator &other) const + { return other.m_it < m_it; } + + typename UnaryFunction::result_type dereference() const + { return UnaryFunction::operator()(*m_it); } + + void advance(typename Iterator::difference_type n) + { std::advance(m_it, n); } + + typename Iterator::difference_type distance_to(const transform_iterator &other)const + { return std::distance(other.m_it, m_it); } +}; + +template <class Iterator, class UnaryFunc> +transform_iterator<Iterator, UnaryFunc> +make_transform_iterator(Iterator it, UnaryFunc fun) +{ + return transform_iterator<Iterator, UnaryFunc>(it, fun); +} + +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_TRANSFORM_ITERATORS_HPP diff --git a/src/third_party/boost/boost/container/detail/tree.hpp b/src/third_party/boost/boost/container/detail/tree.hpp new file mode 100644 index 00000000000..6cd91ed2a69 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/tree.hpp @@ -0,0 +1,1154 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_TREE_HPP +#define BOOST_CONTAINER_TREE_HPP + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> +#include <boost/container/container_fwd.hpp> + +#include <boost/move/move.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/detail/no_exceptions_support.hpp> +#include <boost/intrusive/rbtree.hpp> + +#include <boost/container/detail/utilities.hpp> +#include <boost/container/detail/algorithms.hpp> +#include <boost/container/detail/node_alloc_holder.hpp> +#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> +#ifndef BOOST_CONTAINER_PERFECT_FORWARDING +#include <boost/container/detail/preprocessor.hpp> +#endif + +#include <utility> //std::pair +#include <iterator> +#include <algorithm> + +namespace boost { +namespace container { +namespace container_detail { + +template<class Key, class Value, class KeyCompare, class KeyOfValue> +struct value_compare_impl + : public KeyCompare +{ + typedef Value value_type; + typedef KeyCompare key_compare; + typedef KeyOfValue key_of_value; + typedef Key key_type; + + value_compare_impl(const key_compare &kcomp) + : key_compare(kcomp) + {} + + const key_compare &key_comp() const + { return static_cast<const key_compare &>(*this); } + + key_compare &key_comp() + { return static_cast<key_compare &>(*this); } + + template<class T> + struct is_key + { + static const bool value = is_same<const T, const key_type>::value; + }; + + template<class T> + typename enable_if_c<is_key<T>::value, const key_type &>::type + key_forward(const T &key) const + { return key; } + + template<class T> + typename enable_if_c<!is_key<T>::value, const key_type &>::type + key_forward(const T &key) const + { return KeyOfValue()(key); } + + template<class KeyType, class KeyType2> + bool operator()(const KeyType &key1, const KeyType2 &key2) const + { return key_compare::operator()(this->key_forward(key1), this->key_forward(key2)); } +}; + +template<class VoidPointer> +struct rbtree_hook +{ + typedef typename container_detail::bi::make_set_base_hook + < container_detail::bi::void_pointer<VoidPointer> + , container_detail::bi::link_mode<container_detail::bi::normal_link> + , container_detail::bi::optimize_size<true> + >::type type; +}; + +template<class T> +struct rbtree_type +{ + typedef T type; +}; + +template<class T1, class T2> +struct rbtree_type< std::pair<T1, T2> > +{ + typedef pair<T1, T2> type; +}; + +template <class T, class VoidPointer> +struct rbtree_node + : public rbtree_hook<VoidPointer>::type +{ + private: + BOOST_COPYABLE_AND_MOVABLE(rbtree_node) + + public: + typedef typename rbtree_hook<VoidPointer>::type hook_type; + + typedef T value_type; + typedef typename rbtree_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); + return *ptr; + } + + const T &get_data() const + { + const T* ptr = reinterpret_cast<const T*>(&this->m_data); + return *ptr; + } + + private: + internal_type m_data; + + template<class A, class B> + void do_assign(const std::pair<const A, B> &p) + { + const_cast<A&>(m_data.first) = p.first; + m_data.second = p.second; + } + + template<class A, class B> + void do_assign(const pair<const A, B> &p) + { + const_cast<A&>(m_data.first) = p.first; + m_data.second = p.second; + } + + template<class V> + void do_assign(const V &v) + { m_data = v; } + + template<class A, class B> + void do_move(std::pair<const A, B> &p) + { + 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) + { + 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); } +}; + +}//namespace container_detail { + +namespace container_detail { + +template<class A, class ValueCompare> +struct intrusive_rbtree_type +{ + typedef typename boost::container:: + allocator_traits<A>::value_type value_type; + typedef typename boost::container:: + allocator_traits<A>::void_pointer void_pointer; + typedef typename boost::container:: + allocator_traits<A>::size_type size_type; + typedef typename container_detail::rbtree_node + <value_type, void_pointer> node_type; + typedef node_compare<ValueCompare, node_type> node_compare_type; + typedef typename container_detail::bi::make_rbtree + <node_type + ,container_detail::bi::compare<node_compare_type> + ,container_detail::bi::base_hook<typename rbtree_hook<void_pointer>::type> + ,container_detail::bi::constant_time_size<true> + ,container_detail::bi::size_type<size_type> + >::type container_type; + typedef container_type type ; +}; + +} //namespace container_detail { + +namespace container_detail { + +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> + >::type + , KeyCompare + > +{ + typedef typename container_detail::intrusive_rbtree_type + < A, value_compare_impl + <Key, Value, KeyCompare, KeyOfValue> + >::type Icont; + typedef container_detail::node_alloc_holder + <A, Icont, KeyCompare> AllocHolder; + typedef typename AllocHolder::NodePtr NodePtr; + typedef rbtree < Key, Value, KeyOfValue + , KeyCompare, A> ThisType; + typedef typename AllocHolder::NodeAlloc NodeAlloc; + typedef typename AllocHolder::ValAlloc ValAlloc; + typedef typename AllocHolder::Node Node; + typedef typename Icont::iterator iiterator; + typedef typename Icont::const_iterator iconst_iterator; + typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer; + typedef typename AllocHolder::allocator_v1 allocator_v1; + typedef typename AllocHolder::allocator_v2 allocator_v2; + typedef typename AllocHolder::alloc_version alloc_version; + + class RecyclingCloner; + friend class RecyclingCloner; + + class RecyclingCloner + { + public: + RecyclingCloner(AllocHolder &holder, Icont &irbtree) + : m_holder(holder), m_icont(irbtree) + {} + + NodePtr operator()(const Node &other) const + { + if(NodePtr p = m_icont.unlink_leftmost_without_rebalance()){ + //First recycle a node (this can't throw) + try{ + //This can throw + *p = other; + return p; + } + catch(...){ + //If there is an exception destroy the whole source + m_holder.destroy_node(p); + while((p = m_icont.unlink_leftmost_without_rebalance())){ + m_holder.destroy_node(p); + } + throw; + } + } + else{ + return m_holder.create_node(other); + } + } + + AllocHolder &m_holder; + Icont &m_icont; + }; + + class RecyclingMoveCloner; + friend class RecyclingMoveCloner; + + class RecyclingMoveCloner + { + public: + RecyclingMoveCloner(AllocHolder &holder, Icont &irbtree) + : m_holder(holder), m_icont(irbtree) + {} + + NodePtr operator()(const Node &other) const + { + if(NodePtr p = m_icont.unlink_leftmost_without_rebalance()){ + //First recycle a node (this can't throw) + try{ + //This can throw + *p = boost::move(other); + return p; + } + catch(...){ + //If there is an exception destroy the whole source + m_holder.destroy_node(p); + while((p = m_icont.unlink_leftmost_without_rebalance())){ + m_holder.destroy_node(p); + } + throw; + } + } + else{ + return m_holder.create_node(other); + } + } + + AllocHolder &m_holder; + Icont &m_icont; + }; + + BOOST_COPYABLE_AND_MOVABLE(rbtree) + + public: + + typedef Key key_type; + typedef Value value_type; + typedef A allocator_type; + typedef KeyCompare key_compare; + typedef value_compare_impl< Key, Value + , KeyCompare, KeyOfValue> value_compare; + typedef typename boost::container:: + allocator_traits<A>::pointer pointer; + typedef typename boost::container:: + allocator_traits<A>::const_pointer const_pointer; + typedef typename boost::container:: + allocator_traits<A>::reference reference; + typedef typename boost::container:: + allocator_traits<A>::const_reference const_reference; + typedef typename boost::container:: + allocator_traits<A>::size_type size_type; + typedef typename boost::container:: + allocator_traits<A>::difference_type difference_type; + typedef difference_type rbtree_difference_type; + typedef pointer rbtree_pointer; + typedef const_pointer rbtree_const_pointer; + typedef reference rbtree_reference; + typedef const_reference rbtree_const_reference; + typedef NodeAlloc stored_allocator_type; + + private: + + template<class KeyValueCompare> + struct key_node_compare + : private KeyValueCompare + { + key_node_compare(const KeyValueCompare &comp) + : KeyValueCompare(comp) + {} + + template<class T> + struct is_node + { + static const bool value = is_same<T, Node>::value; + }; + + template<class T> + typename enable_if_c<is_node<T>::value, const value_type &>::type + key_forward(const T &node) const + { return node.get_data(); } + + template<class T> + typename enable_if_c<!is_node<T>::value, const T &>::type + key_forward(const T &key) const + { return key; } + + template<class KeyType, class KeyType2> + bool operator()(const KeyType &key1, const KeyType2 &key2) const + { return KeyValueCompare::operator()(this->key_forward(key1), this->key_forward(key2)); } + }; + + typedef key_node_compare<value_compare> KeyNodeCompare; + + public: + //rbtree const_iterator + class const_iterator + : public std::iterator + < std::bidirectional_iterator_tag + , value_type , rbtree_difference_type + , rbtree_const_pointer , rbtree_const_reference> + { + protected: + typedef typename Icont::iterator iiterator; + iiterator m_it; + explicit const_iterator(iiterator it) : m_it(it){} + void prot_incr() { ++m_it; } + void prot_decr() { --m_it; } + + private: + iiterator get() + { return this->m_it; } + + public: + friend class rbtree <Key, Value, KeyOfValue, KeyCompare, A>; + typedef rbtree_difference_type difference_type; + + //Constructors + const_iterator() + : m_it() + {} + + //Pointer like operators + const_reference operator*() const + { return m_it->get_data(); } + + const_pointer operator->() const + { return const_pointer(&m_it->get_data()); } + + //Increment / Decrement + const_iterator& operator++() + { prot_incr(); return *this; } + + const_iterator operator++(int) + { iiterator tmp = m_it; ++*this; return const_iterator(tmp); } + + const_iterator& operator--() + { prot_decr(); return *this; } + + const_iterator operator--(int) + { iiterator tmp = m_it; --*this; return const_iterator(tmp); } + + //Comparison operators + bool operator== (const const_iterator& r) const + { return m_it == r.m_it; } + + bool operator!= (const const_iterator& r) const + { return m_it != r.m_it; } + }; + + //rbtree iterator + class iterator : public const_iterator + { + private: + explicit iterator(iiterator it) + : const_iterator(it) + {} + + iiterator get() + { return this->m_it; } + + public: + friend class rbtree <Key, Value, KeyOfValue, KeyCompare, A>; + typedef rbtree_pointer pointer; + typedef rbtree_reference reference; + + //Constructors + iterator(){} + + //Pointer like operators + reference operator*() const { return this->m_it->get_data(); } + pointer operator->() const { return pointer(&this->m_it->get_data()); } + + //Increment / Decrement + 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; } + + iterator operator--(int) + { iterator tmp = *this; --*this; return tmp; } + }; + + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + + rbtree() + : AllocHolder(key_compare()) + {} + + rbtree(const key_compare& comp, const allocator_type& a = allocator_type()) + : AllocHolder(a, comp) + {} + + template <class InputIterator> + rbtree(InputIterator first, InputIterator last, const key_compare& comp, + const allocator_type& a, bool unique_insertion) + : AllocHolder(a, comp) + { + typedef typename std::iterator_traits<InputIterator>::iterator_category ItCat; + priv_create_and_insert_nodes(first, last, unique_insertion, alloc_version(), ItCat()); + } + + template <class InputIterator> + rbtree( ordered_range_t, InputIterator first, InputIterator last + , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()) + : AllocHolder(a, comp) + { + typedef typename std::iterator_traits<InputIterator>::iterator_category ItCat; + priv_create_and_insert_ordered_nodes(first, last, alloc_version(), ItCat()); + } + + 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() + {} //AllocHolder clears the tree + + rbtree& operator=(BOOST_COPY_ASSIGN_REF(rbtree) x) + { + if (&x != this){ + NodeAlloc &this_alloc = this->get_stored_allocator(); + const NodeAlloc &x_alloc = x.get_stored_allocator(); + container_detail::bool_<allocator_traits<NodeAlloc>:: + propagate_on_container_copy_assignment::value> flag; + if(flag && this_alloc != x_alloc){ + this->clear(); + } + this->AllocHolder::copy_assign_alloc(x); + //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())); + + //Now recreate the source tree reusing nodes stored by other_tree + this->icont().clone_from + (x.icont() + , RecyclingCloner(*this, other_tree) + , Destroyer(this->node_alloc())); + + //If there are remaining nodes, destroy them + NodePtr p; + while((p = other_tree.unlink_leftmost_without_rebalance())){ + AllocHolder::destroy_node(p); + } + } + return *this; + } + + rbtree& operator=(BOOST_RV_REF(rbtree) x) + { + if (&x != this){ + NodeAlloc &this_alloc = this->node_alloc(); + NodeAlloc &x_alloc = x.node_alloc(); + //If allocators are equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy and swap pointers + this->clear(); + this->icont() = boost::move(x.icont()); + //Move allocator if needed + this->AllocHolder::move_assign_alloc(x); + } + //If unequal allocators, then do a one by one move + else{ + //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())); + + //Now recreate the source tree reusing nodes stored by other_tree + this->icont().clone_from + (x.icont() + , RecyclingMoveCloner(*this, other_tree) + , Destroyer(this->node_alloc())); + + //If there are remaining nodes, destroy them + NodePtr p; + while((p = other_tree.unlink_leftmost_without_rebalance())){ + AllocHolder::destroy_node(p); + } + } + } + return *this; + } + + public: + // accessors: + value_compare value_comp() const + { return this->icont().value_comp().value_comp(); } + + key_compare key_comp() const + { return this->icont().value_comp().value_comp().key_comp(); } + + allocator_type get_allocator() const + { return allocator_type(this->node_alloc()); } + + const stored_allocator_type &get_stored_allocator() const + { return this->node_alloc(); } + + stored_allocator_type &get_stored_allocator() + { return this->node_alloc(); } + + iterator begin() + { return iterator(this->icont().begin()); } + + const_iterator begin() const + { return this->cbegin(); } + + iterator end() + { return iterator(this->icont().end()); } + + const_iterator end() const + { return this->cend(); } + + reverse_iterator rbegin() + { return reverse_iterator(end()); } + + const_reverse_iterator rbegin() const + { return this->crbegin(); } + + reverse_iterator rend() + { return reverse_iterator(begin()); } + + const_reverse_iterator rend() const + { 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 + { 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 + { 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>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_reverse_iterator crend() const + { return const_reverse_iterator(cbegin()); } + + bool empty() const + { return !this->size(); } + + size_type size() const + { return this->icont().size(); } + + size_type max_size() const + { return AllocHolder::max_size(); } + + void swap(ThisType& x) + { AllocHolder::swap(x); } + + public: + + typedef typename Icont::insert_commit_data insert_commit_data; + + // insert/erase + std::pair<iterator,bool> insert_unique_check + (const key_type& key, insert_commit_data &data) + { + 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); + } + + std::pair<iterator,bool> insert_unique_check + (const_iterator hint, const key_type& key, insert_commit_data &data) + { + 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); + } + + iterator insert_unique_commit(const value_type& v, insert_commit_data &data) + { + NodePtr tmp = AllocHolder::create_node(v); + iiterator it(this->icont().insert_unique_commit(*tmp, data)); + return iterator(it); + } + + template<class MovableConvertible> + iterator insert_unique_commit + (BOOST_FWD_REF(MovableConvertible) mv, insert_commit_data &data) + { + NodePtr tmp = AllocHolder::create_node(boost::forward<MovableConvertible>(mv)); + iiterator it(this->icont().insert_unique_commit(*tmp, data)); + return iterator(it); + } + + std::pair<iterator,bool> insert_unique(const value_type& v) + { + insert_commit_data data; + std::pair<iterator,bool> ret = + this->insert_unique_check(KeyOfValue()(v), data); + if(!ret.second) + return ret; + return std::pair<iterator,bool> + (this->insert_unique_commit(v, data), true); + } + + template<class MovableConvertible> + std::pair<iterator,bool> insert_unique(BOOST_FWD_REF(MovableConvertible) mv) + { + insert_commit_data data; + std::pair<iterator,bool> ret = + this->insert_unique_check(KeyOfValue()(mv), data); + if(!ret.second) + return ret; + return std::pair<iterator,bool> + (this->insert_unique_commit(boost::forward<MovableConvertible>(mv), data), true); + } + + private: + std::pair<iterator, bool> emplace_unique_impl(NodePtr p) + { + value_type &v = p->get_data(); + insert_commit_data data; + std::pair<iterator,bool> ret = + this->insert_unique_check(KeyOfValue()(v), data); + if(!ret.second){ + Destroyer(this->node_alloc())(p); + return ret; + } + return std::pair<iterator,bool> + ( iterator(iiterator(this->icont().insert_unique_commit(*p, data))) + , true ); + } + + iterator emplace_unique_hint_impl(const_iterator hint, NodePtr p) + { + value_type &v = p->get_data(); + insert_commit_data data; + std::pair<iterator,bool> ret = + this->insert_unique_check(hint, KeyOfValue()(v), data); + if(!ret.second){ + Destroyer(this->node_alloc())(p); + return ret.first; + } + return iterator(iiterator(this->icont().insert_unique_commit(*p, data))); + } + + public: + + #ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + template <class... Args> + std::pair<iterator, bool> emplace_unique(Args&&... args) + { return this->emplace_unique_impl(AllocHolder::create_node(boost::forward<Args>(args)...)); } + + template <class... Args> + iterator emplace_hint_unique(const_iterator hint, Args&&... args) + { return this->emplace_unique_hint_impl(hint, AllocHolder::create_node(boost::forward<Args>(args)...)); } + + template <class... Args> + iterator emplace_equal(Args&&... args) + { + NodePtr p(AllocHolder::create_node(boost::forward<Args>(args)...)); + return iterator(this->icont().insert_equal(this->icont().end(), *p)); + } + + template <class... Args> + iterator emplace_hint_equal(const_iterator hint, Args&&... args) + { + NodePtr p(AllocHolder::create_node(boost::forward<Args>(args)...)); + return iterator(this->icont().insert_equal(hint.get(), *p)); + } + + #else //#ifdef 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, >) \ + std::pair<iterator, bool> emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + return this->emplace_unique_impl \ + (AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint_unique(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + return this->emplace_unique_hint_impl \ + (hint, AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + NodePtr p(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + return iterator(this->icont().insert_equal(this->icont().end(), *p)); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint_equal(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + NodePtr p(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + return iterator(this->icont().insert_equal(hint.get(), *p)); \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + iterator insert_unique(const_iterator hint, const value_type& v) + { + insert_commit_data data; + std::pair<iterator,bool> ret = + this->insert_unique_check(hint, KeyOfValue()(v), data); + if(!ret.second) + return ret.first; + return this->insert_unique_commit(v, data); + } + + template<class MovableConvertible> + iterator insert_unique(const_iterator hint, BOOST_FWD_REF(MovableConvertible) mv) + { + insert_commit_data data; + std::pair<iterator,bool> ret = + this->insert_unique_check(hint, KeyOfValue()(mv), data); + if(!ret.second) + return ret.first; + return this->insert_unique_commit(boost::forward<MovableConvertible>(mv), data); + } + + template <class InputIterator> + void insert_unique(InputIterator first, InputIterator last) + { + if(this->empty()){ + //Insert with end hint, to achieve linear + //complexity if [first, last) is ordered + const_iterator end(this->end()); + for( ; first != last; ++first) + this->insert_unique(end, *first); + } + else{ + for( ; first != last; ++first) + this->insert_unique(*first); + } + } + + iterator insert_equal(const value_type& v) + { + NodePtr p(AllocHolder::create_node(v)); + return iterator(this->icont().insert_equal(this->icont().end(), *p)); + } + + template<class MovableConvertible> + iterator insert_equal(BOOST_FWD_REF(MovableConvertible) mv) + { + NodePtr p(AllocHolder::create_node(boost::forward<MovableConvertible>(mv))); + return iterator(this->icont().insert_equal(this->icont().end(), *p)); + } + + iterator insert_equal(const_iterator hint, const value_type& v) + { + NodePtr p(AllocHolder::create_node(v)); + return iterator(this->icont().insert_equal(hint.get(), *p)); + } + + template<class MovableConvertible> + iterator insert_equal(const_iterator hint, BOOST_FWD_REF(MovableConvertible) mv) + { + NodePtr p(AllocHolder::create_node(boost::forward<MovableConvertible>(mv))); + return iterator(this->icont().insert_equal(hint.get(), *p)); + } + + template <class InputIterator> + void insert_equal(InputIterator first, InputIterator last) + { + //Insert with end hint, to achieve linear + //complexity if [first, last) is ordered + const_iterator end(this->cend()); + for( ; first != last; ++first) + this->insert_equal(end, *first); + } + + iterator erase(const_iterator position) + { return iterator(this->icont().erase_and_dispose(position.get(), Destroyer(this->node_alloc()))); } + + size_type erase(const key_type& k) + { return AllocHolder::erase_key(k, KeyNodeCompare(value_comp()), alloc_version()); } + + iterator erase(const_iterator first, const_iterator last) + { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); } + + void clear() + { AllocHolder::clear(alloc_version()); } + + // set operations: + iterator find(const key_type& k) + { return iterator(this->icont().find(k, KeyNodeCompare(value_comp()))); } + + const_iterator find(const key_type& k) const + { return const_iterator(this->non_const_icont().find(k, KeyNodeCompare(value_comp()))); } + + size_type count(const key_type& k) const + { return size_type(this->icont().count(k, KeyNodeCompare(value_comp()))); } + + iterator lower_bound(const key_type& k) + { return iterator(this->icont().lower_bound(k, KeyNodeCompare(value_comp()))); } + + const_iterator lower_bound(const key_type& k) const + { return const_iterator(this->non_const_icont().lower_bound(k, KeyNodeCompare(value_comp()))); } + + iterator upper_bound(const key_type& k) + { return iterator(this->icont().upper_bound(k, KeyNodeCompare(value_comp()))); } + + const_iterator upper_bound(const key_type& k) const + { 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> + (const_iterator(ret.first), const_iterator(ret.second)); + } + + private: + //Iterator range version + template<class InpIterator> + void priv_create_and_insert_nodes + (InpIterator beg, InpIterator end, bool unique, allocator_v1, std::input_iterator_tag) + { + if(unique){ + for (; beg != end; ++beg){ + this->insert_unique(*beg); + } + } + else{ + for (; beg != end; ++beg){ + this->insert_equal(*beg); + } + } + } + + template<class InpIterator> + void priv_create_and_insert_nodes + (InpIterator beg, InpIterator end, bool unique, allocator_v2, std::input_iterator_tag) + { //Just forward to the default one + priv_create_and_insert_nodes(beg, end, unique, allocator_v1(), std::input_iterator_tag()); + } + + class insertion_functor; + friend class insertion_functor; + + class insertion_functor + { + Icont &icont_; + + public: + insertion_functor(Icont &icont) + : icont_(icont) + {} + + void operator()(Node &n) + { this->icont_.insert_equal(this->icont_.cend(), n); } + }; + + + template<class FwdIterator> + void priv_create_and_insert_nodes + (FwdIterator beg, FwdIterator end, bool unique, allocator_v2, std::forward_iterator_tag) + { + if(beg != end){ + if(unique){ + priv_create_and_insert_nodes(beg, end, unique, allocator_v2(), std::input_iterator_tag()); + } + else{ + //Optimized allocation and construction + this->allocate_many_and_construct + (beg, std::distance(beg, end), insertion_functor(this->icont())); + } + } + } + + //Iterator range version + template<class InpIterator> + void priv_create_and_insert_ordered_nodes + (InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag) + { + const_iterator cend_n(this->cend()); + for (; beg != end; ++beg){ + this->insert_before(cend_n, *beg); + } + } + + template<class InpIterator> + void priv_create_and_insert_ordered_nodes + (InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag) + { //Just forward to the default one + priv_create_and_insert_ordered_nodes(beg, end, allocator_v1(), std::input_iterator_tag()); + } + + class back_insertion_functor; + friend class back_insertion_functor; + + class back_insertion_functor + { + Icont &icont_; + + public: + back_insertion_functor(Icont &icont) + : icont_(icont) + {} + + void operator()(Node &n) + { this->icont_.push_back(n); } + }; + + + template<class FwdIterator> + void priv_create_and_insert_ordered_nodes + (FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag) + { + if(beg != end){ + //Optimized allocation and construction + this->allocate_many_and_construct + (beg, std::distance(beg, end), back_insertion_functor(this->icont())); + } + } +}; + +template <class Key, class Value, class KeyOfValue, + class KeyCompare, class A> +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, + class KeyCompare, class A> +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(), + y.begin(), y.end()); +} + +template <class Key, class Value, class KeyOfValue, + class KeyCompare, class A> +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, + class KeyCompare, class A> +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, + class KeyCompare, class A> +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, + class KeyCompare, class A> +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, + class KeyCompare, class A> +inline void +swap(rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x, + rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) +{ + x.swap(y); +} + +} //namespace container_detail { +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +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> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //BOOST_CONTAINER_TREE_HPP diff --git a/src/third_party/boost/boost/container/detail/type_traits.hpp b/src/third_party/boost/boost/container/detail/type_traits.hpp new file mode 100644 index 00000000000..6a0b3ed58d4 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/type_traits.hpp @@ -0,0 +1,203 @@ +////////////////////////////////////////////////////////////////////////////// +// (C) Copyright John Maddock 2000. +// (C) Copyright Ion Gaztanaga 2005-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. +// +// The alignment_of implementation comes from John Maddock's boost::alignment_of code +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP +#define BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" + +#include <boost/move/move.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +struct nat{}; + +//boost::alignment_of yields to 10K lines of preprocessed code, so we +//need an alternative +template <typename T> struct alignment_of; + +template <typename T> +struct alignment_of_hack +{ + char c; + T t; + alignment_of_hack(); +}; + +template <unsigned A, unsigned S> +struct alignment_logic +{ + enum{ value = A < S ? A : S }; +}; + +template< typename T > +struct alignment_of +{ + enum{ value = alignment_logic + < sizeof(alignment_of_hack<T>) - sizeof(T) + , sizeof(T)>::value }; +}; + +//This is not standard, but should work with all compilers +union max_align +{ + char char_; + short short_; + int int_; + long long_; + #ifdef BOOST_HAS_LONG_LONG + long long long_long_; + #endif + float float_; + double double_; + long double long_double_; + void * void_ptr_; +}; + +template<class T> +struct remove_reference +{ + typedef T type; +}; + +template<class T> +struct remove_reference<T&> +{ + typedef T type; +}; + +#ifndef BOOST_NO_RVALUE_REFERENCES + +template<class T> +struct remove_reference<T&&> +{ + typedef T type; +}; + +#else + +template<class T> +struct remove_reference< ::boost::rv<T> > +{ + typedef T type; +}; + +#endif + +template<class T> +struct is_reference +{ + enum { value = false }; +}; + +template<class T> +struct is_reference<T&> +{ + enum { value = true }; +}; + +template<class T> +struct is_pointer +{ + enum { value = false }; +}; + +template<class T> +struct is_pointer<T*> +{ + enum { value = true }; +}; + +template <typename T> +struct add_reference +{ + typedef T& type; +}; + +template<class T> +struct add_reference<T&> +{ + typedef T& type; +}; + +template<> +struct add_reference<void> +{ + typedef nat &type; +}; + +template<> +struct add_reference<const void> +{ + typedef const nat &type; +}; + +template <class T> +struct add_const_reference +{ typedef const T &type; }; + +template <class T> +struct add_const_reference<T&> +{ typedef T& type; }; + +template <typename T, typename U> +struct is_same +{ + typedef char yes_type; + struct no_type + { + char padding[8]; + }; + + template <typename V> + static yes_type is_same_tester(V*, V*); + static no_type is_same_tester(...); + + static T *t; + static U *u; + + static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u)); +}; + +template<class T> +struct remove_const +{ + typedef T type; +}; + +template<class T> +struct remove_const< const T> +{ + typedef T type; +}; + +template<class T> +struct remove_ref_const +{ + typedef typename remove_const< typename remove_reference<T>::type >::type type; +}; + +} // namespace container_detail +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP diff --git a/src/third_party/boost/boost/container/detail/utilities.hpp b/src/third_party/boost/boost/container/detail/utilities.hpp new file mode 100644 index 00000000000..ee0fe993b25 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/utilities.hpp @@ -0,0 +1,271 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_UTILITIES_HPP +#define BOOST_CONTAINER_DETAIL_UTILITIES_HPP + +#include "config_begin.hpp" +#include <cstdio> +#include <boost/type_traits/is_fundamental.hpp> +#include <boost/type_traits/is_pointer.hpp> +#include <boost/type_traits/is_enum.hpp> +#include <boost/type_traits/is_member_pointer.hpp> +#include <boost/type_traits/is_class.hpp> +#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 <algorithm> + +namespace boost { +namespace container { +namespace container_detail { + +template<class T> +const T &max_value(const T &a, const T &b) +{ return a > b ? a : b; } + +template<class T> +const T &min_value(const T &a, const T &b) +{ return a < b ? a : b; } + +template <class SizeType> +SizeType + get_next_capacity(const SizeType max_size + ,const SizeType capacity + ,const SizeType n) +{ +// if (n > max_size - capacity) +// throw std::length_error("get_next_capacity"); + + const SizeType m3 = max_size/3; + + if (capacity < m3) + return capacity + max_value(3*(capacity+1)/5, n); + + if (capacity < m3*2) + return capacity + max_value((capacity+1)/2, n); + + return max_size; +} + +template <class T> +inline T* to_raw_pointer(T* p) +{ return p; } + +template <class Pointer> +inline typename Pointer::element_type* + to_raw_pointer(const Pointer &p) +{ return boost::container::container_detail::to_raw_pointer(p.operator->()); } + +//!To avoid ADL problems with swap +template <class T> +inline void do_swap(T& x, T& y) +{ + using std::swap; + swap(x, y); +} + +template<class AllocatorType> +inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) + BOOST_CONTAINER_NOEXCEPT +{} + +template<class AllocatorType> +inline void swap_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) +{ container_detail::do_swap(l, r); } + +template<class AllocatorType> +inline void assign_alloc(AllocatorType &, const AllocatorType &, container_detail::false_type) + BOOST_CONTAINER_NOEXCEPT +{} + +template<class AllocatorType> +inline void assign_alloc(AllocatorType &l, const AllocatorType &r, container_detail::true_type) +{ l = r; } + +template<class AllocatorType> +inline void move_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) + BOOST_CONTAINER_NOEXCEPT +{} + +template<class AllocatorType> +inline void move_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) +{ l = ::boost::move(r); } + +//Rounds "orig_size" by excess to round_to bytes +template<class SizeType> +inline SizeType get_rounded_size(SizeType orig_size, SizeType round_to) +{ + return ((orig_size-1)/round_to+1)*round_to; +} + +template <std::size_t OrigSize, std::size_t RoundTo> +struct ct_rounded_size +{ + enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo }; +}; +/* +template <class _TypeT> +struct __rw_is_enum +{ + struct _C_no { }; + struct _C_yes { int _C_dummy [2]; }; + + struct _C_indirect { + // prevent classes with user-defined conversions from matching + + // use double to prevent float->int gcc conversion warnings + _C_indirect (double); +}; + +// nested struct gets rid of bogus gcc errors +struct _C_nest { + // supply first argument to prevent HP aCC warnings + static _C_no _C_is (int, ...); + static _C_yes _C_is (int, _C_indirect); + + static _TypeT _C_make_T (); +}; + +enum { + _C_val = sizeof (_C_yes) == sizeof (_C_nest::_C_is (0, _C_nest::_C_make_T ())) + && !::boost::is_fundamental<_TypeT>::value +}; + +}; +*/ + +template<class T> +struct move_const_ref_type + : if_c +// < ::boost::is_fundamental<T>::value || ::boost::is_pointer<T>::value || ::boost::is_member_pointer<T>::value || ::boost::is_enum<T>::value + < !::boost::is_class<T>::value + ,const T & + ,BOOST_CATCH_CONST_RLVALUE(T) + > +{}; + +} //namespace container_detail { + +////////////////////////////////////////////////////////////////////////////// +// +// uninitialized_move_alloc +// +////////////////////////////////////////////////////////////////////////////// + +//! <b>Effects</b>: +//! \code +//! for (; first != last; ++result, ++first) +//! allocator_traits::construct(a, &*result, boost::move(*first)); +//! \endcode +//! +//! <b>Returns</b>: result +template + <typename A, + typename I, // I models InputIterator + typename F> // F models ForwardIterator +F uninitialized_move_alloc(A &a, I f, I l, F r) +{ + while (f != l) { + allocator_traits<A>::construct(a, container_detail::to_raw_pointer(&*r), boost::move(*f)); + ++f; ++r; + } + return r; +} + +////////////////////////////////////////////////////////////////////////////// +// +// uninitialized_copy_alloc +// +////////////////////////////////////////////////////////////////////////////// + +//! <b>Effects</b>: +//! \code +//! for (; first != last; ++result, ++first) +//! allocator_traits::construct(a, &*result, *first); +//! \endcode +//! +//! <b>Returns</b>: result +template + <typename A, + typename I, // I models InputIterator + typename F> // F models ForwardIterator +F uninitialized_copy_alloc(A &a, I f, I l, F r) +{ + while (f != l) { + allocator_traits<A>::construct(a, container_detail::to_raw_pointer(&*r), *f); + ++f; ++r; + } + return r; +} + +////////////////////////////////////////////////////////////////////////////// +// +// uninitialized_copy_alloc +// +////////////////////////////////////////////////////////////////////////////// + +//! <b>Effects</b>: +//! \code +//! for (; first != last; ++result, ++first) +//! allocator_traits::construct(a, &*result, *first); +//! \endcode +//! +//! <b>Returns</b>: result +template + <typename A, + typename F, // F models ForwardIterator + typename T> +void uninitialized_fill_alloc(A &a, F f, F l, const T &t) +{ + while (f != l) { + allocator_traits<A>::construct(a, container_detail::to_raw_pointer(&*f), t); + ++f; + } +} + +////////////////////////////////////////////////////////////////////////////// +// +// uninitialized_copy_or_move_alloc +// +////////////////////////////////////////////////////////////////////////////// + +template +<typename A +,typename I // I models InputIterator +,typename F> // F models ForwardIterator +F uninitialized_copy_or_move_alloc + (A &a, I f, I l, F r + ,typename boost::container::container_detail::enable_if + < boost::move_detail::is_move_iterator<I> >::type* = 0) +{ + return ::boost::container::uninitialized_move_alloc(a, f, l, r); +} + +template +<typename A +,typename I // I models InputIterator +,typename F> // F models ForwardIterator +F uninitialized_copy_or_move_alloc + (A &a, I f, I l, F r + ,typename boost::container::container_detail::disable_if + < boost::move_detail::is_move_iterator<I> >::type* = 0) +{ + return ::boost::container::uninitialized_copy_alloc(a, f, l, r); +} + +} //namespace container { +} //namespace boost { + + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP diff --git a/src/third_party/boost/boost/container/detail/value_init.hpp b/src/third_party/boost/boost/container/detail/value_init.hpp new file mode 100644 index 00000000000..afbc9c1e34d --- /dev/null +++ b/src/third_party/boost/boost/container/detail/value_init.hpp @@ -0,0 +1,45 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_VALUE_INIT_HPP +#define BOOST_CONTAINER_DETAIL_VALUE_INIT_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> + +namespace boost { +namespace container { +namespace container_detail { + +template<class T> +struct value_init +{ + value_init() + : m_t() + {} + + operator T &() { return m_t; } + + T m_t; +}; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_VALUE_INIT_HPP diff --git a/src/third_party/boost/boost/container/detail/variadic_templates_tools.hpp b/src/third_party/boost/boost/container/detail/variadic_templates_tools.hpp new file mode 100644 index 00000000000..f21f972ab12 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/variadic_templates_tools.hpp @@ -0,0 +1,153 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-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_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP +#define BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include "config_begin.hpp" +#include <boost/container/detail/workaround.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <cstddef> //std::size_t + +namespace boost { +namespace container { +namespace container_detail { + +template<typename... Values> +class tuple; + +template<> class tuple<> +{}; + +template<typename Head, typename... Tail> +class tuple<Head, Tail...> + : private tuple<Tail...> +{ + typedef tuple<Tail...> inherited; + + public: + tuple() { } + + // implicit copy-constructor is okay + // Construct tuple from separate arguments. + tuple(typename add_const_reference<Head>::type v, + typename add_const_reference<Tail>::type... vtail) + : inherited(vtail...), m_head(v) + {} + + // Construct tuple from another tuple. + template<typename... VValues> + tuple(const tuple<VValues...>& other) + : m_head(other.head()), inherited(other.tail()) + {} + + template<typename... VValues> + tuple& operator=(const tuple<VValues...>& other) + { + m_head = other.head(); + tail() = other.tail(); + return this; + } + + typename add_reference<Head>::type head() { return m_head; } + typename add_reference<const Head>::type head() const { return m_head; } + + inherited& tail() { return *this; } + const inherited& tail() const { return *this; } + + protected: + Head m_head; +}; + + +template<typename... Values> +tuple<Values&&...> tie_forward(Values&&... values) +{ return tuple<Values&&...>(values...); } + +template<int I, typename Tuple> +struct tuple_element; + +template<int I, typename Head, typename... Tail> +struct tuple_element<I, tuple<Head, Tail...> > +{ + typedef typename tuple_element<I-1, tuple<Tail...> >::type type; +}; + +template<typename Head, typename... Tail> +struct tuple_element<0, tuple<Head, Tail...> > +{ + typedef Head type; +}; + +template<int I, typename Tuple> +class get_impl; + +template<int I, typename Head, typename... Values> +class get_impl<I, tuple<Head, Values...> > +{ + typedef typename tuple_element<I-1, tuple<Values...> >::type Element; + typedef get_impl<I-1, tuple<Values...> > Next; + + public: + typedef typename add_reference<Element>::type type; + typedef typename add_const_reference<Element>::type const_type; + static type get(tuple<Head, Values...>& t) { return Next::get(t.tail()); } + static const_type get(const tuple<Head, Values...>& t) { return Next::get(t.tail()); } +}; + +template<typename Head, typename... Values> +class get_impl<0, tuple<Head, Values...> > +{ + public: + typedef typename add_reference<Head>::type type; + typedef typename add_const_reference<Head>::type const_type; + static type get(tuple<Head, Values...>& t) { return t.head(); } + static const_type get(const tuple<Head, Values...>& t){ return t.head(); } +}; + +template<int I, typename... Values> +typename get_impl<I, tuple<Values...> >::type get(tuple<Values...>& t) +{ return get_impl<I, tuple<Values...> >::get(t); } + +template<int I, typename... Values> +typename get_impl<I, tuple<Values...> >::const_type get(const tuple<Values...>& t) +{ return get_impl<I, tuple<Values...> >::get(t); } + +//////////////////////////////////////////////////// +// Builds an index_tuple<0, 1, 2, ..., Num-1>, that will +// be used to "unpack" into comma-separated values +// in a function call. +//////////////////////////////////////////////////// + +template<int... Indexes> +struct index_tuple{}; + +template<std::size_t Num, typename Tuple = index_tuple<> > +struct build_number_seq; + +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)> > +{}; + +template<int... Indexes> +struct build_number_seq<0, index_tuple<Indexes...> > +{ typedef index_tuple<Indexes...> type; }; + + +}}} //namespace boost { namespace container { namespace container_detail { + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP diff --git a/src/third_party/boost/boost/container/detail/version_type.hpp b/src/third_party/boost/boost/container/detail/version_type.hpp new file mode 100644 index 00000000000..46344faca05 --- /dev/null +++ b/src/third_party/boost/boost/container/detail/version_type.hpp @@ -0,0 +1,92 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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. +// +////////////////////////////////////////////////////////////////////////////// +// +// This code comes from N1953 document by Howard E. Hinnant +// +////////////////////////////////////////////////////////////////////////////// + + +#ifndef BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP +#define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP + +#include "config_begin.hpp" + +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/type_traits.hpp> + +namespace boost{ +namespace container { +namespace container_detail { + +//using namespace boost; + +template <class T, unsigned V> +struct version_type + : public container_detail::integral_constant<unsigned, V> +{ + typedef T type; + + version_type(const version_type<T, 0>&); +}; + +namespace impl{ + +template <class T, + bool = container_detail::is_convertible<version_type<T, 0>, typename T::version>::value> +struct extract_version +{ + static const unsigned value = 1; +}; + +template <class T> +struct extract_version<T, true> +{ + static const unsigned value = T::version::value; +}; + +template <class T> +struct has_version +{ + private: + struct two {char _[2];}; + template <class U> static two test(...); + template <class U> static char test(const typename U::version*); + public: + static const bool value = sizeof(test<T>(0)) == 1; + void dummy(){} +}; + +template <class T, bool = has_version<T>::value> +struct version +{ + static const unsigned value = 1; +}; + +template <class T> +struct version<T, true> +{ + static const unsigned value = extract_version<T>::value; +}; + +} //namespace impl + +template <class T> +struct version + : public container_detail::integral_constant<unsigned, impl::version<T>::value> +{ +}; + +} //namespace container_detail { +} //namespace container { +} //namespace boost{ + +#include "config_end.hpp" + +#endif //#define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP diff --git a/src/third_party/boost/boost/container/detail/workaround.hpp b/src/third_party/boost/boost/container/detail/workaround.hpp new file mode 100644 index 00000000000..45ab2f2c4da --- /dev/null +++ b/src/third_party/boost/boost/container/detail/workaround.hpp @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_DETAIL_WORKAROUND_HPP +#define BOOST_CONTAINER_DETAIL_WORKAROUND_HPP + +#include <boost/container/detail/config_begin.hpp> + +#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES)\ + && !defined(BOOST_INTERPROCESS_DISABLE_VARIADIC_TMPL) + #define BOOST_CONTAINER_PERFECT_FORWARDING +#endif + +#if defined(BOOST_NO_NOEXCEPT) + #define BOOST_CONTAINER_NOEXCEPT + #define BOOST_CONTAINER_NOEXCEPT_IF(x) +#else + #define BOOST_CONTAINER_NOEXCEPT noexcept + #define BOOST_CONTAINER_NOEXCEPT_IF(x) noexcept(x) +#endif + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP diff --git a/src/third_party/boost/boost/container/flat_map.hpp b/src/third_party/boost/boost/container/flat_map.hpp new file mode 100644 index 00000000000..2d4515b4a48 --- /dev/null +++ b/src/third_party/boost/boost/container/flat_map.hpp @@ -0,0 +1,1457 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_FLAT_MAP_HPP +#define BOOST_CONTAINER_FLAT_MAP_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/container_fwd.hpp> +#include <utility> +#include <functional> +#include <memory> +#include <stdexcept> +#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/move/move.hpp> + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace boost { +namespace container { +#else +namespace boost { +namespace container { +#endif + +/// @cond +// Forward declarations of operators == and <, needed for friend declarations. +#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; + +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); + +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); + +namespace container_detail{ + +template<class D, class S> +static D &force(const S &s) +{ return *const_cast<D*>((reinterpret_cast<const D*>(&s))); } + +template<class D, class S> +static D force_copy(S s) +{ + D *vp = reinterpret_cast<D *>(&s); + return D(*vp); +} + +} //namespace container_detail{ + + +/// @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 +//! 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 +//! 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>). +//! +//! Pred is the ordering function for Keys (e.g. <i>std::less<Key></i>). +//! +//! 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 +//! 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 +{ + /// @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, + 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, + 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 + + typedef typename impl_tree_t::value_type impl_value_type; + typedef typename impl_tree_t::pointer impl_pointer; + typedef typename impl_tree_t::const_pointer impl_const_pointer; + typedef typename impl_tree_t::reference impl_reference; + typedef typename impl_tree_t::const_reference impl_const_reference; + typedef typename impl_tree_t::value_compare impl_value_compare; + typedef typename impl_tree_t::iterator impl_iterator; + typedef typename impl_tree_t::const_iterator impl_const_iterator; + typedef typename impl_tree_t::reverse_iterator impl_reverse_iterator; + typedef typename impl_tree_t::const_reverse_iterator impl_const_reverse_iterator; + typedef typename impl_tree_t::allocator_type impl_allocator_type; + typedef allocator_traits<A> allocator_traits_type; + + + + /// @endcond + + public: + + // typedefs: + typedef Key key_type; + typedef T mapped_type; + typedef typename std::pair<key_type, mapped_type> value_type; + typedef typename allocator_traits_type::pointer pointer; + typedef typename allocator_traits_type::const_pointer const_pointer; + typedef typename allocator_traits_type::reference reference; + typedef typename allocator_traits_type::const_reference const_reference; + typedef typename impl_tree_t::size_type size_type; + typedef typename impl_tree_t::difference_type difference_type; + + typedef container_detail::flat_tree_value_compare + < Pred + , container_detail::select1st< std::pair<Key, T> > + , std::pair<Key, T> > value_compare; + typedef Pred key_compare; + typedef typename container_detail:: + get_flat_tree_iterators<pointer>::iterator iterator; + typedef typename container_detail:: + get_flat_tree_iterators<pointer>::const_iterator const_iterator; + typedef typename container_detail:: + get_flat_tree_iterators + <pointer>::reverse_iterator reverse_iterator; + typedef typename container_detail:: + get_flat_tree_iterators + <pointer>::const_reverse_iterator const_reverse_iterator; + typedef A allocator_type; + typedef A stored_allocator_type; + + public: + //! <b>Effects</b>: Default constructs an empty flat_map. + //! + //! <b>Complexity</b>: Constant. + 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()) + : 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 + //! allocator, and inserts elements from the range [first ,last ). + //! + //! <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.insert_unique(first, last); } + + //! <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. + 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) + {} + + //! <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) + : 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>Postcondition</b>: x is emptied. + flat_map(BOOST_RV_REF(flat_map) x) + : m_flat_tree(boost::move(x.m_flat_tree)) + {} + + //! <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) + { 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) + { 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()); } + + //! <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())); } + + //! <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()); } + + 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() + { 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()); } + + //! <b>Effects</b>: Returns an iterator to the end of the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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()); } + + //! <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<const_iterator>(m_flat_tree.cend()); } + + //! <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()); } + + //! <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()); } + + //! <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<const_reverse_iterator>(m_flat_tree.crbegin()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! 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()); } + + //! <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<const_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 crend() const + { return container_detail::force<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 + { 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 + { 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 + { 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 + //! 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 + //! 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) ; + + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, priv_subscript) + #endif + + //! Returns: A reference to the element whose key is equivalent to x. + //! Throws: An exception object of type out_of_range if no such element is present. + //! Complexity: logarithmic. + T& at(const key_type& k) + { + iterator i = this->find(k); + if(i == this->end()){ + throw std::out_of_range("key not found"); + } + return i->second; + } + + //! Returns: A reference to the element whose key is equivalent to x. + //! Throws: An exception object of type out_of_range if no such element is present. + //! Complexity: logarithmic. + const T& at(const key_type& k) const + { + const_iterator i = this->find(k); + if(i == this->end()){ + throw std::out_of_range("key not found"); + } + return i->second; + } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + //! with key equivalent to the key of x. + //! + //! <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 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. + std::pair<iterator,bool> insert(const value_type& x) + { return container_detail::force<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 + //! 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 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. + std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x) + { return container_detail::force<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 + //! 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 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. + std::pair<iterator,bool> insert(BOOST_RV_REF(impl_value_type) x) + { + return container_detail::force<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 + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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, 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))); } + + //! <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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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) + { 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)))); } + + //! <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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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) + { + return container_detail::force_copy<iterator>( + m_flat_tree.insert_unique(container_detail::force<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 + //! 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) + //! search time plus N*size() insertion time. + //! + //! <b>Note</b>: If an element is inserted it might invalidate elements. + template <class InputIterator> + void insert(InputIterator first, InputIterator last) + { m_flat_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 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 + //! 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 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. + template <class... Args> + std::pair<iterator,bool> emplace(Args&&... args) + { return container_detail::force_copy< std::pair<iterator, bool> >(m_flat_tree.emplace_unique(boost::forward<Args>(args)...)); } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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. + 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)...)); } + + #else //#ifdef 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, >) \ + std::pair<iterator,bool> emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy< std::pair<iterator, bool> > \ + (m_flat_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_unique \ + (container_detail::force<impl_const_iterator>(hint) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! 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))); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: Logarithmic search time plus erasure time + //! linear to the elements with bigger keys. + 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). + //! + //! <b>Returns</b>: Returns last. + //! + //! <b>Complexity</b>: size()*N where N is the distance from first to last. + //! + //! <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))); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + void clear() + { m_flat_tree.clear(); } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + // with previous allocations. The size of the vector is unchanged + //! + //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { m_flat_tree.shrink_to_fit(); } + + //! <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) + { 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)); } + + //! <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 + { 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) + { 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)); } + + //! <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) + { 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)); } + + //! <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)); } + + //! <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)); } + + //! <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 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) + { m_flat_tree.reserve(count); } + + /// @cond + template <class K1, class T1, class C1, class A1> + friend bool operator== (const flat_map<K1, T1, C1, A1>&, + const flat_map<K1, T1, C1, A1>&); + template <class K1, class T1, class C1, class A1> + friend bool operator< (const flat_map<K1, T1, C1, A1>&, + const flat_map<K1, T1, C1, A1>&); + + private: + mapped_type &priv_subscript(const key_type& k) + { + iterator i = lower_bound(k); + // i->first is greater than or equivalent to k. + if (i == end() || key_comp()(k, (*i).first)){ + container_detail::value_init<mapped_type> m; + i = insert(i, impl_value_type(k, ::boost::move(m.m_t))); + } + return (*i).second; + } + mapped_type &priv_subscript(BOOST_RV_REF(key_type) mk) + { + key_type &k = mk; + iterator i = lower_bound(k); + // i->first is greater than or equivalent to k. + if (i == end() || key_comp()(k, (*i).first)){ + container_detail::value_init<mapped_type> m; + i = insert(i, impl_value_type(boost::move(k), ::boost::move(m.m_t))); + } + return (*i).second; + } + /// @endcond +}; + +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) + { 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) + { 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) + { 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) + { 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) + { 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) + { 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) + { x.swap(y); } + +/// @cond + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class K, class T, class C, class A> +struct has_trivial_destructor_after_move<boost::container::flat_map<K, T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +namespace container { + +// Forward declaration of operators < and ==, needed for friend declaration. +#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_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); + +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); +/// @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 +//! 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 +//! 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>). +//! +//! Pred is the ordering function for Keys (e.g. <i>std::less<Key></i>). +//! +//! A is the allocator to allocate the value_types +//! (e.g. <i>allocator< std::pair<Key, T> ></i>). +#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_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, + 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, + 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 + + typedef typename impl_tree_t::value_type impl_value_type; + typedef typename impl_tree_t::pointer impl_pointer; + typedef typename impl_tree_t::const_pointer impl_const_pointer; + typedef typename impl_tree_t::reference impl_reference; + typedef typename impl_tree_t::const_reference impl_const_reference; + typedef typename impl_tree_t::value_compare impl_value_compare; + typedef typename impl_tree_t::iterator impl_iterator; + typedef typename impl_tree_t::const_iterator impl_const_iterator; + typedef typename impl_tree_t::reverse_iterator impl_reverse_iterator; + typedef typename impl_tree_t::const_reverse_iterator impl_const_reverse_iterator; + typedef typename impl_tree_t::allocator_type impl_allocator_type; + typedef allocator_traits<A> allocator_traits_type; + + /// @endcond + + public: + + // typedefs: + typedef Key key_type; + typedef T mapped_type; + typedef Pred key_compare; + typedef typename std::pair<key_type, mapped_type> value_type; + typedef typename allocator_traits_type::pointer pointer; + typedef typename allocator_traits_type::const_pointer const_pointer; + typedef typename allocator_traits_type::reference reference; + typedef typename allocator_traits_type::const_reference const_reference; + typedef typename impl_tree_t::size_type size_type; + typedef typename impl_tree_t::difference_type difference_type; + typedef container_detail::flat_tree_value_compare + < Pred + , container_detail::select1st< std::pair<Key, T> > + , std::pair<Key, T> > value_compare; + + typedef typename container_detail:: + get_flat_tree_iterators<pointer>::iterator iterator; + typedef typename container_detail:: + get_flat_tree_iterators<pointer>::const_iterator const_iterator; + typedef typename container_detail:: + get_flat_tree_iterators + <pointer>::reverse_iterator reverse_iterator; + typedef typename container_detail:: + get_flat_tree_iterators + <pointer>::const_reverse_iterator const_reverse_iterator; + typedef A allocator_type; + //Non-standard extension + typedef A stored_allocator_type; + + //! <b>Effects</b>: Default constructs an empty flat_map. + //! + //! <b>Complexity</b>: Constant. + 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()) + : m_flat_tree(comp, container_detail::force<impl_allocator_type>(a)) { } + + //! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object + //! and allocator, and inserts elements from the range [first ,last ). + //! + //! <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.insert_equal(first, last); } + + //! <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. + 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) + {} + + //! <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) + : 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>Postcondition</b>: x is emptied. + flat_multimap(BOOST_RV_REF(flat_multimap) x) + : m_flat_tree(boost::move(x.m_flat_tree)) + { } + + //! <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) + { 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) + { 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()); } + + //! <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())); } + + //! <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()); } + + 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() + { 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 an iterator to the end of the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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()); } + + //! <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()); } + + //! <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()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! 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()); } + + //! <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<const_reverse_iterator>(m_flat_tree.rend()); } + + //! <b>Effects</b>: Returns true if the container contains no elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + { 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 + { return m_flat_tree.max_size(); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + void swap(flat_multimap& x) + { m_flat_tree.swap(x.m_flat_tree); } + + //! <b>Effects</b>: Inserts 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(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>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) + { 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>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) + { 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. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant time if the value + //! is to be inserted before p) 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_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))); } + + //! <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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant time if the value + //! is to be inserted before p) 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_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) + , boost::move(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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant time if the value + //! is to be inserted before p) 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_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))); + } + + //! <b>Requires</b>: first, last are not iterators into *this. + //! + //! <b>Effects</b>: inserts each element from the range [first,last) . + //! + //! <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(InputIterator first, InputIterator last) + { m_flat_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. + //! + //! <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. + template <class... Args> + iterator emplace(Args&&... args) + { return container_detail::force_copy<iterator>(m_flat_tree.emplace_equal(boost::forward<Args>(args)...)); } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant time if the value + //! is to be inserted before p) plus linear insertion + //! to the elements with bigger keys than x. + //! + //! <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_equal + (container_detail::force<impl_const_iterator>(hint), boost::forward<Args>(args)...)); + } + + #else //#ifdef 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, >) \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy<iterator>(m_flat_tree.emplace_equal \ + (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return container_detail::force_copy<iterator>(m_flat_tree.emplace_hint_equal \ + (container_detail::force<impl_const_iterator>(hint) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! 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))); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: Logarithmic search time plus erasure time + //! linear to the elements with bigger keys. + 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). + //! + //! <b>Returns</b>: Returns last. + //! + //! <b>Complexity</b>: size()*N where N is the distance from first to last. + //! + //! <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))); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + void clear() + { m_flat_tree.clear(); } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + // with previous allocations. The size of the vector is unchanged + //! + //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { m_flat_tree.shrink_to_fit(); } + + //! <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) + { return container_detail::force_copy<iterator>(m_flat_tree.find(x)); } + + //! <b>Returns</b>: An 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 + { return container_detail::force<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 + { 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) + {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)); } + + //! <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) + {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)); } + + //! <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_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_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 + { 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) + { m_flat_tree.reserve(count); } + + /// @cond + template <class K1, class T1, class C1, class A1> + friend bool operator== (const flat_multimap<K1, T1, C1, A1>& x, + const flat_multimap<K1, T1, C1, A1>& y); + + template <class K1, class T1, class C1, class A1> + friend bool operator< (const flat_multimap<K1, T1, C1, A1>& x, + const flat_multimap<K1, T1, C1, A1>& y); + /// @endcond +}; + +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) + { 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) + { 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) + { 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) + { 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) + { 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) + { 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) + { x.swap(y); } + +}} + +/// @cond + +namespace boost { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class K, class T, class C, class A> +struct has_trivial_destructor_after_move< boost::container::flat_multimap<K, T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +} //namespace boost { + +/// @endcond + +#include <boost/container/detail/config_end.hpp> + +#endif /* BOOST_CONTAINER_FLAT_MAP_HPP */ diff --git a/src/third_party/boost/boost/container/flat_set.hpp b/src/third_party/boost/boost/container/flat_set.hpp new file mode 100644 index 00000000000..f36730972e3 --- /dev/null +++ b/src/third_party/boost/boost/container/flat_set.hpp @@ -0,0 +1,1265 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_FLAT_SET_HPP +#define BOOST_CONTAINER_FLAT_SET_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/container_fwd.hpp> +#include <utility> +#include <functional> +#include <memory> +#include <boost/container/detail/flat_tree.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/move/move.hpp> + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace boost { +namespace container { +#else +namespace boost { +namespace container { +#endif + +/// @cond +// Forward declarations of operators < and ==, needed for friend declaration. + +#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; + +template <class T, class Pred, class A> +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, + 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 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 +//! 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 +{ + /// @cond + private: + BOOST_COPYABLE_AND_MOVABLE(flat_set) + typedef container_detail::flat_tree<T, T, container_detail::identity<T>, Pred, A> tree_t; + tree_t m_flat_tree; // flat tree representing flat_set + typedef typename container_detail:: + move_const_ref_type<T>::type insert_const_ref_type; + /// @endcond + + public: + + // typedefs: + typedef typename tree_t::key_type key_type; + typedef typename tree_t::value_type value_type; + typedef typename tree_t::pointer pointer; + typedef typename tree_t::const_pointer const_pointer; + typedef typename tree_t::reference reference; + typedef typename tree_t::const_reference const_reference; + typedef typename tree_t::key_compare key_compare; + typedef typename tree_t::value_compare value_compare; + typedef typename tree_t::iterator iterator; + typedef typename tree_t::const_iterator const_iterator; + typedef typename tree_t::reverse_iterator reverse_iterator; + typedef typename tree_t::const_reverse_iterator const_reverse_iterator; + typedef typename tree_t::size_type size_type; + typedef typename tree_t::difference_type difference_type; + 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>Complexity</b>: Constant. + explicit flat_set() + : m_flat_tree() + {} + + //! <b>Effects</b>: Constructs an empty flat_map 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 + //! allocator, and inserts elements from the range [first ,last ). + //! + //! <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, + const Pred& comp = Pred(), + const allocator_type& a = allocator_type()) + : 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 + //! 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> + 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) + {} + + //! <b>Effects</b>: Copy constructs a map. + //! + //! <b>Complexity</b>: Linear in x.size(). + flat_set(const flat_set<T,Pred,A>& 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>Postcondition</b>: x is emptied. + flat_set(BOOST_RV_REF(flat_set) mx) + : m_flat_tree(boost::move(mx.m_flat_tree)) + {} + + //! <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) + { m_flat_tree = x.m_flat_tree; return *this; } + + //! <b>Effects</b>: Makes *this a copy of x. + //! + //! <b>Complexity</b>: Linear in x.size(). + flat_set<T,Pred,A>& 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 + { 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 + { 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 + { return m_flat_tree.get_allocator(); } + + 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() + { 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 + { 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 + { 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() + { 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 + { 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 + { return m_flat_tree.cend(); } + + //! <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(); } + + //! <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(); } + + //! <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(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! 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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + { 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 + { 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 + { return m_flat_tree.max_size(); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + //! with key equivalent to the key of x. + //! + //! <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 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. + 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) + std::pair<iterator, bool> insert(T &x) + { return this->insert(const_cast<const T &>(x)); } + + template<class U> + std::pair<iterator, bool> insert(const U &u, typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(u); } + #endif + + //! <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 + //! 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 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. + 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 + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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) + { return priv_insert(p, x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert(const_iterator position, T &x) + { return this->insert(position, const_cast<const T &>(x)); } + + template<class U> + iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(position, u); } + #endif + + //! <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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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) + { 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 + //! 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) + //! search time plus N*size() insertion time. + //! + //! <b>Note</b>: If an element is inserted it might invalidate elements. + template <class InputIterator> + void insert(InputIterator first, InputIterator last) + { m_flat_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 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 + //! 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 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. + template <class... Args> + std::pair<iterator,bool> emplace(Args&&... args) + { 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 + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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. + template <class... Args> + iterator emplace_hint(const_iterator hint, Args&&... args) + { return m_flat_tree.emplace_hint_unique(hint, boost::forward<Args>(args)...); } + + #else //#ifdef 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, >) \ + std::pair<iterator,bool> emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_flat_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_flat_tree.emplace_hint_unique \ + (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! 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 m_flat_tree.erase(position); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: Logarithmic search time plus erasure time + //! linear to the elements with bigger keys. + 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). + //! + //! <b>Returns</b>: Returns last. + //! + //! <b>Complexity</b>: size()*N where N is the distance from first to last. + //! + //! <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 m_flat_tree.erase(first, last); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + void clear() + { m_flat_tree.clear(); } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + // with previous allocations. The size of the vector is unchanged + //! + //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { m_flat_tree.shrink_to_fit(); } + + //! <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) + { 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 + { 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 + { 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) + { 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 + { return 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) + { return 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 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 + { 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) + { 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 + { 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) + { m_flat_tree.reserve(count); } + + /// @cond + template <class K1, class C1, class A1> + friend bool operator== (const flat_set<K1,C1,A1>&, const flat_set<K1,C1,A1>&); + + template <class K1, class C1, class A1> + 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) + { return m_flat_tree.insert_unique(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) + { 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) + { 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) + { 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) + { 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) + { 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) + { 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) + { x.swap(y); } + +/// @cond + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class C, class A> +struct has_trivial_destructor_after_move<boost::container::flat_set<T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value &&has_trivial_destructor<C>::value; +}; +*/ +namespace container { + +// Forward declaration of operators < and ==, needed for friend declaration. + +#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; + +template <class T, class Pred, class A> +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, + 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, +//! 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 +//! 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 +{ + /// @cond + private: + BOOST_COPYABLE_AND_MOVABLE(flat_multiset) + typedef container_detail::flat_tree<T, T, container_detail::identity<T>, Pred, A> tree_t; + tree_t m_flat_tree; // flat tree representing flat_multiset + typedef typename container_detail:: + move_const_ref_type<T>::type insert_const_ref_type; + /// @endcond + + public: + // typedefs: + typedef typename tree_t::key_type key_type; + typedef typename tree_t::value_type value_type; + typedef typename tree_t::pointer pointer; + typedef typename tree_t::const_pointer const_pointer; + typedef typename tree_t::reference reference; + typedef typename tree_t::const_reference const_reference; + typedef typename tree_t::key_compare key_compare; + typedef typename tree_t::value_compare value_compare; + typedef typename tree_t::iterator iterator; + typedef typename tree_t::const_iterator const_iterator; + typedef typename tree_t::reverse_iterator reverse_iterator; + typedef typename tree_t::const_reverse_iterator const_reverse_iterator; + typedef typename tree_t::size_type size_type; + typedef typename tree_t::difference_type difference_type; + 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>Complexity</b>: Constant. + explicit flat_multiset() + : m_flat_tree() + {} + + explicit flat_multiset(const Pred& comp, + const allocator_type& a = allocator_type()) + : m_flat_tree(comp, a) {} + + template <class InputIterator> + flat_multiset(InputIterator first, InputIterator last, + const Pred& comp = Pred(), + const allocator_type& a = allocator_type()) + : 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 + //! 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> + 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) + {} + + flat_multiset(const flat_multiset<T,Pred,A>& x) + : m_flat_tree(x.m_flat_tree) {} + + flat_multiset(BOOST_RV_REF(flat_multiset) x) + : m_flat_tree(boost::move(x.m_flat_tree)) + {} + + flat_multiset<T,Pred,A>& 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) + { 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 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 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 m_flat_tree.get_allocator(); } + + 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() + { 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 + { 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 + { 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() + { 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 + { 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 + { return m_flat_tree.cend(); } + + //! <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(); } + + //! <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(); } + + //! <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(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! 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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + { 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 + { 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 + { return m_flat_tree.max_size(); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + void swap(flat_multiset& x) + { m_flat_tree.swap(x.m_flat_tree); } + + //! <b>Effects</b>: Inserts 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(insert_const_ref_type x) + { return priv_insert(x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert(T &x) + { return this->insert(const_cast<const T &>(x)); } + + template<class U> + iterator insert(const U &u, typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(u); } + #endif + + //! <b>Effects</b>: Inserts a new value_type 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) + { return m_flat_tree.insert_equal(boost::move(x)); } + + //! <b>Effects</b>: Inserts a copy of x in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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) + { return priv_insert(p, x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert(const_iterator position, T &x) + { return this->insert(position, const_cast<const T &>(x)); } + + template<class U> + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(position, u); } + #endif + + //! <b>Effects</b>: Inserts a new value move constructed from x in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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) + { return m_flat_tree.insert_equal(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) . + //! + //! <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(InputIterator first, InputIterator last) + { m_flat_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. + //! + //! <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. + template <class... Args> + iterator emplace(Args&&... args) + { return m_flat_tree.emplace_equal(boost::forward<Args>(args)...); } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted + //! 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. + template <class... Args> + iterator emplace_hint(const_iterator hint, Args&&... args) + { return m_flat_tree.emplace_hint_equal(hint, boost::forward<Args>(args)...); } + + #else //#ifdef 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, >) \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_flat_tree.emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_flat_tree.emplace_hint_equal \ + (hint BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! 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 m_flat_tree.erase(position); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: Logarithmic search time plus erasure time + //! linear to the elements with bigger keys. + 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). + //! + //! <b>Returns</b>: Returns last. + //! + //! <b>Complexity</b>: size()*N where N is the distance from first to last. + //! + //! <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 m_flat_tree.erase(first, last); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + void clear() + { m_flat_tree.clear(); } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + // with previous allocations. The size of the vector is unchanged + //! + //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { m_flat_tree.shrink_to_fit(); } + + //! <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) + { 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 + { 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 + { 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) + { 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 + { return 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) + { return 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 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 + { 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) + { 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 + { 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) + { m_flat_tree.reserve(count); } + + /// @cond + template <class K1, class C1, class A1> + friend bool operator== (const flat_multiset<K1,C1,A1>&, + const flat_multiset<K1,C1,A1>&); + template <class K1, class C1, class A1> + friend bool operator< (const flat_multiset<K1,C1,A1>&, + const flat_multiset<K1,C1,A1>&); + private: + iterator priv_insert(const T &x) + { return m_flat_tree.insert_equal(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) + { 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) + { 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) + { 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) + { 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) + { 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) +{ 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) + { x.swap(y); } + +/// @cond + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class C, class A> +struct has_trivial_destructor_after_move<boost::container::flat_multiset<T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +namespace container { + +/// @endcond + +}} + +#include <boost/container/detail/config_end.hpp> + +#endif /* BOOST_CONTAINER_FLAT_SET_HPP */ diff --git a/src/third_party/boost/boost/container/list.hpp b/src/third_party/boost/boost/container/list.hpp new file mode 100644 index 00000000000..6df999bb513 --- /dev/null +++ b/src/third_party/boost/boost/container/list.hpp @@ -0,0 +1,1371 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_LIST_HPP_ +#define BOOST_CONTAINER_LIST_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/container_fwd.hpp> +#include <boost/container/detail/version_type.hpp> +#include <boost/move/move.hpp> +#include <boost/move/move_helpers.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/container/detail/utilities.hpp> +#include <boost/container/detail/algorithms.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/intrusive/list.hpp> +#include <boost/assert.hpp> +#include <boost/container/detail/node_alloc_holder.hpp> + +#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) +#else +//Preprocessor library to emulate perfect forwarding +#include <boost/container/detail/preprocessor.hpp> +#endif + +#include <stdexcept> +#include <iterator> +#include <utility> +#include <memory> +#include <functional> +#include <algorithm> +#include <stdexcept> + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace boost { +namespace container { +#else +namespace boost { +namespace container { +#endif + +/// @cond +namespace container_detail { + +template<class VoidPointer> +struct list_hook +{ + typedef typename container_detail::bi::make_list_base_hook + <container_detail::bi::void_pointer<VoidPointer>, container_detail::bi::link_mode<container_detail::bi::normal_link> >::type type; +}; + +template <class T, class VoidPointer> +struct list_node + : public list_hook<VoidPointer>::type +{ + + 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 + + T m_data; +}; + +template<class A> +struct intrusive_list_type +{ + typedef boost::container::allocator_traits<A> allocator_traits_type; + typedef typename allocator_traits_type::value_type value_type; + typedef typename boost::intrusive::pointer_traits + <typename allocator_traits_type::pointer>::template + rebind_pointer<void>::type + void_pointer; + typedef typename container_detail::list_node + <value_type, void_pointer> node_type; + typedef typename container_detail::bi::make_list + < node_type + , container_detail::bi::base_hook<typename list_hook<void_pointer>::type> + , container_detail::bi::constant_time_size<true> + , container_detail::bi::size_type + <typename allocator_traits_type::size_type> + >::type container_type; + typedef container_type type ; +}; + +} //namespace container_detail { +/// @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 +//! 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 + : protected container_detail::node_alloc_holder + <A, typename container_detail::intrusive_list_type<A>::type> +{ + /// @cond + typedef typename + container_detail::intrusive_list_type<A>::type Icont; + typedef list <T, A> ThisType; + typedef container_detail::node_alloc_holder<A, Icont> AllocHolder; + typedef typename AllocHolder::NodePtr NodePtr; + typedef typename AllocHolder::NodeAlloc NodeAlloc; + typedef typename AllocHolder::ValAlloc ValAlloc; + typedef typename AllocHolder::Node Node; + typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer; + typedef typename AllocHolder::allocator_v1 allocator_v1; + typedef typename AllocHolder::allocator_v2 allocator_v2; + typedef typename AllocHolder::alloc_version alloc_version; + typedef boost::container::allocator_traits<A> allocator_traits_type; + + class equal_to_value + { + typedef typename AllocHolder::value_type value_type; + const value_type &t_; + + public: + equal_to_value(const value_type &t) + : t_(t) + {} + + bool operator()(const value_type &t)const + { return t_ == t; } + }; + + template<class Pred> + struct ValueCompareToNodeCompare + : Pred + { + ValueCompareToNodeCompare(Pred pred) + : Pred(pred) + {} + + bool operator()(const Node &a, const Node &b) const + { return static_cast<const Pred&>(*this)(a.m_data, b.m_data); } + + bool operator()(const Node &a) const + { return static_cast<const Pred&>(*this)(a.m_data); } + }; + /// @endcond + + public: + //! The type of object, T, stored in the list + typedef T value_type; + //! Pointer to T + typedef typename allocator_traits_type::pointer pointer; + //! Const pointer to T + typedef typename allocator_traits_type::const_pointer const_pointer; + //! Reference to T + typedef typename allocator_traits_type::reference reference; + //! Const reference to T + typedef typename allocator_traits_type::const_reference const_reference; + //! An unsigned integral type + typedef typename allocator_traits_type::size_type size_type; + //! A signed integral type + typedef typename allocator_traits_type::difference_type difference_type; + //! The allocator type + typedef A allocator_type; + //! Non-standard extension: the stored allocator type + typedef NodeAlloc stored_allocator_type; + + /// @cond + private: + BOOST_COPYABLE_AND_MOVABLE(list) + typedef difference_type list_difference_type; + typedef pointer list_pointer; + typedef const_pointer list_const_pointer; + typedef reference list_reference; + typedef const_reference list_const_reference; + /// @endcond + + public: + //! Const iterator used to iterate through a list. + class const_iterator + /// @cond + : public std::iterator<std::bidirectional_iterator_tag, + value_type, list_difference_type, + list_const_pointer, list_const_reference> + { + + protected: + typename Icont::iterator m_it; + explicit const_iterator(typename Icont::iterator it) : m_it(it){} + void prot_incr() { ++m_it; } + void prot_decr() { --m_it; } + + private: + typename Icont::iterator get() + { return this->m_it; } + + public: + friend class list<T, A>; + typedef list_difference_type difference_type; + + //Constructors + const_iterator() + : m_it() + {} + + //Pointer like operators + const_reference operator*() const + { return m_it->m_data; } + + const_pointer operator->() const + { return const_pointer(&m_it->m_data); } + + //Increment / Decrement + const_iterator& operator++() + { prot_incr(); return *this; } + + const_iterator operator++(int) + { typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp); } + + const_iterator& operator--() + { prot_decr(); return *this; } + + const_iterator operator--(int) + { typename Icont::iterator tmp = m_it; --*this; return const_iterator(tmp); } + + //Comparison operators + bool operator== (const const_iterator& r) const + { return m_it == r.m_it; } + + bool operator!= (const const_iterator& r) const + { return m_it != r.m_it; } + } + /// @endcond + ; + + //! Iterator used to iterate through a list + class iterator + /// @cond + : public const_iterator + { + + private: + explicit iterator(typename Icont::iterator it) + : const_iterator(it) + {} + + typename Icont::iterator get() + { return this->m_it; } + + public: + friend class list<T, A>; + typedef list_pointer pointer; + typedef list_reference reference; + + //Constructors + iterator(){} + + //Pointer like operators + reference operator*() const { return this->m_it->m_data; } + pointer operator->() const { return pointer(&this->m_it->m_data); } + + //Increment / Decrement + 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; } + + iterator operator--(int) + { iterator tmp = *this; --*this; return tmp; } + }; + /// @endcond + + //! Iterator used to iterate backwards through a list. + typedef std::reverse_iterator<iterator> reverse_iterator; + //! 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() + : 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) + {} + + //! <b>Effects</b>: Constructs a list that will use a copy of allocator a + //! and inserts n copies of value. + //! + //! <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()) + { this->resize(n); } + + //! <b>Effects</b>: Constructs a list that will use a copy of allocator a + //! and inserts n copies of value. + //! + //! <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) + { this->insert(this->cbegin(), n, value); } + + //! <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) + : 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>: Constructs a list that will use a copy of allocator a + //! and inserts a copy of the range [first, last) in the list. + //! + //! <b>Throws</b>: If allocator_type's default constructor or copy constructor + //! throws or T's constructor taking an dereferenced InIt throws. + //! + //! <b>Complexity</b>: Linear to the range [first, last). + template <class InpIt> + list(InpIt first, InpIt last, const A &a = A()) + : AllocHolder(a) + { this->insert(this->cbegin(), first, last); } + + //! <b>Effects</b>: Destroys the list. All stored values are destroyed + //! and used memory is deallocated. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements. + ~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 + { return this->node_alloc(); } + + stored_allocator_type &get_stored_allocator() + { return this->node_alloc(); } + + //! <b>Effects</b>: Erases all the elements of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements in the list. + void clear() + { 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>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>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. + //! + //! <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. + //! + //! <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>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. + //! + //! <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 + { 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 + { 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 + { return AllocHolder::max_size(); } + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! <b>Effects</b>: Inserts a copy of x at the beginning of the list. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_front(const T &x); + + //! <b>Effects</b>: Constructs a new element in the beginning of the list + //! and moves the resources of mx to this new element. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_front(T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front) + #endif + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! <b>Effects</b>: Inserts a copy of x at the end of the list. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_back(const T &x); + + //! <b>Effects</b>: Constructs a new element in the end of the list + //! and moves the resources of mx to this new element. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_back(T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back) + #endif + + //! <b>Effects</b>: Removes the first element from the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Amortized constant time. + void pop_front() + { this->erase(this->cbegin()); } + + //! <b>Effects</b>: Removes the last element from the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Amortized constant time. + 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 + //! from the beginning of the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reference front() + { return *this->begin(); } + + //! <b>Requires</b>: !empty() + //! + //! <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 + { return *this->begin(); } + + //! <b>Requires</b>: !empty() + //! + //! <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() + { return *(--this->end()); } + + //! <b>Requires</b>: !empty() + //! + //! <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 + { return *(--this->end()); } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are copy constructed from x. + //! + //! <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) + { + const_iterator iend = this->cend(); + size_type len = this->size(); + + if(len > new_size){ + size_type to_erase = len - new_size; + while(to_erase--){ + --iend; + } + this->erase(iend, this->cend()); + } + else{ + this->priv_create_and_insert_nodes(iend, new_size - len, x); + } + } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are default constructed. + //! + //! <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_iterator iend = this->end(); + size_type len = this->size(); + + if(len > new_size){ + size_type to_erase = len - new_size; + const_iterator ifirst; + if(to_erase < len/2u){ + ifirst = iend; + while(to_erase--){ + --ifirst; + } + } + else{ + ifirst = this->begin(); + size_type to_skip = len - to_erase; + while(to_skip--){ + ++ifirst; + } + } + this->erase(ifirst, iend); + } + else{ + this->priv_create_and_insert_nodes(this->cend(), new_size - len); + } + } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + void swap(ThisType& x) + { AllocHolder::swap(x); } + + //! <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>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to the number of elements in x. + ThisType& operator=(BOOST_COPY_ASSIGN_REF(ThisType) x) + { + if (&x != this){ + NodeAlloc &this_alloc = this->node_alloc(); + const NodeAlloc &x_alloc = x.node_alloc(); + container_detail::bool_<allocator_traits_type:: + propagate_on_container_copy_assignment::value> flag; + if(flag && this_alloc != x_alloc){ + this->clear(); + } + this->AllocHolder::copy_assign_alloc(x); + this->assign(x.begin(), x.end()); + } + return *this; + } + + //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this. + //! + //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had + //! before the function. + //! + //! <b>Throws</b>: If allocator_type's copy constructor throws. + //! + //! <b>Complexity</b>: Constant. + ThisType& operator=(BOOST_RV_REF(ThisType) x) + { + if (&x != this){ + NodeAlloc &this_alloc = this->node_alloc(); + NodeAlloc &x_alloc = x.node_alloc(); + //If allocators are equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy and swap pointers + this->clear(); + this->icont() = boost::move(x.icont()); + //Move allocator if needed + this->AllocHolder::move_assign_alloc(x); + } + //If unequal allocators, then do a one by one move + else{ + typedef typename std::iterator_traits<iterator>::iterator_category ItCat; + this->assign( boost::make_move_iterator(x.begin()) + , boost::make_move_iterator(x.end())); + } + } + return *this; + } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts n copies of x before p. + //! + //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to n. + void insert(const_iterator p, size_type n, const T& x) + { this->priv_create_and_insert_nodes(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. + //! + //! <b>Throws</b>: If memory allocation throws, T's constructor from a + //! dereferenced InpIt throws. + //! + //! <b>Complexity</b>: Linear to std::distance [first, last). + template <class InpIt> + 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; + this->priv_insert_dispatch(p, first, last, Result()); + } + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of x before position. + //! + //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + iterator insert(const_iterator position, const T &x); + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a new element before position with mx's resources. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Amortized constant time. + iterator insert(const_iterator position, T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator) + #endif + + #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)... in the end of the list. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's in-place constructor throws. + //! + //! <b>Complexity</b>: Constant + template <class... Args> + void emplace_back(Args&&... args) + { + this->emplace(this->cend(), boost::forward<Args>(args)...); + } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... in the beginning of the list. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's in-place constructor throws. + //! + //! <b>Complexity</b>: Constant + template <class... Args> + void emplace_front(Args&&... args) + { + this->emplace(this->cbegin(), boost::forward<Args>(args)...); + } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... before p. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's in-place constructor throws. + //! + //! <b>Complexity</b>: Constant + template <class... Args> + iterator emplace(const_iterator p, Args&&... args) + { + NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...)); + return iterator(this->icont().insert(p.get(), *pnode)); + } + + #else //#ifdef 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, >) \ + void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + this->emplace(this->cend() \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + this->emplace(this->cbegin() \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace(const_iterator p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + NodePtr pnode (AllocHolder::create_node \ + (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + return iterator(this->icont().insert(p.get(), *pnode)); \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Erases the element at p p. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Amortized constant time. + 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. + //! + //! <b>Effects</b>: Erases the elements pointed by [first, last). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the distance between first and last. + iterator erase(const_iterator first, const_iterator last) + { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); } + + //! <b>Effects</b>: Assigns the n copies of val to *this. + //! + //! <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) + { this->priv_fill_assign(n, val); } + + //! <b>Effects</b>: Assigns the the range [first, last) to *this. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's constructor from dereferencing InpIt throws. + //! + //! <b>Complexity</b>: Linear to n. + template <class InpIt> + 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; + this->priv_assign_dispatch(first, last, Result()); + } + + //! <b>Requires</b>: p must point to an element contained + //! by the list. x != *this + //! + //! <b>Effects</b>: Transfers all the elements of 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) BOOST_CONTAINER_NOEXCEPT + { + BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x); + this->icont().splice(p.get(), x.icont()); + } + + //! <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, + //! 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. + //! + //! <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 + { + BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x); + this->icont().splice(p.get(), x.icont(), i.get()); + } + + //! <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, + //! 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 + { + BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x); + this->icont().splice(p.get(), x.icont(), first.get(), last.get()); + } + + //! <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, + //! 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 + { + BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x); + this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n); + } + + //! <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(); } + + //! <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) + { remove_if(equal_to_value(value)); } + + //! <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> + 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 + //! 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 + //! 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> + void unique(BinaryPredicate binary_pred) + { + typedef ValueCompareToNodeCompare<BinaryPredicate> Predicate; + this->icont().unique_and_dispose(Predicate(binary_pred), Destroyer(this->node_alloc())); + } + + //! <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. + //! + //! <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) + { this->merge(x, value_less()); } + + //! <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. + //! + //! <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. + //! + //! <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) + { + if((NodeAlloc&)*this == (NodeAlloc&)x){ + this->icont().merge(x.icont(), + ValueCompareToNodeCompare<StrictWeakOrdering>(comp)); + } + else{ + throw std::runtime_error("list::merge called with unequal allocators"); + } + } + + //! <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>. + //! 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> + void sort(StrictWeakOrdering comp) + { + // nothing if the list has length 0 or 1. + if (this->size() < 2) + return; + this->icont().sort(ValueCompareToNodeCompare<StrictWeakOrdering>(comp)); + } + + /// @cond + private: + + 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) + { + NodePtr tmp = AllocHolder::create_node(boost::move(x)); + return iterator(this->icont().insert(p.get(), *tmp)); + } + + 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) + { this->insert(this->cbegin(), x); } + + void priv_push_front (BOOST_RV_REF(T) x) + { this->insert(this->cbegin(), boost::move(x)); } + + //Iterator range version + template<class InpIterator> + void priv_create_and_insert_nodes + (const_iterator pos, InpIterator beg, InpIterator end) + { + typedef typename std::iterator_traits<InpIterator>::iterator_category ItCat; + priv_create_and_insert_nodes(pos, beg, end, alloc_version(), ItCat()); + } + + template<class InpIterator> + void priv_create_and_insert_nodes + (const_iterator pos, InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag) + { + for (; beg != end; ++beg){ + this->icont().insert(pos.get(), *this->create_node_from_it(beg)); + } + } + + template<class InpIterator> + void priv_create_and_insert_nodes + (const_iterator pos, InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag) + { //Just forward to the default one + priv_create_and_insert_nodes(pos, beg, end, allocator_v1(), std::input_iterator_tag()); + } + + class insertion_functor; + friend class insertion_functor; + + class insertion_functor + { + Icont &icont_; + typename Icont::const_iterator pos_; + + public: + insertion_functor(Icont &icont, typename Icont::const_iterator pos) + : icont_(icont), pos_(pos) + {} + + void operator()(Node &n) + { this->icont_.insert(pos_, n); } + }; + + + template<class FwdIterator> + void priv_create_and_insert_nodes + (const_iterator pos, FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag) + { + if(beg != end){ + //Optimized allocation and construction + this->allocate_many_and_construct + (beg, std::distance(beg, end), insertion_functor(this->icont(), pos.get())); + } + } + + //Default constructed version + void priv_create_and_insert_nodes(const_iterator pos, size_type n) + { + typedef default_construct_iterator<value_type, difference_type> default_iterator; + this->priv_create_and_insert_nodes(pos, default_iterator(n), default_iterator()); + } + + //Copy constructed version + void priv_create_and_insert_nodes(const_iterator pos, size_type n, const T& x) + { + typedef constant_iterator<value_type, difference_type> cvalue_iterator; + this->priv_create_and_insert_nodes(pos, cvalue_iterator(x, n), cvalue_iterator()); + } + + //Dispatch to detect iterator range or integer overloads + template <class InputIter> + void priv_insert_dispatch(const_iterator p, + InputIter first, InputIter last, + container_detail::false_) + { 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_) + { this->insert(p, (size_type)n, x); } + + void priv_fill_assign(size_type n, const T& val) + { + iterator i = this->begin(), iend = this->end(); + + for ( ; i != iend && n > 0; ++i, --n) + *i = val; + if (n > 0){ + this->priv_create_and_insert_nodes(this->cend(), n, val); + } + else{ + this->erase(i, cend()); + } + } + + template <class Integer> + void priv_assign_dispatch(Integer n, Integer val, container_detail::true_) + { this->priv_fill_assign((size_type) n, (T) val); } + + template <class InputIter> + void priv_assign_dispatch(InputIter first2, InputIter last2, container_detail::false_) + { + iterator first1 = this->begin(); + iterator last1 = this->end(); + for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) + *first1 = *first2; + if (first2 == last2) + this->erase(first1, last1); + else{ + this->priv_create_and_insert_nodes(last1, first2, last2); + } + } + + //Functors for member algorithm defaults + struct value_less + { + bool operator()(const value_type &a, const value_type &b) const + { return a < b; } + }; + + struct value_equal + { + bool operator()(const value_type &a, const value_type &b) const + { return a == b; } + }; + /// @endcond + +}; + +template <class T, class A> +inline bool operator==(const list<T,A>& x, const list<T,A>& y) +{ + if(x.size() != y.size()){ + return false; + } + typedef typename list<T,A>::const_iterator const_iterator; + const_iterator end1 = x.end(); + + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; +} + +template <class T, class A> +inline bool operator<(const list<T,A>& x, + const list<T,A>& y) +{ + return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +template <class T, class A> +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) +{ + return y < x; +} + +template <class T, class A> +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) +{ + return !(x < y); +} + +template <class T, class A> +inline void swap(list<T, A>& x, list<T, A>& y) +{ + x.swap(y); +} + +/// @cond + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class A> +struct has_trivial_destructor_after_move<boost::container::list<T, A> > +{ + static const bool value = has_trivial_destructor<A>::value; +}; +*/ +namespace container { + +/// @endcond + +}} + +#include <boost/container/detail/config_end.hpp> + +#endif // BOOST_CONTAINER_LIST_HPP_ diff --git a/src/third_party/boost/boost/container/map.hpp b/src/third_party/boost/boost/container/map.hpp new file mode 100644 index 00000000000..8f7ecd42b37 --- /dev/null +++ b/src/third_party/boost/boost/container/map.hpp @@ -0,0 +1,1317 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_MAP_HPP +#define BOOST_CONTAINER_MAP_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/container_fwd.hpp> +#include <utility> +#include <functional> +#include <memory> +#include <stdexcept> +#include <boost/container/detail/tree.hpp> +#include <boost/container/detail/value_init.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/utilities.hpp> +#include <boost/container/detail/pair.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <boost/move/move.hpp> +#include <boost/move/move_helpers.hpp> +#include <boost/static_assert.hpp> +#include <boost/container/detail/value_init.hpp> + + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace boost { +namespace container { +#else +namespace boost { +namespace container { +#endif + +/// @cond +// Forward declarations of operators == and <, needed for friend declarations. +template <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); + +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); +/// @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 +//! 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 +//! 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>). +//! +//! A is the allocator to allocate the value_types +//! (e.g. <i>allocator< std::pair<const Key, T> > </i>). +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +template <class Key, class T, class Pred = std::less< std::pair< const Key, T> >, class A = std::allocator<T> > +#else +template <class Key, class T, class Pred, class A> +#endif +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, + A> tree_t; + tree_t m_tree; // red-black tree representing map + + /// @endcond + + public: + + // typedefs: + typedef typename tree_t::key_type key_type; + typedef typename tree_t::value_type value_type; + typedef typename tree_t::pointer pointer; + typedef typename tree_t::const_pointer const_pointer; + typedef typename tree_t::reference reference; + typedef typename tree_t::const_reference const_reference; + typedef T mapped_type; + typedef Pred key_compare; + typedef typename tree_t::iterator iterator; + typedef typename tree_t::const_iterator const_iterator; + typedef typename tree_t::reverse_iterator reverse_iterator; + typedef typename tree_t::const_reverse_iterator const_reverse_iterator; + typedef typename tree_t::size_type size_type; + typedef typename tree_t::difference_type difference_type; + typedef typename tree_t::allocator_type allocator_type; + typedef typename tree_t::stored_allocator_type stored_allocator_type; + typedef std::pair<key_type, mapped_type> nonconst_value_type; + typedef container_detail::pair + <key_type, mapped_type> nonconst_impl_value_type; + + /// @cond + class value_compare_impl + : public Pred, + public std::binary_function<value_type, value_type, bool> + { + friend class map<Key,T,Pred,A>; + protected : + value_compare_impl(const Pred &c) : Pred(c) {} + public: + bool operator()(const value_type& x, const value_type& y) const { + return Pred::operator()(x.first, y.first); + } + }; + /// @endcond + typedef value_compare_impl value_compare; + + //! <b>Effects</b>: Default constructs an empty map. + //! + //! <b>Complexity</b>: Constant. + map() + : 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)); + } + + //! <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()) + : 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)); + } + + //! <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 + //! 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) + { + //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>: 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) + { + //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>: Copy constructs a map. + //! + //! <b>Complexity</b>: Linear in x.size(). + map(const map<Key,T,Pred,A>& 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)); + } + + //! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources. + //! + //! <b>Complexity</b>: Construct. + //! + //! <b>Postcondition</b>: x is emptied. + 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)); + } + + //! <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 + { 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 + { 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 + { return m_tree.get_allocator(); } + + 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() + { 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 + { 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() + { 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 m_tree.end(); } + + //! <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(); } + + //! <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(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reverse_iterator rend() + { return m_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 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 + { 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 + { 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 + { return m_tree.max_size(); } + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! 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 + //! 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 + BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, priv_subscript) + #endif + + //! Returns: A reference to the element whose key is equivalent to x. + //! Throws: An exception object of type out_of_range if no such element is present. + //! Complexity: logarithmic. + T& at(const key_type& k) + { + iterator i = this->find(k); + if(i == this->end()){ + throw std::out_of_range("key not found"); + } + return i->second; + } + + //! Returns: A reference to the element whose key is equivalent to x. + //! Throws: An exception object of type out_of_range if no such element is present. + //! Complexity: logarithmic. + const T& at(const key_type& k) const + { + const_iterator i = this->find(k); + if(i == this->end()){ + throw std::out_of_range("key not found"); + } + return i->second; + } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + //! with key equivalent to the key of x. + //! + //! <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) + { return m_tree.insert_unique(x); } + + //! <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 + //! 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) + { 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 + //! 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) + { 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 + //! 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) + { return m_tree.insert_unique(boost::move(x)); } + + //! <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 + //! 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) + { 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 + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + 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 + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + 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 + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + iterator insert(iterator position, BOOST_RV_REF(nonconst_impl_value_type) x) + { return m_tree.insert_unique(position, boost::move(x)); } + + //! <b>Effects</b>: Inserts a copy of x in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. + //! + //! <b>Complexity</b>: Logarithmic. + iterator insert(iterator position, const nonconst_value_type& x) + { return m_tree.insert_unique(position, 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. + //! + //! <b>Complexity</b>: Logarithmic. + iterator insert(iterator position, BOOST_RV_REF(value_type) x) + { return m_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 + //! 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) + { 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 + //! 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 + //! 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 in general, but amortized constant if t + //! is inserted right before p. + template <class... Args> + std::pair<iterator,bool> emplace(Args&&... args) + { 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 + //! 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>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + template <class... Args> + iterator emplace_hint(const_iterator hint, Args&&... args) + { return m_tree.emplace_hint_unique(hint, boost::forward<Args>(args)...); } + + #else //#ifdef 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, >) \ + std::pair<iterator,bool> emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_hint_unique(hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! returns end(). + //! + //! <b>Complexity</b>: Amortized constant time + iterator erase(const_iterator position) + { return m_tree.erase(position); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: log(size()) + count(k) + size_type erase(const key_type& x) + { return m_tree.erase(x); } + + //! <b>Effects</b>: Erases all the elements in the range [first, last). + //! + //! <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) + { return m_tree.erase(first, last); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + 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) + { 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 + { 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 + { 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) + { 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 + { 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) + { 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 + { 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) + { 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 + { return m_tree.equal_range(x); } + + /// @cond + template <class K1, class T1, class C1, class A1> + friend bool operator== (const map<K1, T1, C1, A1>&, + const map<K1, T1, C1, A1>&); + template <class K1, class T1, class C1, class A1> + friend bool operator< (const map<K1, T1, C1, A1>&, + const map<K1, T1, C1, A1>&); + private: + mapped_type& priv_subscript(const key_type &k) + { + //we can optimize this + iterator i = lower_bound(k); + // i->first is greater than or equivalent to k. + if (i == end() || key_comp()(k, (*i).first)){ + container_detail::value_init<mapped_type> m; + nonconst_impl_value_type val(k, boost::move(m.m_t)); + i = insert(i, boost::move(val)); + } + return (*i).second; + } + + mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk) + { + key_type &k = mk; + //we can optimize this + iterator i = lower_bound(k); + // i->first is greater than or equivalent to k. + if (i == end() || key_comp()(k, (*i).first)){ + container_detail::value_init<mapped_type> m; + nonconst_impl_value_type val(boost::move(k), boost::move(m.m_t)); + i = insert(i, boost::move(val)); + } + return (*i).second; + } + + /// @endcond +}; + +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) + { 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) + { 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) + { 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) + { 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) + { 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) + { 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) + { x.swap(y); } + +/// @cond + +// 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, + 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, + const multimap<Key,T,Pred,A>& y); + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class K, class T, class C, class A> +struct has_trivial_destructor_after_move<boost::container::map<K, T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +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 +//! 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>. +//! +//! Pred is the ordering function for Keys (e.g. <i>std::less<Key></i>). +//! +//! A is the allocator to allocate the value_types +//!(e.g. <i>allocator< std::pair<<b>const</b> Key, T> ></i>). +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +template <class Key, class T, class Pred = std::less< std::pair< const Key, T> >, class A = std::allocator<T> > +#else +template <class Key, class T, class Pred, class A> +#endif +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, + A> tree_t; + tree_t m_tree; // red-black tree representing map + typedef typename container_detail:: + move_const_ref_type<Key>::type insert_key_const_ref_type; + /// @endcond + + public: + + // typedefs: + typedef typename tree_t::key_type key_type; + typedef typename tree_t::value_type value_type; + typedef typename tree_t::pointer pointer; + typedef typename tree_t::const_pointer const_pointer; + typedef typename tree_t::reference reference; + typedef typename tree_t::const_reference const_reference; + typedef T mapped_type; + typedef Pred key_compare; + typedef typename tree_t::iterator iterator; + typedef typename tree_t::const_iterator const_iterator; + typedef typename tree_t::reverse_iterator reverse_iterator; + typedef typename tree_t::const_reverse_iterator const_reverse_iterator; + typedef typename tree_t::size_type size_type; + typedef typename tree_t::difference_type difference_type; + typedef typename tree_t::allocator_type allocator_type; + typedef typename tree_t::stored_allocator_type stored_allocator_type; + typedef std::pair<key_type, mapped_type> nonconst_value_type; + typedef container_detail::pair + <key_type, mapped_type> nonconst_impl_value_type; + + /// @cond + class value_compare_impl + : public Pred, + public std::binary_function<value_type, value_type, bool> + { + friend class multimap<Key,T,Pred,A>; + protected : + value_compare_impl(const Pred &c) : Pred(c) {} + public: + bool operator()(const value_type& x, const value_type& y) const { + return Pred::operator()(x.first, y.first); + } + }; + /// @endcond + typedef value_compare_impl value_compare; + + //! <b>Effects</b>: Default constructs an empty multimap. + //! + //! <b>Complexity</b>: Constant. + multimap() + : 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)); + } + + //! <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)); + } + + //! <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 + //! 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) + { + //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>: 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) + {} + + + //! <b>Effects</b>: Copy constructs a multimap. + //! + //! <b>Complexity</b>: Linear in x.size(). + multimap(const multimap<Key,T,Pred,A>& 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)); + } + + //! <b>Effects</b>: Move constructs a multimap. Constructs *this using x's resources. + //! + //! <b>Complexity</b>: Construct. + //! + //! <b>Postcondition</b>: x is emptied. + 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)); + } + + //! <b>Effects</b>: Makes *this a copy of x. + //! + //! <b>Complexity</b>: Linear in x.size(). + 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) + { 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 + { 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 + { 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 + { return m_tree.get_allocator(); } + + 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() + { 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 + { 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() + { 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 m_tree.end(); } + + //! <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(); } + + //! <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(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reverse_iterator rend() + { return m_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 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 + { 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 + { 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 + { return m_tree.max_size(); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + void swap(multimap& x) + { m_tree.swap(x.m_tree); } + + //! <b>Effects</b>: Inserts x and returns the iterator pointing to the + //! newly inserted element. + //! + //! <b>Complexity</b>: Logarithmic. + 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>Complexity</b>: Logarithmic. + 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>Complexity</b>: Logarithmic. + 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>Complexity</b>: Logarithmic. + 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. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + iterator insert(iterator position, const value_type& x) + { return m_tree.insert_equal(position, x); } + + //! <b>Effects</b>: Inserts a new value constructed from x in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + iterator insert(iterator position, const nonconst_value_type& x) + { return m_tree.insert_equal(position, x); } + + //! <b>Effects</b>: Inserts a new value move constructed from x in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + iterator insert(iterator position, BOOST_RV_REF(nonconst_value_type) x) + { return m_tree.insert_equal(position, boost::move(x)); } + + //! <b>Effects</b>: Inserts a new value move constructed from x in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + iterator insert(iterator position, BOOST_RV_REF(nonconst_impl_value_type) x) + { return m_tree.insert_equal(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) . + //! + //! <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) + { 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)... in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + template <class... Args> + iterator emplace(Args&&... args) + { return m_tree.emplace_equal(boost::forward<Args>(args)...); } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... in the container. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + template <class... Args> + iterator emplace_hint(const_iterator hint, Args&&... args) + { return m_tree.emplace_hint_equal(hint, boost::forward<Args>(args)...); } + + #else //#ifdef 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, >) \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_hint_equal(hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! returns end(). + //! + //! <b>Complexity</b>: Amortized constant time + iterator erase(const_iterator position) + { return m_tree.erase(position); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: log(size()) + count(k) + size_type erase(const key_type& x) + { return m_tree.erase(x); } + + //! <b>Effects</b>: Erases all the elements in the range [first, last). + //! + //! <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) + { return m_tree.erase(first, last); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + 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) + { 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 + { 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 + { 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) + {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 + { 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) + { 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) + { 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 + { 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 + { return m_tree.equal_range(x); } + + /// @cond + template <class K1, class T1, class C1, class A1> + friend bool operator== (const multimap<K1, T1, C1, A1>& x, + const multimap<K1, T1, C1, A1>& y); + + template <class K1, class T1, class C1, class A1> + friend bool operator< (const multimap<K1, T1, C1, A1>& x, + const multimap<K1, T1, C1, A1>& y); + /// @endcond +}; + +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) +{ 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) +{ 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) +{ 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) +{ 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) +{ 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) +{ 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) +{ x.swap(y); } + +/// @cond + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class K, class T, class C, class A> +struct has_trivial_destructor_after_move<boost::container::multimap<K, T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +namespace container { + +/// @endcond + +}} + +#include <boost/container/detail/config_end.hpp> + +#endif /* BOOST_CONTAINER_MAP_HPP */ + diff --git a/src/third_party/boost/boost/container/set.hpp b/src/third_party/boost/boost/container/set.hpp new file mode 100644 index 00000000000..b25e7013fc7 --- /dev/null +++ b/src/third_party/boost/boost/container/set.hpp @@ -0,0 +1,1176 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_SET_HPP +#define BOOST_CONTAINER_SET_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/container_fwd.hpp> + +#include <utility> +#include <functional> +#include <memory> + +#include <boost/move/move.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/tree.hpp> +#include <boost/move/move.hpp> +#ifndef BOOST_CONTAINER_PERFECT_FORWARDING +#include <boost/container/detail/preprocessor.hpp> +#endif + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace boost { +namespace container { +#else +namespace boost { +namespace container { +#endif + +/// @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, + const set<T,Pred,A>& y); + +template <class T, class Pred, class A> +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 +//! 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 +{ + /// @cond + private: + BOOST_COPYABLE_AND_MOVABLE(set) + 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:: + move_const_ref_type<T>::type insert_const_ref_type; + /// @endcond + + public: + + // typedefs: + typedef typename tree_t::key_type key_type; + typedef typename tree_t::value_type value_type; + typedef typename tree_t::pointer pointer; + typedef typename tree_t::const_pointer const_pointer; + typedef typename tree_t::reference reference; + typedef typename tree_t::const_reference const_reference; + typedef Pred key_compare; + typedef Pred value_compare; + typedef typename tree_t::iterator iterator; + typedef typename tree_t::const_iterator const_iterator; + typedef typename tree_t::reverse_iterator reverse_iterator; + typedef typename tree_t::const_reverse_iterator const_reverse_iterator; + typedef typename tree_t::size_type size_type; + typedef typename tree_t::difference_type difference_type; + typedef typename tree_t::allocator_type allocator_type; + 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 + //! 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 + //! allocator, and inserts elements from the range [first ,last ). + //! + //! <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) + {} + + //! <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) + {} + + //! <b>Effects</b>: Copy constructs a set. + //! + //! <b>Complexity</b>: Linear in x.size(). + 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>Postcondition</b>: x is emptied. + set(BOOST_RV_REF(set) x) + : m_tree(boost::move(x.m_tree)) + {} + + //! <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 + { 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 + { 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 + { return m_tree.get_allocator(); } + + 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() + { 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 + { 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() + { 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 m_tree.end(); } + + //! <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(); } + + //! <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(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reverse_iterator rend() + { return m_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 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 + { 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 + { return m_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 m_tree.crbegin(); } + + //! <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 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 + { 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 + { 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 + { return m_tree.max_size(); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + //! with key equivalent to the key of x. + //! + //! <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) + { return priv_insert(x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + std::pair<iterator,bool> insert(T &x) + { return this->insert(const_cast<const T &>(x)); } + + template<class U> + std::pair<iterator,bool> insert(const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(u); } + #endif + + //! <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 + //! 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) + { 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 + //! 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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <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) + { return priv_insert(p, x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert(const_iterator position, T &x) + { return this->insert(position, const_cast<const T &>(x)); } + + template<class U> + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(position, u); } + #endif + + //! <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. + //! + //! <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) + { 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 + //! 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) + { 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 + //! 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 + //! 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>Throws</b>: If memory allocation throws or + //! T's in-place constructor throws. + //! + //! <b>Complexity</b>: Logarithmic. + template <class... Args> + std::pair<iterator,bool> emplace(Args&&... args) + { 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 + //! no element in the container with equivalent value. + //! p is a hint pointing to where the insert + //! should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. + //! + //! <b>Complexity</b>: Logarithmic. + template <class... Args> + iterator emplace_hint(const_iterator hint, Args&&... args) + { return m_tree.emplace_hint_unique(hint, boost::forward<Args>(args)...); } + + #else //#ifdef 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, >) \ + std::pair<iterator,bool> emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_hint_unique(hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! returns end(). + //! + //! <b>Complexity</b>: Amortized constant time + iterator erase(const_iterator p) + { return m_tree.erase(p); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: log(size()) + count(k) + size_type erase(const key_type& x) + { return m_tree.erase(x); } + + //! <b>Effects</b>: Erases all the elements in the range [first, last). + //! + //! <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) + { return m_tree.erase(first, last); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + 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) + { 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 + { 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 + { 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) + { 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 + { 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) + { 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 + { 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) + { 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 + { return m_tree.equal_range(x); } + + /// @cond + template <class K1, class C1, class A1> + friend bool operator== (const set<K1,C1,A1>&, const set<K1,C1,A1>&); + + template <class K1, class C1, class A1> + friend bool operator< (const set<K1,C1,A1>&, const set<K1,C1,A1>&); + + private: + std::pair<iterator, bool> priv_insert(const T &x) + { return m_tree.insert_unique(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) +{ 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) +{ 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) +{ 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) +{ 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) +{ 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) +{ return !(x < y); } + +template <class T, class Pred, class A> +inline void swap(set<T,Pred,A>& x, set<T,Pred,A>& y) +{ x.swap(y); } + +/// @cond + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class C, class A> +struct has_trivial_destructor_after_move<boost::container::set<T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +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, + const multiset<T,Pred,A>& y); + +template <class T, class Pred, class A> +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 +//! 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 +//! 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 +{ + /// @cond + private: + BOOST_COPYABLE_AND_MOVABLE(multiset) + 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:: + move_const_ref_type<T>::type insert_const_ref_type; + /// @endcond + + public: + + // typedefs: + typedef typename tree_t::key_type key_type; + typedef typename tree_t::value_type value_type; + typedef typename tree_t::pointer pointer; + typedef typename tree_t::const_pointer const_pointer; + typedef typename tree_t::reference reference; + typedef typename tree_t::const_reference const_reference; + typedef Pred key_compare; + typedef Pred value_compare; + typedef typename tree_t::iterator iterator; + typedef typename tree_t::const_iterator const_iterator; + typedef typename tree_t::reverse_iterator reverse_iterator; + typedef typename tree_t::const_reverse_iterator const_reverse_iterator; + typedef typename tree_t::size_type size_type; + typedef typename tree_t::difference_type difference_type; + typedef typename tree_t::allocator_type allocator_type; + typedef typename tree_t::stored_allocator_type stored_allocator_type; + + //! <b>Effects</b>: Constructs an empty multiset using the specified comparison + //! object and allocator. + //! + //! <b>Complexity</b>: Constant. + multiset() + : m_tree() + {} + + //! <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()) + : m_tree(comp, a) + {} + + //! <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 + //! 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) + {} + + //! <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) + {} + + //! <b>Effects</b>: Copy constructs a multiset. + //! + //! <b>Complexity</b>: Linear in x.size(). + 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>Postcondition</b>: x is emptied. + multiset(BOOST_RV_REF(multiset) x) + : m_tree(boost::move(x.m_tree)) + {} + + //! <b>Effects</b>: Makes *this a copy of x. + //! + //! <b>Complexity</b>: Linear in x.size(). + 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) + { 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 + { 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 + { 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 + { return m_tree.get_allocator(); } + + 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() + { 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 + { 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() + { 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 m_tree.end(); } + + //! <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(); } + + //! <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(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reverse_iterator rend() + { return m_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 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 + { 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 + { return m_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 m_tree.crbegin(); } + + //! <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 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 + { 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 + { 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 + { return m_tree.max_size(); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + void swap(multiset& x) + { m_tree.swap(x.m_tree); } + + //! <b>Effects</b>: Inserts x and returns the iterator pointing to the + //! newly inserted element. + //! + //! <b>Complexity</b>: Logarithmic. + iterator insert(insert_const_ref_type x) + { return priv_insert(x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert(T &x) + { return this->insert(const_cast<const T &>(x)); } + + template<class U> + iterator insert(const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(u); } + #endif + + //! <b>Effects</b>: Inserts a copy of x in the container. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + 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. + //! p is a hint pointing to where the insert should start to search. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <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) + { return priv_insert(p, x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert(const_iterator position, T &x) + { return this->insert(position, const_cast<const T &>(x)); } + + template<class U> + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_insert(position, u); } + #endif + + //! <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. + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <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) + { return m_tree.insert_equal(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) . + //! + //! <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) + { 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. + //! + //! <b>Complexity</b>: Logarithmic. + template <class... Args> + iterator emplace(Args&&... args) + { return m_tree.emplace_equal(boost::forward<Args>(args)...); } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... + //! + //! <b>Returns</b>: An iterator pointing to the element with key equivalent + //! to the key of x. + //! + //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t + //! is inserted right before p. + template <class... Args> + iterator emplace_hint(const_iterator hint, Args&&... args) + { return m_tree.emplace_hint_equal(hint, boost::forward<Args>(args)...); } + + #else //#ifdef 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, >) \ + iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_hint(const_iterator hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { return m_tree.emplace_hint_equal(hint \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <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, + //! returns end(). + //! + //! <b>Complexity</b>: Amortized constant time + iterator erase(const_iterator p) + { return m_tree.erase(p); } + + //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. + //! + //! <b>Returns</b>: Returns the number of erased elements. + //! + //! <b>Complexity</b>: log(size()) + count(k) + size_type erase(const key_type& x) + { return m_tree.erase(x); } + + //! <b>Effects</b>: Erases all the elements in the range [first, last). + //! + //! <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) + { return m_tree.erase(first, last); } + + //! <b>Effects</b>: erase(a.begin(),a.end()). + //! + //! <b>Postcondition</b>: size() == 0. + //! + //! <b>Complexity</b>: linear in size(). + 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) + { 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 + { 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 + { 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) + { 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 + { 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) + { 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 + { 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) + { 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 + { return m_tree.equal_range(x); } + + /// @cond + template <class K1, class C1, class A1> + friend bool operator== (const multiset<K1,C1,A1>&, + const multiset<K1,C1,A1>&); + template <class K1, class C1, class A1> + friend bool operator< (const multiset<K1,C1,A1>&, + const multiset<K1,C1,A1>&); + private: + iterator priv_insert(const T &x) + { return m_tree.insert_equal(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) +{ 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) +{ 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) +{ 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) +{ 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) +{ 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) +{ return !(x < y); } + +template <class T, class Pred, class A> +inline void swap(multiset<T,Pred,A>& x, multiset<T,Pred,A>& y) +{ x.swap(y); } + +/// @cond + +} //namespace container { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class C, class A> +struct has_trivial_destructor_after_move<boost::container::multiset<T, C, A> > +{ + static const bool value = has_trivial_destructor<A>::value && has_trivial_destructor<C>::value; +}; +*/ +namespace container { + +/// @endcond + +}} + +#include <boost/container/detail/config_end.hpp> + +#endif /* BOOST_CONTAINER_SET_HPP */ + diff --git a/src/third_party/boost/boost/container/slist.hpp b/src/third_party/boost/boost/container/slist.hpp new file mode 100644 index 00000000000..1cdcdf1046a --- /dev/null +++ b/src/third_party/boost/boost/container/slist.hpp @@ -0,0 +1,1549 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2004-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_SLIST_HPP +#define BOOST_CONTAINER_SLIST_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/container_fwd.hpp> +#include <boost/move/move.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/container/detail/utilities.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/detail/no_exceptions_support.hpp> +#include <boost/container/detail/node_alloc_holder.hpp> +#include <boost/intrusive/slist.hpp> + + +#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) +//Preprocessor library to emulate perfect forwarding +#else +#include <boost/container/detail/preprocessor.hpp> +#endif + +#include <stdexcept> +#include <iterator> +#include <utility> +#include <memory> +#include <functional> +#include <algorithm> + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace boost { +namespace container { +#else +namespace boost { +namespace container { +#endif + +/// @cond + +namespace container_detail { + +template<class VoidPointer> +struct slist_hook +{ + typedef typename container_detail::bi::make_slist_base_hook + <container_detail::bi::void_pointer<VoidPointer>, container_detail::bi::link_mode<container_detail::bi::normal_link> >::type type; +}; + +template <class T, class VoidPointer> +struct slist_node + : public slist_hook<VoidPointer>::type +{ + + 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 + + T m_data; +}; + +template<class A> +struct intrusive_slist_type +{ + typedef boost::container::allocator_traits<A> allocator_traits_type; + typedef typename allocator_traits_type::value_type value_type; + typedef typename boost::intrusive::pointer_traits + <typename allocator_traits_type::pointer>::template + rebind_pointer<void>::type + void_pointer; + typedef typename container_detail::slist_node + <value_type, void_pointer> node_type; + + typedef typename container_detail::bi::make_slist + <node_type + ,container_detail::bi::base_hook<typename slist_hook<void_pointer>::type> + ,container_detail::bi::constant_time_size<true> + , container_detail::bi::size_type + <typename allocator_traits_type::size_type> + >::type container_type; + typedef container_type type ; +}; + +} //namespace container_detail { + +/// @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 +//! 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: +//! 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, +//! 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 + : 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 + container_detail::intrusive_slist_type<A>::type Icont; + typedef container_detail::node_alloc_holder<A, Icont> AllocHolder; + typedef typename AllocHolder::NodePtr NodePtr; + typedef slist <T, A> ThisType; + typedef typename AllocHolder::NodeAlloc NodeAlloc; + typedef typename AllocHolder::ValAlloc ValAlloc; + typedef typename AllocHolder::Node Node; + typedef container_detail::allocator_destroyer<NodeAlloc> Destroyer; + typedef typename AllocHolder::allocator_v1 allocator_v1; + typedef typename AllocHolder::allocator_v2 allocator_v2; + typedef typename AllocHolder::alloc_version alloc_version; + typedef boost::container::allocator_traits<A> allocator_traits_type; + + class equal_to_value + { + typedef typename AllocHolder::value_type value_type; + const value_type &t_; + + public: + equal_to_value(const value_type &t) + : t_(t) + {} + + bool operator()(const value_type &t)const + { return t_ == t; } + }; + + template<class Pred> + struct ValueCompareToNodeCompare + : Pred + { + ValueCompareToNodeCompare(Pred pred) + : Pred(pred) + {} + + bool operator()(const Node &a, const Node &b) const + { return static_cast<const Pred&>(*this)(a.m_data, b.m_data); } + + bool operator()(const Node &a) const + { return static_cast<const Pred&>(*this)(a.m_data); } + }; + /// @endcond + public: + //! The type of object, T, stored in the list + typedef T value_type; + //! Pointer to T + typedef typename allocator_traits_type::pointer pointer; + //! Const pointer to T + typedef typename allocator_traits_type::const_pointer const_pointer; + //! Reference to T + typedef typename allocator_traits_type::reference reference; + //! Const reference to T + typedef typename allocator_traits_type::const_reference const_reference; + //! An unsigned integral type + typedef typename allocator_traits_type::size_type size_type; + //! A signed integral type + typedef typename allocator_traits_type::difference_type difference_type; + //! The allocator type + typedef A allocator_type; + //! Non-standard extension: the stored allocator type + typedef NodeAlloc stored_allocator_type; + + /// @cond + private: + BOOST_COPYABLE_AND_MOVABLE(slist) + typedef difference_type list_difference_type; + typedef pointer list_pointer; + typedef const_pointer list_const_pointer; + typedef reference list_reference; + typedef const_reference list_const_reference; + /// @endcond + + public: + + //! Const iterator used to iterate through a list. + class const_iterator + /// @cond + : public std::iterator<std::forward_iterator_tag, + value_type, list_difference_type, + list_const_pointer, list_const_reference> + { + + protected: + typename Icont::iterator m_it; + explicit const_iterator(typename Icont::iterator it) : m_it(it){} + void prot_incr(){ ++m_it; } + + private: + typename Icont::iterator get() + { return this->m_it; } + + public: + friend class slist<T, A>; + typedef list_difference_type difference_type; + + //Constructors + const_iterator() + : m_it() + {} + + //Pointer like operators + const_reference operator*() const + { return m_it->m_data; } + + const_pointer operator->() const + { return const_pointer(&m_it->m_data); } + + //Increment / Decrement + const_iterator& operator++() + { prot_incr(); return *this; } + + const_iterator operator++(int) + { typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp); } + + //Comparison operators + bool operator== (const const_iterator& r) const + { return m_it == r.m_it; } + + bool operator!= (const const_iterator& r) const + { return m_it != r.m_it; } + } + /// @endcond + ; + + //! Iterator used to iterate through a list + class iterator + /// @cond + : public const_iterator + { + + private: + explicit iterator(typename Icont::iterator it) + : const_iterator(it) + {} + + typename Icont::iterator get() + { return this->m_it; } + + public: + friend class slist<T, A>; + typedef list_pointer pointer; + typedef list_reference reference; + + //Constructors + iterator(){} + + //Pointer like operators + reference operator*() const { return this->m_it->m_data; } + pointer operator->() const { return pointer(&this->m_it->m_data); } + + //Increment / Decrement + iterator& operator++() + { this->prot_incr(); return *this; } + + iterator operator++(int) + { typename Icont::iterator tmp = this->m_it; ++*this; return iterator(tmp); } + } + /// @endcond + ; + + 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) + {} + + explicit slist(size_type n) + : AllocHolder(allocator_type()) + { this->resize(n); } + + //! <b>Effects</b>: Constructs a list that will use a copy of allocator a + //! and inserts n copies of value. + //! + //! <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) + { this->priv_create_and_insert_nodes(this->before_begin(), n, x); } + + //! <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. + //! + //! <b>Throws</b>: If allocator_type's default constructor or copy constructor + //! throws or T's constructor taking an dereferenced InIt throws. + //! + //! <b>Complexity</b>: Linear to the range [first, last). + template <class InpIt> + slist(InpIt first, InpIt last, + 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) + : 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>: 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>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to the number of elements in x. + slist& operator= (BOOST_COPY_ASSIGN_REF(slist) x) + { + if (&x != this){ + NodeAlloc &this_alloc = this->node_alloc(); + const NodeAlloc &x_alloc = x.node_alloc(); + container_detail::bool_<allocator_traits_type:: + propagate_on_container_copy_assignment::value> flag; + if(flag && this_alloc != x_alloc){ + this->clear(); + } + this->AllocHolder::copy_assign_alloc(x); + this->assign(x.begin(), x.end()); + } + return *this; + } + + //! <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>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to the number of elements in x. + slist& operator= (BOOST_RV_REF(slist) x) + { + if (&x != this){ + NodeAlloc &this_alloc = this->node_alloc(); + NodeAlloc &x_alloc = x.node_alloc(); + //If allocators a re equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy and swap pointers + this->clear(); + this->icont() = boost::move(x.icont()); + //Move allocator if needed + this->AllocHolder::move_assign_alloc(x); + } + //If unequal allocators, then do a one by one move + else{ + typedef typename std::iterator_traits<iterator>::iterator_category ItCat; + this->assign( boost::make_move_iterator(x.begin()) + , boost::make_move_iterator(x.end())); + } + } + return *this; + } + + //! <b>Effects</b>: Destroys the list. All stored values are destroyed + //! and used memory is deallocated. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements. + ~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 + { return this->node_alloc(); } + + stored_allocator_type &get_stored_allocator() + { return this->node_alloc(); } + + public: + + //! <b>Effects</b>: Assigns the n copies of val to *this. + //! + //! <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) + { this->priv_fill_assign(n, val); } + + //! <b>Effects</b>: Assigns the range [first, last) to *this. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's constructor from dereferencing InpIt throws. + //! + //! <b>Complexity</b>: Linear to n. + template <class InpIt> + 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; + this->priv_assign_dispatch(first, last, Result()); + } + + //! <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 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() + { return iterator(end()); } + + //! <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 + { 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 + //! 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 + { 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 + { 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 + { return !this->size(); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements on *this and x. + void swap(slist& x) + { AllocHolder::swap(x); } + + //! <b>Requires</b>: !empty() + //! + //! <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() + { return *this->begin(); } + + //! <b>Requires</b>: !empty() + //! + //! <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 + { return *this->begin(); } + + //! <b>Effects</b>: Inserts a copy of t in the beginning of the list. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_front(insert_const_ref_type x) + { return priv_push_front(x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + void push_front(T &x) { push_front(const_cast<const T &>(x)); } + + template<class U> + void push_front(const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_push_front(u); } + #endif + + //! <b>Effects</b>: Constructs a new element in the beginning of the list + //! and moves the resources of t to this new element. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_front(BOOST_RV_REF(T) x) + { this->icont().push_front(*this->create_node(boost::move(x))); } + + //! <b>Effects</b>: Removes the first element from the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Amortized constant time. + 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>Throws</b>: Nothing. + //! + //! <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>Throws</b>: Nothing. + //! + //! <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. + //! + //! <b>Effects</b>: Inserts a copy of the value after the p pointed + //! 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) + { return this->priv_insert_after(prev_pos, x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert_after(const_iterator position, T &x) + { return this->insert_after(position, const_cast<const T &>(x)); } + + template<class U> + iterator insert_after( const_iterator position, const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return this->priv_insert_after(position, u); } + #endif + + //! <b>Requires</b>: prev_pos must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts a move constructed copy object from the value after the + //! 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) + { 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. + //! + //! <b>Effects</b>: Inserts n copies of x after prev_pos. + //! + //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to n. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references of + //! previous values. + void insert_after(const_iterator prev_pos, size_type n, const value_type& x) + { 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) + //! 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) + { + const bool aux_boolean = container_detail::is_convertible<InIter, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_insert_after_range_dispatch(prev_pos, first, last, Result()); + } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of x before p. + //! + //! <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) + { return this->priv_insert(position, x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + iterator insert(const_iterator position, T &x) + { return this->insert(position, const_cast<const T &>(x)); } + + template<class U> + iterator insert( const_iterator position, const U &u + , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return this->priv_insert(position, u); } + #endif + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a new element before p with mx's resources. + //! + //! <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) + { return this->insert_after(previous(p), boost::move(x)); } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts n copies of x before p. + //! + //! <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) + { 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. + //! + //! <b>Throws</b>: If memory allocation throws, T's constructor from a + //! dereferenced InpIt throws. + //! + //! <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) + { return this->insert_after(previous(p), 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)... in the front of the list + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + template <class... Args> + void emplace_front(Args&&... args) + { this->emplace_after(this->cbefore_begin(), boost::forward<Args>(args)...); } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... before p + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's in-place constructor throws. + //! + //! <b>Complexity</b>: Linear to the elements before p + template <class... Args> + iterator emplace(const_iterator p, Args&&... args) + { return this->emplace_after(this->previous(p), boost::forward<Args>(args)...); } + + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... after prev + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's in-place constructor throws. + //! + //! <b>Complexity</b>: Constant + template <class... Args> + iterator emplace_after(const_iterator prev, Args&&... args) + { + NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...)); + return iterator(this->icont().insert_after(prev.get(), *pnode)); + } + + #else //#ifdef 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, >) \ + void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + this->emplace(this->cbegin() \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace (const_iterator p \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + return this->emplace_after \ + (this->previous(p) \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace_after(const_iterator prev \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + NodePtr pnode (AllocHolder::create_node \ + (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ + return iterator(this->icont().insert_after(prev.get(), *pnode)); \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <b>Effects</b>: Erases the element after the element pointed by prev_pos + //! of 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>: Constant. + //! + //! <b>Note</b>: Does not invalidate iterators or references to non erased elements. + iterator erase_after(const_iterator prev_pos) + { + return iterator(this->icont().erase_after_and_dispose(prev_pos.get(), Destroyer(this->node_alloc()))); + } + + //! <b>Effects</b>: Erases the range (before_first, last) from + //! 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) + { + return iterator(this->icont().erase_after_and_dispose(before_first.get(), last.get(), Destroyer(this->node_alloc()))); + } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Erases the element at p p. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements before 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. + //! + //! <b>Effects</b>: Erases the elements pointed by [first, last). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the distance between first and last plus + //! linear to the elements before first. + iterator erase(const_iterator first, const_iterator last) + { return iterator(this->erase_after(previous(first), last)); } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are copy constructed from x. + //! + //! <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) + { + typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next; + while (++(cur_next = cur) != end_n && new_size > 0){ + --new_size; + cur = cur_next; + } + 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); + } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are default constructed. + //! + //! <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) + { + 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; + } + if (cur_next != end_n){ + this->erase_after(const_iterator(cur), const_iterator(end_n)); + } + else{ + this->priv_create_and_insert_nodes(const_iterator(cur), new_size - len); + } + } + + //! <b>Effects</b>: Erases all the elements of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements in the list. + void clear() + { this->icont().clear_and_dispose(Destroyer(this->node_alloc())); } + + //! <b>Requires</b>: p must point to an element contained + //! by the list. x != *this + //! + //! <b>Effects</b>: Transfers all the elements of list x to this list, after 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 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) + { + if((NodeAlloc&)*this == (NodeAlloc&)x){ + this->icont().splice_after(prev_pos.get(), x.icont()); + } + else{ + throw std::runtime_error("slist::splice called with unequal allocators"); + } + } + + //! <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, + //! after the element pointed by prev_pos. + //! 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) + { + if((NodeAlloc&)*this == (NodeAlloc&)x){ + this->icont().splice_after(prev_pos.get(), x.icont(), prev.get()); + } + else{ + throw std::runtime_error("slist::splice called with unequal allocators"); + } + } + + //! <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, + const_iterator before_first, const_iterator before_last) + { + if((NodeAlloc&)*this == (NodeAlloc&)x){ + this->icont().splice_after + (prev_pos.get(), x.icont(), before_first.get(), before_last.get()); + } + else{ + throw std::runtime_error("slist::splice called with unequal allocators"); + } + } + + //! <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. + //! 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, + const_iterator before_first, const_iterator before_last, + size_type n) + { + if((NodeAlloc&)*this == (NodeAlloc&)x){ + this->icont().splice_after + (prev_pos.get(), x.icont(), before_first.get(), before_last.get(), n); + } + else{ + throw std::runtime_error("slist::splice called with unequal allocators"); + } + } + + //! <b>Requires</b>: p must point to an element contained + //! by the list. x != *this + //! + //! <b>Effects</b>: Transfers all the elements of 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), 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) + { 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, + //! 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. + //! + //! <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) + { this->splice_after(previous(p), x, i); } + + //! <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, + //! 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>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(); } + + //! <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) + { remove_if(equal_to_value(value)); } + + //! <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> + 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 + //! 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 + //! 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> + 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>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. + //! + //! <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) + { this->merge(x, value_less()); } + + //! <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. + //! + //! <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. + //! + //! <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) + { + if((NodeAlloc&)*this == (NodeAlloc&)x){ + this->icont().merge(x.icont(), + ValueCompareToNodeCompare<StrictWeakOrdering>(comp)); + } + else{ + throw std::runtime_error("list::merge called with unequal allocators"); + } + } + + //! <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>. + //! 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> + void sort(StrictWeakOrdering comp) + { + // nothing if the slist has length 0 or 1. + if (this->size() < 2) + return; + this->icont().sort(ValueCompareToNodeCompare<StrictWeakOrdering>(comp)); + } + + /// @cond + private: + 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) + { return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(x))); } + + void priv_push_front(const value_type &x) + { this->icont().push_front(*this->create_node(x)); } + + //Iterator range version + template<class InpIterator> + void priv_create_and_insert_nodes + (const_iterator prev, InpIterator beg, InpIterator end) + { + typedef typename std::iterator_traits<InpIterator>::iterator_category ItCat; + priv_create_and_insert_nodes(prev, beg, end, alloc_version(), ItCat()); + } + + template<class InpIterator> + void priv_create_and_insert_nodes + (const_iterator prev, InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag) + { + for (; beg != end; ++beg){ + this->icont().insert_after(prev.get(), *this->create_node_from_it(beg)); + ++prev; + } + } + + template<class InpIterator> + void priv_create_and_insert_nodes + (const_iterator prev, InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag) + { //Just forward to the default one + priv_create_and_insert_nodes(prev, beg, end, allocator_v1(), std::input_iterator_tag()); + } + + class insertion_functor; + friend class insertion_functor; + + class insertion_functor + { + Icont &icont_; + typename Icont::const_iterator prev_; + + public: + insertion_functor(Icont &icont, typename Icont::const_iterator prev) + : icont_(icont), prev_(prev) + {} + + void operator()(Node &n) + { prev_ = this->icont_.insert_after(prev_, n); } + }; + + template<class FwdIterator> + void priv_create_and_insert_nodes + (const_iterator prev, FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag) + { + //Optimized allocation and construction + this->allocate_many_and_construct + (beg, std::distance(beg, end), insertion_functor(this->icont(), prev.get())); + } + + //Default constructed version + void priv_create_and_insert_nodes(const_iterator prev, size_type n) + { + typedef default_construct_iterator<value_type, difference_type> default_iterator; + this->priv_create_and_insert_nodes(prev, default_iterator(n), default_iterator()); + } + + //Copy constructed version + void priv_create_and_insert_nodes(const_iterator prev, size_type n, const T& x) + { + typedef constant_iterator<value_type, difference_type> cvalue_iterator; + this->priv_create_and_insert_nodes(prev, cvalue_iterator(x, n), cvalue_iterator()); + } + + //Dispatch to detect iterator range or integer overloads + template <class InputIter> + void priv_insert_dispatch(const_iterator prev, + InputIter first, InputIter last, + container_detail::false_) + { 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_) + { this->priv_create_and_insert_nodes(prev, (size_type)n, x); } + + void priv_fill_assign(size_type n, const T& val) + { + iterator end_n(this->end()); + iterator prev(this->before_begin()); + iterator node(this->begin()); + for ( ; node != end_n && n > 0 ; --n){ + *node = val; + prev = node; + ++node; + } + if (n > 0) + this->priv_create_and_insert_nodes(prev, n, val); + else + this->erase_after(prev, end_n); + } + + template <class Int> + void priv_assign_dispatch(Int n, Int val, container_detail::true_) + { this->priv_fill_assign((size_type) n, (T)val); } + + template <class InpIt> + void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_) + { + iterator end_n(this->end()); + iterator prev(this->before_begin()); + iterator node(this->begin()); + while (node != end_n && first != last){ + *node = *first; + prev = node; + ++node; + ++first; + } + if (first != last) + this->priv_create_and_insert_nodes(prev, first, last); + else + this->erase_after(prev, end_n); + } + + template <class Int> + 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_) + { this->priv_create_and_insert_nodes(prev_pos, first, last); } + + //Functors for member algorithm defaults + struct value_less + { + bool operator()(const value_type &a, const value_type &b) const + { return a < b; } + }; + + struct value_equal + { + bool operator()(const value_type &a, const value_type &b) const + { return a == b; } + }; + + struct value_equal_to_this + { + explicit value_equal_to_this(const value_type &ref) + : m_ref(ref){} + + bool operator()(const value_type &val) const + { return m_ref == val; } + + const value_type &m_ref; + }; + /// @endcond +}; + +template <class T, class A> +inline bool +operator==(const slist<T,A>& x, const slist<T,A>& y) +{ + if(x.size() != y.size()){ + return false; + } + typedef typename slist<T,A>::const_iterator const_iterator; + const_iterator end1 = x.end(); + + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + while (i1 != end1 && *i1 == *i2){ + ++i1; + ++i2; + } + return i1 == end1; +} + +template <class T, class A> +inline bool +operator<(const slist<T,A>& sL1, const slist<T,A>& sL2) +{ + return std::lexicographical_compare + (sL1.begin(), sL1.end(), sL2.begin(), sL2.end()); +} + +template <class T, class A> +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) + { return sL2 < sL1; } + +template <class T, class A> +inline bool +operator<=(const slist<T,A>& sL1, const slist<T,A>& sL2) + { return !(sL2 < sL1); } + +template <class T, class A> +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) + { x.swap(y); } + +}} + +/// @cond + +namespace boost { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class A> +struct has_trivial_destructor_after_move<boost::container::slist<T, A> > +{ + static const bool value = has_trivial_destructor<A>::value; +}; +*/ +namespace container { + +/// @endcond + +}} //namespace boost{ namespace container { + +// Specialization of insert_iterator so that insertions will be constant +// time rather than linear time. + +///@cond + +//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> > +{ + protected: + typedef boost::container::slist<T, A> Container; + Container* container; + typename Container::iterator iter; + public: + typedef Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + 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) + { + iter = container->insert_after(iter, value); + return *this; + } + insert_iterator<Container>& operator*(){ return *this; } + insert_iterator<Container>& operator++(){ return *this; } + insert_iterator<Container>& operator++(int){ return *this; } +}; + +} //namespace std; + +///@endcond + +#include <boost/container/detail/config_end.hpp> + +#endif /* BOOST_CONTAINER_SLIST_HPP */ diff --git a/src/third_party/boost/boost/container/stable_vector.hpp b/src/third_party/boost/boost/container/stable_vector.hpp new file mode 100644 index 00000000000..851b5f26e8c --- /dev/null +++ b/src/third_party/boost/boost/container/stable_vector.hpp @@ -0,0 +1,1818 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-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. +// +////////////////////////////////////////////////////////////////////////////// +// Stable vector. +// +// Copyright 2008 Joaquin M Lopez Munoz. +// 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) +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_STABLE_VECTOR_HPP +#define BOOST_CONTAINER_STABLE_VECTOR_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/container_fwd.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/not.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/container/detail/version_type.hpp> +#include <boost/container/detail/multiallocation_chain.hpp> +#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/intrusive/pointer_traits.hpp> + +#include <algorithm> +#include <stdexcept> +#include <memory> + +///@cond + +#include <boost/container/vector.hpp> + +//#define STABLE_VECTOR_ENABLE_INVARIANT_CHECKING + +#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING) +#include <boost/assert.hpp> +#endif + +///@endcond + +namespace boost { +namespace container { + +///@cond + +namespace stable_vector_detail{ + +template<class SmartPtr> +struct smart_ptr_type +{ + typedef typename SmartPtr::value_type value_type; + typedef value_type *pointer; + static pointer get (const SmartPtr &smartptr) + { return smartptr.get();} +}; + +template<class T> +struct smart_ptr_type<T*> +{ + typedef T value_type; + typedef value_type *pointer; + static pointer get (pointer ptr) + { 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 +{ + public: + clear_on_destroy(C &c) + : c_(c), do_clear_(true) + {} + + void release() + { do_clear_ = false; } + + ~clear_on_destroy() + { + if(do_clear_){ + c_.clear(); + c_.clear_pool(); + } + } + + private: + clear_on_destroy(const clear_on_destroy &); + clear_on_destroy &operator=(const clear_on_destroy &); + C &c_; + bool do_clear_; +}; + +template<class VoidPtr> +struct node_type_base +{/* + node_type_base(VoidPtr p) + : up(p) + {}*/ + node_type_base() + {} + void set_pointer(VoidPtr p) + { up = p; } + + VoidPtr up; +}; + +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); } + + T value; +}; + +template<typename T, typename Reference, typename Pointer> +class iterator + : public std::iterator< std::random_access_iterator_tag + , T + , typename boost::intrusive:: + pointer_traits<Pointer>::difference_type + , Pointer + , Reference> +{ + typedef typename boost::intrusive:: + pointer_traits<Pointer>::template + rebind_pointer<void>::type void_ptr; + typedef typename boost::intrusive:: + pointer_traits<Pointer>::template + rebind_pointer<const void>::type const_void_ptr; + typedef node_type<void_ptr, T> node_type_t; + typedef typename boost::intrusive:: + pointer_traits<Pointer>::template + rebind_pointer<node_type_t>::type node_type_ptr_t; + typedef typename boost::intrusive:: + pointer_traits<Pointer>::template + rebind_pointer<const node_type_t>::type const_node_type_ptr_t; + typedef typename boost::intrusive:: + pointer_traits<Pointer>::template + rebind_pointer<void_ptr>::type void_ptr_ptr; + + friend class iterator<T, const T, typename boost::intrusive::pointer_traits<Pointer>::template rebind_pointer<T>::type>; + + public: + typedef std::random_access_iterator_tag iterator_category; + typedef T value_type; + typedef typename boost::intrusive:: + pointer_traits<Pointer>::difference_type difference_type; + typedef Pointer pointer; + typedef Reference reference; + + iterator() + {} + + explicit iterator(node_type_ptr_t pn) + : pn(pn) + {} + + 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))); + } + + 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))); + } + + 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))); + } + + reference dereference() const + { return pn->value; } + bool equal(const iterator& x) const + { return pn==x.pn; } + void increment() + { pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+1)); } + void decrement() + { pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)-1)); } + void advance(difference_type n) + { pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+n)); } + difference_type distance_to(const iterator& x)const + { return void_ptr_ptr_cast(x.pn->up) - void_ptr_ptr_cast(pn->up); } + + public: + //Pointer like operators + reference operator*() const { return this->dereference(); } + pointer operator->() const { return pointer(&this->dereference()); } + + //Increment / Decrement + iterator& operator++() + { this->increment(); return *this; } + + iterator operator++(int) + { iterator tmp(*this); ++*this; return iterator(tmp); } + + iterator& operator--() + { this->decrement(); return *this; } + + iterator operator--(int) + { iterator tmp(*this); --*this; return iterator(tmp); } + + reference operator[](difference_type off) const + { + iterator tmp(*this); + tmp += off; + return *tmp; + } + + iterator& operator+=(difference_type off) + { + pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+off)); + return *this; + } + + friend iterator operator+(const iterator &left, difference_type off) + { + iterator tmp(left); + tmp += off; + return tmp; + } + + friend iterator operator+(difference_type off, const iterator& right) + { + iterator tmp(right); + tmp += off; + return tmp; + } + + iterator& operator-=(difference_type off) + { *this += -off; return *this; } + + friend iterator operator-(const iterator &left, difference_type off) + { + iterator tmp(left); + tmp -= off; + return tmp; + } + + friend difference_type operator-(const iterator& left, const iterator& right) + { + return void_ptr_ptr_cast(left.pn->up) - void_ptr_ptr_cast(right.pn->up); + } + + //Comparison operators + friend bool operator== (const iterator& l, const iterator& r) + { return l.pn == r.pn; } + + friend bool operator!= (const iterator& l, const iterator& r) + { return l.pn != r.pn; } + + friend bool operator< (const iterator& l, const iterator& r) + { return void_ptr_ptr_cast(l.pn->up) < void_ptr_ptr_cast(r.pn->up); } + + friend bool operator<= (const iterator& l, const iterator& r) + { return void_ptr_ptr_cast(l.pn->up) <= void_ptr_ptr_cast(r.pn->up); } + + friend bool operator> (const iterator& l, const iterator& r) + { return void_ptr_ptr_cast(l.pn->up) > void_ptr_ptr_cast(r.pn->up); } + + friend bool operator>= (const iterator& l, const iterator& r) + { return void_ptr_ptr_cast(l.pn->up) >= void_ptr_ptr_cast(r.pn->up); } + + node_type_ptr_t pn; +}; + +template<class A, unsigned int Version> +struct select_multiallocation_chain +{ + typedef typename A::multiallocation_chain type; +}; + +template<class A> +struct select_multiallocation_chain<A, 1> +{ + typedef typename boost::intrusive::pointer_traits + <typename allocator_traits<A>::pointer>:: + template rebind_pointer<void>::type void_ptr; + typedef container_detail::basic_multiallocation_chain + <void_ptr> multialloc_cached_counted; + typedef boost::container::container_detail:: + transform_multiallocation_chain + < multialloc_cached_counted + , typename allocator_traits<A>::value_type> type; +}; + +} //namespace stable_vector_detail + +#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + +#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING) + +#define STABLE_VECTOR_CHECK_INVARIANT \ +invariant_checker BOOST_JOIN(check_invariant_,__LINE__)(*this); \ +BOOST_JOIN(check_invariant_,__LINE__).touch(); +#else + +#define STABLE_VECTOR_CHECK_INVARIANT + +#endif //#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING) + +#endif //#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + +/// @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. +//! +//!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. +//! +//!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. +//! +//!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 +template <class T, class A> +#endif +class stable_vector +{ + ///@cond + typedef allocator_traits<A> allocator_traits_type; + typedef typename container_detail:: + move_const_ref_type<T>::type insert_const_ref_type; + typedef typename boost::intrusive::pointer_traits + <typename allocator_traits_type::pointer>:: + template rebind_pointer<void>::type void_ptr; + typedef typename boost::intrusive::pointer_traits + <void_ptr>::template + rebind_pointer<const void>::type const_void_ptr; + typedef typename boost::intrusive::pointer_traits + <void_ptr>::template + rebind_pointer<void_ptr>::type void_ptr_ptr; + typedef typename boost::intrusive::pointer_traits + <void_ptr>::template + rebind_pointer<const void_ptr>::type const_void_ptr_ptr; + typedef stable_vector_detail::node_type + <void_ptr, T> node_type_t; + typedef typename boost::intrusive::pointer_traits + <void_ptr>::template + rebind_pointer<node_type_t>::type node_type_ptr_t; + typedef stable_vector_detail::node_type_base + <void_ptr> node_type_base_t; + typedef typename boost::intrusive::pointer_traits + <void_ptr>::template + rebind_pointer<node_type_base_t>::type node_type_base_ptr_t; + typedef ::boost::container::vector<void_ptr, + typename allocator_traits_type:: + template portable_rebind_alloc + <void_ptr>::type> impl_type; + typedef typename impl_type::iterator impl_iterator; + typedef typename impl_type::const_iterator const_impl_iterator; + + typedef ::boost::container::container_detail:: + integral_constant<unsigned, 1> allocator_v1; + typedef ::boost::container::container_detail:: + integral_constant<unsigned, 2> allocator_v2; + typedef ::boost::container::container_detail::integral_constant + <unsigned, boost::container::container_detail:: + version<A>::value> alloc_version; + typedef typename allocator_traits_type:: + template portable_rebind_alloc + <node_type_t>::type node_allocator_type; + + node_type_ptr_t allocate_one() + { return this->allocate_one(alloc_version()); } + + template<class AllocatorVersion> + node_type_ptr_t allocate_one(AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { return node_alloc().allocate(1); } + + template<class AllocatorVersion> + node_type_ptr_t allocate_one(AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { return node_alloc().allocate_one(); } + + void deallocate_one(node_type_ptr_t p) + { return this->deallocate_one(p, alloc_version()); } + + template<class AllocatorVersion> + void deallocate_one(node_type_ptr_t p, AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { node_alloc().deallocate(p, 1); } + + template<class AllocatorVersion> + void deallocate_one(node_type_ptr_t p, AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { node_alloc().deallocate_one(p); } + + friend class stable_vector_detail::clear_on_destroy<stable_vector>; + ///@endcond + public: + + + // types: + + typedef typename allocator_traits_type::reference reference; + typedef typename allocator_traits_type::const_reference const_reference; + typedef typename allocator_traits_type::pointer pointer; + typedef typename allocator_traits_type::const_pointer const_pointer; + typedef stable_vector_detail::iterator + <T,T&, pointer> iterator; + typedef stable_vector_detail::iterator + <T,const T&, const_pointer> const_iterator; + typedef typename impl_type::size_type size_type; + typedef typename iterator::difference_type difference_type; + typedef T value_type; + typedef A allocator_type; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + typedef node_allocator_type stored_allocator_type; + + ///@cond + private: + BOOST_COPYABLE_AND_MOVABLE(stable_vector) + static const size_type ExtraPointers = 3; + //This container stores metadata at the end of the void_ptr vector with additional 3 pointers: + // back() is impl.back() - ExtraPointers; + // end node index is impl.end()[-3] + // Node cache first is impl.end()[-2]; + // Node cache last is *impl.back(); + + typedef typename stable_vector_detail:: + select_multiallocation_chain + < node_allocator_type + , alloc_version::value + >::type multiallocation_chain; + ///@endcond + 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() + { + STABLE_VECTOR_CHECK_INVARIANT; + } + + //! <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) + : internal_data(al),impl(al) + { + STABLE_VECTOR_CHECK_INVARIANT; + } + + //! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a + //! and inserts n default contructed values. + //! + //! <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()) + { + stable_vector_detail::clear_on_destroy<stable_vector> cod(*this); + this->resize(n); + STABLE_VECTOR_CHECK_INVARIANT; + cod.release(); + } + + //! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a + //! and inserts n copies of value. + //! + //! <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()) + : internal_data(al),impl(al) + { + stable_vector_detail::clear_on_destroy<stable_vector> cod(*this); + this->insert(this->cbegin(), n, t); + STABLE_VECTOR_CHECK_INVARIANT; + cod.release(); + } + + //! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a + //! and inserts a copy of the range [first, last) in the stable_vector. + //! + //! <b>Throws</b>: If allocator_type's default constructor or copy constructor + //! throws or T's constructor taking an dereferenced InIt throws. + //! + //! <b>Complexity</b>: Linear to the range [first, last). + template <class InputIterator> + stable_vector(InputIterator first,InputIterator last,const A& al=A()) + : internal_data(al),impl(al) + { + stable_vector_detail::clear_on_destroy<stable_vector> cod(*this); + this->insert(this->cbegin(), first, last); + STABLE_VECTOR_CHECK_INVARIANT; + cod.release(); + } + + //! <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>:: + select_on_container_copy_construction(x.node_alloc())) + , impl(allocator_traits<allocator_type>:: + select_on_container_copy_construction(x.impl.get_stored_allocator())) + { + 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. 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)) + { + this->priv_swap_members(x); + } + + //! <b>Effects</b>: Destroys the stable_vector. All stored values are destroyed + //! and used memory is deallocated. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements. + ~stable_vector() + { + this->clear(); + 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>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to the number of elements in x. + stable_vector& operator=(BOOST_COPY_ASSIGN_REF(stable_vector) x) + { + STABLE_VECTOR_CHECK_INVARIANT; + if (&x != this){ + node_allocator_type &this_alloc = this->node_alloc(); + const node_allocator_type &x_alloc = x.node_alloc(); + container_detail::bool_<allocator_traits_type:: + propagate_on_container_copy_assignment::value> flag; + if(flag && this_alloc != x_alloc){ + this->clear(); + this->shrink_to_fit(); + } + container_detail::assign_alloc(this->node_alloc(), x.node_alloc(), flag); + container_detail::assign_alloc(this->impl.get_stored_allocator(), x.impl.get_stored_allocator(), flag); + this->assign(x.begin(), x.end()); + } + return *this; + } + + //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this. + //! + //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had + //! before the function. + //! + //! <b>Throws</b>: If allocator_type's copy constructor throws. + //! + //! <b>Complexity</b>: Linear. + stable_vector& operator=(BOOST_RV_REF(stable_vector) x) + { + if (&x != this){ + node_allocator_type &this_alloc = this->node_alloc(); + node_allocator_type &x_alloc = x.node_alloc(); + //If allocators are equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy objects but retain memory + this->clear(); + this->impl = boost::move(x.impl); + this->priv_swap_members(x); + //Move allocator if needed + container_detail::bool_<allocator_traits_type:: + propagate_on_container_move_assignment::value> flag; + container_detail::move_alloc(this->node_alloc(), x.node_alloc(), flag); + } + //If unequal allocators, then do a one by one move + else{ + typedef typename std::iterator_traits<iterator>::iterator_category ItCat; + this->assign( boost::make_move_iterator(x.begin()) + , boost::make_move_iterator(x.end())); + } + } + return *this; + } + + //! <b>Effects</b>: Assigns the the range [first, last) to *this. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's constructor from dereferencing InpIt throws. + //! + //! <b>Complexity</b>: Linear to n. + template<typename InputIterator> + void assign(InputIterator first,InputIterator last) + { + assign_dispatch(first, last, boost::is_integral<InputIterator>()); + } + + + //! <b>Effects</b>: Assigns the n copies of val to *this. + //! + //! <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& t) + { + typedef constant_iterator<value_type, difference_type> cvalue_iterator; + return assign_dispatch(cvalue_iterator(t, n), cvalue_iterator(), boost::mpl::false_()); + } + + //! <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();} + + //! <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>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>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. + //! + //! <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. + //! + //! <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>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. + //! + //! <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 + { + if(!impl.capacity()){ + return 0; + } + else{ + const size_type num_nodes = this->impl.size() + this->internal_data.pool_size; + const size_type num_buck = this->impl.capacity(); + return (num_nodes < num_buck) ? num_nodes : num_buck; + } + } + + //! <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; } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are copy constructed from x. + //! + //! <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 n, const T& t) + { + STABLE_VECTOR_CHECK_INVARIANT; + if(n > size()) + this->insert(this->cend(), n - this->size(), t); + else if(n < this->size()) + this->erase(this->cbegin() + n, this->cend()); + } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are default constructed. + //! + //! <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 n) + { + typedef default_construct_iterator<value_type, difference_type> default_iterator; + STABLE_VECTOR_CHECK_INVARIANT; + if(n > size()) + this->insert(this->cend(), default_iterator(n - this->size()), default_iterator()); + else if(n < this->size()) + this->erase(this->cbegin() + n, this->cend()); + } + + //! <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. + void reserve(size_type n) + { + STABLE_VECTOR_CHECK_INVARIANT; + if(n > this->max_size()) + throw std::bad_alloc(); + + size_type size = this->size(); + size_type old_capacity = this->capacity(); + if(n > old_capacity){ + this->initialize_end_node(n); + const void * old_ptr = &impl[0]; + impl.reserve(n + ExtraPointers); + bool realloced = &impl[0] != old_ptr; + //Fix the pointers for the newly allocated buffer + if(realloced){ + this->align_nodes(impl.begin(), impl.begin()+size+1); + } + //Now fill pool if data is not enough + if((n - size) > this->internal_data.pool_size){ + this->add_to_pool((n - size) - this->internal_data.pool_size); + } + } + } + + //! <b>Requires</b>: size() > n. + //! + //! <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 + //! 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 + //! 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()) + throw std::out_of_range("invalid subscript at stable_vector::at"); + return operator[](n); + } + + //! <b>Requires</b>: size() > n. + //! + //! <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()) + throw std::out_of_range("invalid subscript at stable_vector::at"); + return operator[](n); + } + + //! <b>Requires</b>: !empty() + //! + //! <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()); } + + //! <b>Requires</b>: !empty() + //! + //! <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()); } + + //! <b>Requires</b>: !empty() + //! + //! <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)); } + + //! <b>Requires</b>: !empty() + //! + //! <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)); } + + //! <b>Effects</b>: Inserts a copy of x at the end of the stable_vector. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_back(insert_const_ref_type x) + { return priv_push_back(x); } + + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + void push_back(T &x) { push_back(const_cast<const T &>(x)); } + + template<class U> + void push_back(const U &u, typename container_detail::enable_if_c + <container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return priv_push_back(u); } + #endif + + //! <b>Effects</b>: Constructs a new element in the end of the stable_vector + //! and moves the resources of mx to this new element. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Amortized constant time. + 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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + void pop_back() + { this->erase(this->end()-1); } + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of x before position. + //! + //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + 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) + iterator insert(const_iterator position, T &x) { return this->insert(position, const_cast<const T &>(x)); } + + template<class U> + iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c + <container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0) + { return this->priv_insert(position, u); } + #endif + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a new element before position with mx's resources. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + 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; + //Just call more general insert(pos, size, value) and return iterator + size_type pos_n = position - cbegin(); + this->insert(position + ,repeat_move_it(repeat_it(x, 1)) + ,repeat_move_it(repeat_it())); + return iterator(this->begin() + pos_n); + } + + //! <b>Requires</b>: pos must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert n copies of x before pos. + //! + //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to n. + void insert(const_iterator position, size_type n, const T& t) + { + STABLE_VECTOR_CHECK_INVARIANT; + this->insert_not_iter(position, n, t); + } + + //! <b>Requires</b>: pos must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of the [first, last) range before pos. + //! + //! <b>Throws</b>: If memory allocation throws, T's constructor from a + //! dereferenced InpIt throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to std::distance [first, last). + template <class InputIterator> + void insert(const_iterator position,InputIterator first, InputIterator last) + { + STABLE_VECTOR_CHECK_INVARIANT; + this->insert_iter(position,first,last, + boost::mpl::not_<boost::is_integral<InputIterator> >()); + } + + #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)... in the end of the stable_vector. + //! + //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + template<class ...Args> + void emplace_back(Args &&...args) + { + typedef emplace_functor<Args...> EmplaceFunctor; + typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator; + EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...); + this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator()); + } + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... before position + //! + //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + template<class ...Args> + iterator emplace(const_iterator position, Args && ...args) + { + //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; + EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...); + this->insert(position, EmplaceIterator(ef), EmplaceIterator()); + return iterator(this->begin() + pos_n); + } + + #else + + #define BOOST_PP_LOCAL_MACRO(n) \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + 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; \ + EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \ + BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \ + BOOST_PP_RPAREN_IF(n); \ + this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator()); \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace(const_iterator pos \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + 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; \ + EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \ + BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \ + BOOST_PP_RPAREN_IF(n); \ + size_type pos_n = pos - this->cbegin(); \ + this->insert(pos, EmplaceIterator(ef), EmplaceIterator()); \ + return iterator(this->begin() + pos_n); \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + + #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + + //! <b>Effects</b>: Erases the element at position pos. + //! + //! <b>Throws</b>: Nothing. + //! + //! <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) + { + STABLE_VECTOR_CHECK_INVARIANT; + difference_type d = position - this->cbegin(); + impl_iterator it = impl.begin() + d; + this->delete_node(*it); + it = impl.erase(it); + this->align_nodes(it, get_last_align()); + return this->begin()+d; + } + + //! <b>Effects</b>: Erases the elements pointed by [first, last). + //! + //! <b>Throws</b>: Nothing. + //! + //! <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) + { return priv_erase(first, last, alloc_version()); } + + //! <b>Effects</b>: Swaps the contents of *this and x. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + void swap(stable_vector & x) + { + STABLE_VECTOR_CHECK_INVARIANT; + container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag; + container_detail::swap_alloc(this->node_alloc(), x.node_alloc(), flag); + //vector's allocator is swapped here + this->impl.swap(x.impl); + this->priv_swap_members(x); + } + + //! <b>Effects</b>: Erases all the elements of the stable_vector. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements in the stable_vector. + void clear() + { this->erase(this->cbegin(),this->cend()); } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + //! with previous allocations. The size of the stable_vector is unchanged + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { + if(this->capacity()){ + //First empty allocated node pool + this->clear_pool(); + //If empty completely destroy the index, let's recover default-constructed state + if(this->empty()){ + this->impl.clear(); + this->impl.shrink_to_fit(); + this->internal_data.set_end_pointer_to_default_constructed(); + } + //Otherwise, try to shrink-to-fit the index and readjust pointers if necessary + else{ + const size_type size = this->size(); + const void* old_ptr = &impl[0]; + this->impl.shrink_to_fit(); + bool realloced = &impl[0] != old_ptr; + //Fix the pointers for the newly allocated buffer + if(realloced){ + this->align_nodes(impl.begin(), impl.begin()+size+1); + } + } + } + } + + /// @cond + + iterator priv_insert(const_iterator position, const value_type &t) + { + typedef constant_iterator<value_type, difference_type> cvalue_iterator; + return this->insert_iter(position, cvalue_iterator(t, 1), cvalue_iterator(), std::forward_iterator_tag()); + } + + void priv_push_back(const value_type &t) + { this->insert(end(), t); } + + template<class AllocatorVersion> + void clear_pool(AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { + if(!impl.empty() && impl.back()){ + void_ptr &pool_first_ref = impl.end()[-2]; + void_ptr &pool_last_ref = impl.back(); + + multiallocation_chain holder; + holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, this->internal_data.pool_size); + while(!holder.empty()){ + node_type_ptr_t n = holder.front(); + holder.pop_front(); + this->deallocate_one(n); + } + pool_first_ref = pool_last_ref = 0; + this->internal_data.pool_size = 0; + } + } + + template<class AllocatorVersion> + void clear_pool(AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { + if(!impl.empty() && impl.back()){ + void_ptr &pool_first_ref = impl.end()[-2]; + void_ptr &pool_last_ref = impl.back(); + multiallocation_chain holder; + holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size); + node_alloc().deallocate_individual(boost::move(holder)); + pool_first_ref = pool_last_ref = 0; + this->internal_data.pool_size = 0; + } + } + + void clear_pool() + { + this->clear_pool(alloc_version()); + } + + void add_to_pool(size_type n) + { + this->add_to_pool(n, alloc_version()); + } + + template<class AllocatorVersion> + void add_to_pool(size_type n, AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { + size_type remaining = n; + while(remaining--){ + this->put_in_pool(this->allocate_one()); + } + } + + template<class AllocatorVersion> + void add_to_pool(size_type n, AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { + void_ptr &pool_first_ref = impl.end()[-2]; + void_ptr &pool_last_ref = impl.back(); + multiallocation_chain holder; + holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size); + //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled<multiallocation_chain>::value == true)); + multiallocation_chain m (node_alloc().allocate_individual(n)); + holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n); + this->internal_data.pool_size += n; + std::pair<void_ptr, void_ptr> data(holder.extract_data()); + pool_first_ref = data.first; + pool_last_ref = data.second; + } + + void put_in_pool(node_type_ptr_t p) + { + void_ptr &pool_first_ref = impl.end()[-2]; + void_ptr &pool_last_ref = impl.back(); + multiallocation_chain holder; + holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size); + holder.push_front(p); + ++this->internal_data.pool_size; + std::pair<void_ptr, void_ptr> ret(holder.extract_data()); + pool_first_ref = ret.first; + pool_last_ref = ret.second; + } + + node_type_ptr_t get_from_pool() + { + if(!impl.back()){ + return node_type_ptr_t(0); + } + else{ + void_ptr &pool_first_ref = impl.end()[-2]; + void_ptr &pool_last_ref = impl.back(); + multiallocation_chain holder; + holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size); + node_type_ptr_t ret = holder.front(); + holder.pop_front(); + --this->internal_data.pool_size; + if(!internal_data.pool_size){ + pool_first_ref = pool_last_ref = void_ptr(0); + } + else{ + std::pair<void_ptr, void_ptr> data(holder.extract_data()); + pool_first_ref = data.first; + pool_last_ref = data.second; + } + return ret; + } + } + + void insert_iter_prolog(size_type n, difference_type d) + { + initialize_end_node(n); + const void* old_ptr = &impl[0]; + //size_type old_capacity = capacity(); + //size_type old_size = size(); + impl.insert(impl.begin()+d, n, 0); + bool realloced = &impl[0] != old_ptr; + //Fix the pointers for the newly allocated buffer + if(realloced){ + align_nodes(impl.begin(), impl.begin()+d); + } + } + + template<typename InputIterator> + void assign_dispatch(InputIterator first, InputIterator last, boost::mpl::false_) + { + STABLE_VECTOR_CHECK_INVARIANT; + iterator first1 = this->begin(); + iterator last1 = this->end(); + for ( ; first1 != last1 && first != last; ++first1, ++first) + *first1 = *first; + if (first == last){ + this->erase(first1, last1); + } + else{ + this->insert(last1, first, last); + } + } + + template<typename Integer> + void assign_dispatch(Integer n, Integer t, boost::mpl::true_) + { + typedef constant_iterator<value_type, difference_type> cvalue_iterator; + this->assign_dispatch(cvalue_iterator(t, n), cvalue_iterator(), boost::mpl::false_()); + } + + iterator priv_erase(const_iterator first, const_iterator last, allocator_v1) + { + STABLE_VECTOR_CHECK_INVARIANT; + difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin(); + if(d1 != d2){ + impl_iterator it1(impl.begin() + d1), it2(impl.begin() + d2); + for(impl_iterator it = it1; it != it2; ++it) + this->delete_node(*it); + impl_iterator e = impl.erase(it1, it2); + this->align_nodes(e, get_last_align()); + } + return iterator(this->begin() + d1); + } + + impl_iterator get_last_align() + { + return impl.end() - (ExtraPointers - 1); + } + + const_impl_iterator get_last_align() const + { + return impl.cend() - (ExtraPointers - 1); + } + + template<class AllocatorVersion> + iterator priv_erase(const_iterator first, const_iterator last, AllocatorVersion, + typename boost::container::container_detail::enable_if_c + <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1> + ::value>::type * = 0) + { + STABLE_VECTOR_CHECK_INVARIANT; + return priv_erase(first, last, allocator_v1()); + } + + 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))); + } + + 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))); + } + + static value_type& value(const void_ptr &p) + { + return node_ptr_cast(p)->value; + } + + void initialize_end_node(size_type impl_capacity = 0) + { + if(impl.empty()){ + impl.reserve(impl_capacity + ExtraPointers); + impl.resize (ExtraPointers, void_ptr(0)); + impl[0] = &this->internal_data.end_node; + this->internal_data.end_node.up = &impl[0]; + } + } + + void readjust_end_node() + { + if(!this->impl.empty()){ + void_ptr &end_node_ref = *(this->get_last_align()-1); + end_node_ref = this->get_end_node(); + this->internal_data.end_node.up = &end_node_ref; + } + else{ + this->internal_data.end_node.up = void_ptr(&this->internal_data.end_node.up); + } + } + + node_type_ptr_t get_end_node() const + { + const node_type_base_t* cp = &this->internal_data.end_node; + node_type_base_t* p = const_cast<node_type_base_t*>(cp); + return node_ptr_cast(p); + } + + template<class Iter> + void_ptr new_node(const void_ptr &up, Iter it) + { + node_type_ptr_t p = this->allocate_one(); + try{ + boost::container::construct_in_place(this->node_alloc(), &*p, it); + p->set_pointer(up); + } + catch(...){ + this->deallocate_one(p); + throw; + } + return p; + } + + void delete_node(const void_ptr &p) + { + node_type_ptr_t n(node_ptr_cast(p)); + allocator_traits<node_allocator_type>:: + destroy(this->node_alloc(), container_detail::to_raw_pointer(n)); + this->put_in_pool(n); + } + + static void align_nodes(impl_iterator first, impl_iterator last) + { + while(first!=last){ + node_ptr_cast(*first)->up = void_ptr(&*first); + ++first; + } + } + + void insert_not_iter(const_iterator position, size_type n, const T& t) + { + typedef constant_iterator<value_type, difference_type> cvalue_iterator; + this->insert_iter(position, cvalue_iterator(t, n), cvalue_iterator(), std::forward_iterator_tag()); + } + + template <class InputIterator> + void insert_iter(const_iterator position,InputIterator first,InputIterator last, boost::mpl::true_) + { + typedef typename std::iterator_traits<InputIterator>::iterator_category category; + this->insert_iter(position, first, last, category()); + } + + template <class InputIterator> + void insert_iter(const_iterator position,InputIterator first,InputIterator last,std::input_iterator_tag) + { + for(; first!=last; ++first){ + this->insert(position, *first); + } + } + + template <class InputIterator> + iterator insert_iter(const_iterator position, InputIterator first, InputIterator last, std::forward_iterator_tag) + { + size_type n = (size_type)std::distance(first,last); + difference_type d = position-this->cbegin(); + if(n){ + this->insert_iter_prolog(n, d); + const impl_iterator it(impl.begin() + d); + this->insert_iter_fwd(it, first, last, n); + //Fix the pointers for the newly allocated buffer + this->align_nodes(it + n, get_last_align()); + } + return this->begin() + d; + } + + template <class FwdIterator> + void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v1) + { + size_type i=0; + try{ + while(first!=last){ + it[i] = this->new_node(void_ptr_ptr(&it[i]), first); + ++first; + ++i; + } + } + catch(...){ + impl_iterator e = impl.erase(it + i, it + n); + this->align_nodes(e, get_last_align()); + throw; + } + } + + template <class FwdIterator> + void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v2) + { + multiallocation_chain mem(node_alloc().allocate_individual(n)); + + size_type i = 0; + node_type_ptr_t p = 0; + try{ + while(first != last){ + p = mem.front(); + mem.pop_front(); + //This can throw + boost::container::construct_in_place(this->node_alloc(), &*p, first); + p->set_pointer(void_ptr_ptr(&it[i])); + ++first; + it[i] = p; + ++i; + } + } + catch(...){ + node_alloc().deallocate_one(p); + node_alloc().deallocate_many(boost::move(mem)); + impl_iterator e = impl.erase(it+i, it+n); + this->align_nodes(e, get_last_align()); + throw; + } + } + + template <class FwdIterator> + void insert_iter_fwd(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n) + { + size_type i = 0; + node_type_ptr_t p = 0; + try{ + while(first != last){ + p = this->get_from_pool(); + if(!p){ + insert_iter_fwd_alloc(it+i, first, last, n-i, alloc_version()); + break; + } + //This can throw + boost::container::construct_in_place(this->node_alloc(), &*p, first); + p->set_pointer(void_ptr_ptr(&it[i])); + ++first; + it[i]=p; + ++i; + } + } + catch(...){ + put_in_pool(p); + impl_iterator e = impl.erase(it+i, it+n); + this->align_nodes(e, get_last_align()); + throw; + } + } + + template <class InputIterator> + void insert_iter(const_iterator position, InputIterator first, InputIterator last, boost::mpl::false_) + { + this->insert_not_iter(position, first, last); + } + + #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING) + bool invariant()const + { + if(impl.empty()) + return !capacity() && !size(); + if(get_end_node() != *(impl.end() - ExtraPointers)){ + 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) != + const_void_ptr(const_void_ptr_ptr(&*it))) + return false; + } + size_type n = capacity()-size(); + const void_ptr &pool_head = impl.back(); + size_type num_pool = 0; + node_type_ptr_t p = node_ptr_cast(pool_head); + while(p){ + ++num_pool; + p = node_ptr_cast(p->up); + } + return n >= num_pool; + } + + class invariant_checker + { + invariant_checker(const invariant_checker &); + invariant_checker & operator=(const invariant_checker &); + const stable_vector* p; + + public: + invariant_checker(const stable_vector& v):p(&v){} + ~invariant_checker(){BOOST_ASSERT(p->invariant());} + void touch(){} + }; + #endif + + class ebo_holder + : public node_allocator_type + { + private: + BOOST_MOVABLE_BUT_NOT_COPYABLE(ebo_holder) + public: +/* + explicit ebo_holder(BOOST_RV_REF(ebo_holder) x) + : node_allocator_type(boost::move(static_cast<node_allocator_type&>(x))) + , pool_size(0) + , end_node() + {} +*/ + template<class AllocatorRLValue> + explicit ebo_holder(BOOST_FWD_REF(AllocatorRLValue) a) + : node_allocator_type(boost::forward<AllocatorRLValue>(a)) + , pool_size(0) + , end_node() + { + this->set_end_pointer_to_default_constructed(); + } + + ebo_holder() + : node_allocator_type() + , pool_size(0) + , end_node() + { + this->set_end_pointer_to_default_constructed(); + } + + void set_end_pointer_to_default_constructed() + { + end_node.set_pointer(void_ptr(&end_node.up)); + } + + size_type pool_size; + node_type_base_t end_node; + } internal_data; + + void priv_swap_members(stable_vector &x) + { + container_detail::do_swap(this->internal_data.pool_size, x.internal_data.pool_size); + this->readjust_end_node(); + x.readjust_end_node(); + } + + node_allocator_type &node_alloc() { return internal_data; } + const node_allocator_type &node_alloc() const { return internal_data; } + + impl_type impl; + /// @endcond +}; + +template <typename T,typename A> +bool operator==(const stable_vector<T,A>& x,const stable_vector<T,A>& y) +{ + return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin()); +} + +template <typename T,typename A> +bool operator< (const stable_vector<T,A>& x,const stable_vector<T,A>& y) +{ + return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); +} + +template <typename T,typename A> +bool operator!=(const stable_vector<T,A>& x,const stable_vector<T,A>& y) +{ + return !(x==y); +} + +template <typename T,typename A> +bool operator> (const stable_vector<T,A>& x,const stable_vector<T,A>& y) +{ + return y<x; +} + +template <typename T,typename A> +bool operator>=(const stable_vector<T,A>& x,const stable_vector<T,A>& y) +{ + return !(x<y); +} + +template <typename T,typename A> +bool operator<=(const stable_vector<T,A>& x,const stable_vector<T,A>& y) +{ + return !(x>y); +} + +// specialized algorithms: + +template <typename T, typename A> +void swap(stable_vector<T,A>& x,stable_vector<T,A>& y) +{ + x.swap(y); +} + +/// @cond + +#undef STABLE_VECTOR_CHECK_INVARIANT + +/// @endcond + +}} + +#include <boost/container/detail/config_end.hpp> + +#endif //BOOST_CONTAINER_STABLE_VECTOR_HPP diff --git a/src/third_party/boost/boost/container/string.hpp b/src/third_party/boost/boost/container/string.hpp new file mode 100644 index 00000000000..3a9c55a3c4c --- /dev/null +++ b/src/third_party/boost/boost/container/string.hpp @@ -0,0 +1,2895 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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. +// +////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 1996,1997 +// Silicon Graphics Computer Systems, Inc. +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. Silicon Graphics makes no +// representations about the suitability of this software for any +// purpose. It is provided "as is" without express or implied warranty. +// +// +// Copyright (c) 1994 +// Hewlett-Packard Company +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. Hewlett-Packard Company makes no +// representations about the suitability of this software for any +// purpose. It is provided "as is" without express or implied warranty. + +#ifndef BOOST_CONTAINER_STRING_HPP +#define BOOST_CONTAINER_STRING_HPP + +#include <boost/container/detail/config_begin.hpp> +#include <boost/container/detail/workaround.hpp> + +#include <boost/container/detail/workaround.hpp> +#include <boost/container/container_fwd.hpp> +#include <boost/container/detail/utilities.hpp> +#include <boost/container/detail/iterators.hpp> +#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/detail/mpl.hpp> +#include <boost/move/move.hpp> +#include <boost/static_assert.hpp> + +#include <functional> +#include <string> +#include <stdexcept> +#include <utility> +#include <iterator> +#include <memory> +#include <algorithm> +#include <iosfwd> +#include <istream> +#include <ostream> +#include <ios> +#include <locale> +#include <cstddef> +#include <climits> +#include <boost/container/detail/type_traits.hpp> +#include <boost/detail/no_exceptions_support.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/aligned_storage.hpp> + +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace boost { +namespace container { +#else +namespace boost { +namespace container { +#endif + +/// @cond +namespace container_detail { +// ------------------------------------------------------------ +// 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 +// allocator and whose size is this->m_storage. +template <class A> +class basic_string_base +{ + BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_string_base) + + typedef allocator_traits<A> allocator_traits_type; + public: + typedef A allocator_type; + //! The stored allocator type + typedef allocator_type stored_allocator_type; + typedef typename allocator_traits_type::pointer pointer; + typedef typename allocator_traits_type::value_type value_type; + typedef typename allocator_traits_type::size_type size_type; + + basic_string_base() + : members_() + { init(); } + + basic_string_base(const allocator_type& a) + : members_(a) + { init(); } + + basic_string_base(const allocator_type& a, size_type n) + : members_(a) + { + 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); + } + + ~basic_string_base() + { + if(!this->is_short()){ + this->deallocate_block(); + allocator_traits_type::destroy + ( this->alloc() + , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r)) + ); + } + } + + private: + + //This is the structure controlling a long string + struct long_t + { + size_type is_short : 1; + size_type length : (sizeof(size_type)*CHAR_BIT - 1); + size_type storage; + pointer start; + + long_t() + {} + + long_t(const long_t &other) + { + this->is_short = other.is_short; + length = other.length; + storage = other.storage; + start = other.start; + } + + long_t &operator =(const long_t &other) + { + this->is_short = other.is_short; + length = other.length; + storage = other.storage; + start = other.start; + return *this; + } + }; + + //This type is the first part of the structure controlling a short string + //The "data" member stores + struct short_header + { + unsigned char is_short : 1; + unsigned char length : (CHAR_BIT - 1); + }; + + //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), + container_detail::alignment_of<long_t>::value>::type long_raw_t; + + protected: + static const size_type MinInternalBufferChars = 8; + static const size_type AlignmentOfValueType = + alignment_of<value_type>::value; + static const size_type ShortDataOffset = + 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 = + (ZeroCostInternalBufferChars > MinInternalBufferChars) ? + ZeroCostInternalBufferChars : MinInternalBufferChars; + + struct short_t + { + short_header h; + value_type data[UnalignedFinalInternalBufferChars]; + }; + + union repr_t + { + long_raw_t r; + short_t s; + + short_t &short_repr() const + { return *const_cast<short_t *>(&s); } + + long_t &long_repr() const + { return *const_cast<long_t*>(reinterpret_cast<const long_t*>(&r)); } + }; + + struct members_holder + : public A + { + members_holder() + : A() + {} + + template<class AllocatorConvertible> + explicit members_holder(BOOST_FWD_REF(AllocatorConvertible) a) + : A(boost::forward<AllocatorConvertible>(a)) + {} + + repr_t m_repr; + } members_; + + const A &alloc() const + { return members_; } + + A &alloc() + { return members_; } + + static const size_type InternalBufferChars = (sizeof(repr_t) - ShortDataOffset)/sizeof(value_type); + + private: + + static const size_type MinAllocation = InternalBufferChars*2; + + protected: + bool is_short() const + { 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() + , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r)) + ); + } + else{ + allocator_traits_type::construct + ( this->alloc() + , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r)) + ); + } + this->members_.m_repr.s.h.is_short = yes; + } + + private: + void init() + { + this->members_.m_repr.s.h.is_short = 1; + this->members_.m_repr.s.h.length = 0; + } + + protected: + + typedef container_detail::integral_constant<unsigned, 1> allocator_v1; + typedef container_detail::integral_constant<unsigned, 2> allocator_v2; + typedef container_detail::integral_constant<unsigned, + boost::container::container_detail::version<A>::value> alloc_version; + + std::pair<pointer, bool> + allocation_command(allocation_type command, + size_type limit_size, + size_type preferred_size, + size_type &received_size, pointer reuse = 0) + { + if(this->is_short() && (command & (expand_fwd | expand_bwd)) ){ + reuse = pointer(0); + command &= ~(expand_fwd | expand_bwd); + } + return this->allocation_command + (command, limit_size, preferred_size, received_size, reuse, alloc_version()); + } + + std::pair<pointer, bool> + allocation_command(allocation_type command, + size_type limit_size, + size_type preferred_size, + size_type &received_size, + const pointer &reuse, + allocator_v1) + { + (void)limit_size; + (void)reuse; + if(!(command & allocate_new)) + return std::pair<pointer, bool>(pointer(0), false); + received_size = preferred_size; + return std::make_pair(this->alloc().allocate(received_size), false); + } + + std::pair<pointer, bool> + allocation_command(allocation_type command, + 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, + 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) + { + if (p && (n > InternalBufferChars)) + this->alloc().deallocate(p, n); + } + + void construct(pointer p, const value_type &value = value_type()) + { + allocator_traits_type::construct + ( this->alloc() + , container_detail::to_raw_pointer(p) + , value + ); + } + + void destroy(pointer p, size_type n) + { + for(; n--; ++p){ + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(p) + ); + } + } + + void destroy(pointer p) + { + allocator_traits_type::destroy + ( this->alloc() + , container_detail::to_raw_pointer(p) + ); + } + + void allocate_initial_block(size_type n) + { + if (n <= this->max_size()) { + if(n > InternalBufferChars){ + size_type new_cap = this->next_capacity(n); + pointer p = this->allocation_command(allocate_new, n, new_cap, new_cap).first; + this->is_short(false); + this->priv_long_addr(p); + this->priv_size(0); + this->priv_storage(new_cap); + } + } + else + throw_length_error(); + } + + 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; } + + // Helper functions for exception handling. + void throw_length_error() const + { throw(std::length_error("basic_string")); } + + void throw_out_of_range() const + { throw(std::out_of_range("basic_string")); } + + protected: + size_type priv_capacity() const + { return this->priv_storage() - 1; } + + pointer priv_short_addr() const + { return pointer(&this->members_.m_repr.short_repr().data[0]); } + + pointer priv_long_addr() const + { return this->members_.m_repr.long_repr().start; } + + pointer priv_addr() const + { return this->is_short() ? pointer(&this->members_.m_repr.short_repr().data[0]) : this->members_.m_repr.long_repr().start; } + + void priv_long_addr(pointer addr) + { this->members_.m_repr.long_repr().start = addr; } + + size_type priv_storage() const + { return this->is_short() ? priv_short_storage() : priv_long_storage(); } + + size_type priv_short_storage() const + { return InternalBufferChars; } + + size_type priv_long_storage() const + { 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; + } + + size_type priv_size() const + { return this->is_short() ? priv_short_size() : priv_long_size(); } + + size_type priv_short_size() const + { return this->members_.m_repr.short_repr().h.length; } + + size_type priv_long_size() const + { return this->members_.m_repr.long_repr().length; } + + void priv_size(size_type sz) + { + if(this->is_short()) + this->priv_short_size(sz); + else + this->priv_long_size(sz); + } + + 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); + } + + void swap_data(basic_string_base& other) + { + if(this->is_short()){ + if(other.is_short()){ + container_detail::do_swap(this->members_.m_repr, other.members_.m_repr); + } + else{ + repr_t copied(this->members_.m_repr); + this->members_.m_repr.long_repr() = other.members_.m_repr.long_repr(); + other.members_.m_repr = copied; + } + } + else{ + if(other.is_short()){ + repr_t copied(other.members_.m_repr); + other.members_.m_repr.long_repr() = this->members_.m_repr.long_repr(); + this->members_.m_repr = copied; + } + else{ + container_detail::do_swap(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr()); + } + } + } +}; + +} //namespace container_detail { + +/// @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 +//! operations such as search and concatenation. +//! +//! 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, +//! 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 +//! are O(N). +//! +//! 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. +#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> +{ + /// @cond + private: + typedef allocator_traits<A> allocator_traits_type; + BOOST_COPYABLE_AND_MOVABLE(basic_string) + typedef container_detail::basic_string_base<A> base_t; + static const typename base_t::size_type InternalBufferChars = base_t::InternalBufferChars; + + protected: + // A helper class to use a char_traits as a function object. + + template <class Tr> + struct Eq_traits + : public std::binary_function<typename Tr::char_type, + typename Tr::char_type, + bool> + { + bool operator()(const typename Tr::char_type& x, + const typename Tr::char_type& y) const + { return Tr::eq(x, y); } + }; + + template <class Tr> + struct Not_within_traits + : public std::unary_function<typename Tr::char_type, bool> + { + typedef const typename Tr::char_type* Pointer; + const Pointer m_first; + const Pointer m_last; + + Not_within_traits(Pointer f, Pointer l) + : m_first(f), m_last(l) {} + + bool operator()(const typename Tr::char_type& x) const + { + return std::find_if(m_first, m_last, + std::bind1st(Eq_traits<Tr>(), x)) == m_last; + } + }; + /// @endcond + + public: + + //! The allocator type + typedef A allocator_type; + //! The stored allocator type + typedef allocator_type stored_allocator_type; + //! The type of object, CharT, stored in the string + typedef CharT value_type; + //! The second template parameter Traits + typedef Traits traits_type; + //! Pointer to CharT + typedef typename allocator_traits_type::pointer pointer; + //! Const pointer to CharT + typedef typename allocator_traits_type::const_pointer const_pointer; + //! Reference to CharT + typedef typename allocator_traits_type::reference reference; + //! 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; + //! A signed integral type + typedef typename allocator_traits_type::difference_type difference_type; + //! Iterator used to iterate through a string. It's a Random Access Iterator + typedef pointer iterator; + //! Const iterator used to iterate through a string. It's a Random Access Iterator + typedef const_pointer const_iterator; + //! Iterator used to iterate backwards through a 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). + static const size_type npos; + + /// @cond + private: + typedef constant_iterator<CharT, difference_type> cvalue_iterator; + typedef typename base_t::allocator_v1 allocator_v1; + typedef typename base_t::allocator_v2 allocator_v2; + typedef typename base_t::alloc_version alloc_version; + /// @endcond + + public: // Constructor, destructor, assignment. + /// @cond + struct reserve_t {}; + + basic_string(reserve_t, size_type n, + const allocator_type& a = allocator_type()) + //Select allocator as in copy constructor as reserve_t-based constructors + //are two step copies optimized for capacity + : base_t( allocator_traits_type::select_on_container_copy_construction(a) + , n + 1) + { this->priv_terminate_string(); } + + /// @endcond + + //! <b>Effects</b>: Default constructs a basic_string. + //! + //! <b>Throws</b>: If allocator_type's default constructor throws. + basic_string() + : base_t() + { this->priv_terminate_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) + { this->priv_terminate_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) + : 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>Throws</b>: If allocator_type's copy constructor throws. + //! + //! <b>Complexity</b>: Constant. + basic_string(BOOST_RV_REF(basic_string) s) + : base_t(boost::move((base_t&)s)) + {} + + //! <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. + basic_string(const basic_string& s, size_type pos, size_type n = npos, + const allocator_type& a = allocator_type()) + : base_t(a) + { + if (pos > s.size()) + this->throw_out_of_range(); + else + this->priv_range_initialize + (s.begin() + pos, s.begin() + pos + container_detail::min_value(n, s.size() - pos)); + } + + //! <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) + { 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) + { this->priv_range_initialize(s, s + Traits::length(s)); } + + //! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter, + //! and is initialized by n copies of c. + 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()); + } + + //! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter, + //! and a range of iterators. + template <class InputIterator> + basic_string(InputIterator f, InputIterator l, + const allocator_type& a = allocator_type()) + : base_t(a) + { + //Dispatch depending on integer/iterator + const bool aux_boolean = container_detail::is_convertible<InputIterator, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_initialize_dispatch(f, l, Result()); + } + + //! <b>Effects</b>: Destroys the basic_string. All used memory is deallocated. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + ~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) + { + if (&x != this){ + allocator_type &this_alloc = this->alloc(); + const allocator_type &x_alloc = x.alloc(); + container_detail::bool_<allocator_traits_type:: + propagate_on_container_copy_assignment::value> flag; + if(flag && this_alloc != x_alloc){ + if(!this->is_short()){ + this->deallocate_block(); + this->is_short(true); + Traits::assign(*this->priv_addr(), this->priv_null()); + this->priv_size(0); + } + } + container_detail::assign_alloc(this->alloc(), x.alloc(), flag); + this->assign(x.begin(), x.end()); + } + return *this; + } + + //! <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) + { + if (&x != this){ + allocator_type &this_alloc = this->alloc(); + allocator_type &x_alloc = x.alloc(); + //If allocators are equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy objects but retain memory in case x reuses it in the future + this->clear(); + this->swap_data(x); + //Move allocator if needed + container_detail::bool_<allocator_traits_type:: + propagate_on_container_move_assignment::value> flag; + container_detail::move_alloc(this_alloc, x_alloc, flag); + } + //If unequal allocators, then do a one by one move + else{ + this->assign( x.begin(), x.end()); + } + } + return *this; + } + + //! <b>Effects</b>: Assignment from a null-terminated c-string. + basic_string& operator=(const CharT* s) + { return this->assign(s, s + Traits::length(s)); } + + //! <b>Effects</b>: Assignment from character. + basic_string& operator=(CharT c) + { 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(); } + + //! <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(); } + + //! <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() + { 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>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 vector. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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. + //! + //! <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 vector. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + { 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 + { 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(); } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are copy constructed from x. + //! + //! <b>Throws</b>: If memory allocation throws + //! + //! <b>Complexity</b>: Linear to the difference between size() and new_size. + void resize(size_type n, CharT c) + { + if (n <= size()) + this->erase(this->begin() + n, this->end()); + else + this->append(n - this->size(), c); + } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are default constructed. + //! + //! <b>Throws</b>: If memory allocation throws + //! + //! <b>Complexity</b>: Linear to the difference between size() and new_size. + void resize(size_type n) + { resize(n, this->priv_null()); } + + //! <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 + void reserve(size_type res_arg) + { + if (res_arg > this->max_size()) + this->throw_length_error(); + + if (this->capacity() < res_arg){ + size_type n = container_detail::max_value(res_arg, this->size()) + 1; + size_type new_cap = this->next_capacity(n); + pointer new_start = this->allocation_command + (allocate_new, n, new_cap, new_cap).first; + size_type new_length = 0; + + new_length += priv_uninitialized_copy + (this->priv_addr(), this->priv_addr() + this->priv_size(), new_start); + this->priv_construct_null(new_start + new_length); + this->deallocate_block(); + this->is_short(false); + this->priv_long_addr(new_start); + this->priv_size(new_length); + this->priv_storage(new_cap); + } + } + + //! <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(); } + + //! <b>Effects</b>: Erases all the elements of the vector. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements in the vector. + void clear() + { + if (!empty()) { + Traits::assign(*this->priv_addr(), this->priv_null()); + this->priv_size(0); + } + } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + //! with previous allocations. The size of the string is unchanged + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { + //Check if shrinking is possible + if(this->priv_storage() > InternalBufferChars){ + //Check if we should pass from dynamically allocated buffer + //to the internal storage + if(this->priv_size() < (InternalBufferChars)){ + //Dynamically allocated buffer attributes + pointer long_addr = this->priv_long_addr(); + size_type long_storage = this->priv_long_storage(); + size_type long_size = this->priv_long_size(); + //Shrink from allocated buffer to the internal one, including trailing null + Traits::copy( container_detail::to_raw_pointer(this->priv_short_addr()) + , container_detail::to_raw_pointer(long_addr) + , long_size+1); + this->is_short(true); + this->alloc().deallocate(long_addr, long_storage); + } + else{ + //Shrinking in dynamic buffer + this->priv_shrink_to_fit_dynamic_buffer(alloc_version()); + } + } + } + + //! <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 + //! 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 + //! 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 + //! 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()) + this->throw_out_of_range(); + return *(this->priv_addr() + n); + } + + //! <b>Requires</b>: size() > n. + //! + //! <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()) + this->throw_out_of_range(); + return *(this->priv_addr() + n); + } + + //! <b>Effects</b>: Calls append(str.data, str.size()). + //! + //! <b>Returns</b>: *this + basic_string& operator+=(const basic_string& s) + { return this->append(s); } + + //! <b>Effects</b>: Calls append(s). + //! + //! <b>Returns</b>: *this + basic_string& operator+=(const CharT* s) + { return this->append(s); } + + //! <b>Effects</b>: Calls append(1, c). + //! + //! <b>Returns</b>: *this + basic_string& operator+=(CharT c) + { this->push_back(c); return *this; } + + //! <b>Effects</b>: Calls append(str.data(), str.size()). + //! + //! <b>Returns</b>: *this + 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 + //! 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() + //! + //! <b>Returns</b>: *this + basic_string& append(const basic_string& s, size_type pos, size_type n) + { + if (pos > s.size()) + this->throw_out_of_range(); + return this->append(s.begin() + pos, + s.begin() + pos + container_detail::min_value(n, s.size() - pos)); + } + + //! <b>Requires</b>: s points to an array of at least n elements of CharT. + //! + //! <b>Effects</b>: The function replaces the string controlled by *this with + //! a string of length size() + n whose irst size() elements are a copy of the + //! original string controlled by *this and whose remaining + //! elements are a copy of the initial n elements of s. + //! + //! <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) + { return this->append(s, s + n); } + + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <b>Effects</b>: Calls append(s, traits::length(s)). + //! + //! <b>Returns</b>: *this + basic_string& append(const CharT* s) + { return this->append(s, s + Traits::length(s)); } + + //! <b>Effects</b>: Equivalent to append(basic_string(n, c)). + //! + //! <b>Returns</b>: *this + basic_string& append(size_type n, CharT c) + { return this->append(cvalue_iterator(c, n), cvalue_iterator()); } + + //! <b>Requires</b>: [first,last) is a valid range. + //! + //! <b>Effects</b>: Equivalent to append(basic_string(first, last)). + //! + //! <b>Returns</b>: *this + template <class InputIter> + basic_string& append(InputIter first, InputIter last) + { this->insert(this->end(), first, last); return *this; } + + //! <b>Effects</b>: Equivalent to append(static_cast<size_type>(1), c). + void push_back(CharT c) + { + if (this->priv_size() < this->capacity()){ + this->priv_construct_null(this->priv_addr() + (this->priv_size() + 1)); + Traits::assign(this->priv_addr()[this->priv_size()], c); + this->priv_size(this->priv_size()+1); + } + else{ + //No enough memory, insert a new object at the end + this->append((size_type)1, c); + } + } + + //! <b>Effects</b>: Equivalent to assign(str, 0, npos). + //! + //! <b>Returns</b>: *this + 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 + //! 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) + { return this->swap_data(ms), *this; } + + //! <b>Requires</b>: pos <= str.size() + //! + //! <b>Effects</b>: Determines the effective length rlen of the string to assign as + //! the smaller of n and str.size() - pos and calls assign(str.data() + pos rlen). + //! + //! <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, + size_type pos, size_type n) { + if (pos > s.size()) + this->throw_out_of_range(); + return this->assign(s.begin() + pos, + s.begin() + pos + container_detail::min_value(n, s.size() - pos)); + } + + //! <b>Requires</b>: s points to an array of at least n elements of CharT. + //! + //! <b>Effects</b>: Replaces the string controlled by *this with a string of + //! 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); } + + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <b>Effects</b>: Calls assign(s, traits::length(s)). + //! + //! <b>Returns</b>: *this + basic_string& assign(const CharT* s) + { return this->assign(s, s + Traits::length(s)); } + + //! <b>Effects</b>: Equivalent to assign(basic_string(n, c)). + //! + //! <b>Returns</b>: *this + basic_string& assign(size_type n, CharT c) + { return this->assign(cvalue_iterator(c, n), cvalue_iterator()); } + + //! <b>Effects</b>: Equivalent to assign(basic_string(first, last)). + //! + //! <b>Returns</b>: *this + template <class InputIter> + basic_string& assign(InputIter first, InputIter last) + { + //Dispatch depending on integer/iterator + const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + return this->priv_assign_dispatch(first, last, Result()); + } + + //! <b>Requires</b>: pos <= size(). + //! + //! <b>Effects</b>: Calls insert(pos, str.data(), str.size()). + //! + //! <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) + { + if (pos > size()) + this->throw_out_of_range(); + if (this->size() > this->max_size() - s.size()) + this->throw_length_error(); + this->insert(this->priv_addr() + pos, s.begin(), s.end()); + return *this; + } + + //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size() + //! + //! <b>Effects</b>: Determines the effective length rlen of the string to insert as + //! the smaller of n and str.size() - pos2 and calls insert(pos1, str.data() + pos2, rlen). + //! + //! <b>Throws</b>: If memory allocation throws or out_of_range if pos1 > size() or pos2 > str.size(). + //! + //! <b>Returns</b>: *this + basic_string& insert(size_type pos1, const basic_string& s, + size_type pos2, size_type n) + { + if (pos1 > this->size() || pos2 > s.size()) + this->throw_out_of_range(); + size_type len = container_detail::min_value(n, s.size() - pos2); + if (this->size() > this->max_size() - len) + this->throw_length_error(); + const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2; + const CharT *end_ptr = beg_ptr + len; + this->insert(this->priv_addr() + pos1, beg_ptr, end_ptr); + return *this; + } + + //! <b>Requires</b>: s points to an array of at least n elements of CharT and pos <= size(). + //! + //! <b>Effects</b>: Replaces the string controlled by *this with a string of length size() + n + //! whose first pos elements are a copy of the initial elements of the original string + //! controlled by *this and whose next n elements are a copy of the elements in s and whose + //! remaining elements are a copy of the remaining elements of the original string controlled by *this. + //! + //! <b>Throws</b>: If memory allocation throws, out_of_range if pos > size() or + //! length_error if size() + n > max_size(). + //! + //! <b>Returns</b>: *this + basic_string& insert(size_type pos, const CharT* s, size_type n) + { + if (pos > this->size()) + this->throw_out_of_range(); + if (this->size() > this->max_size() - n) + this->throw_length_error(); + this->insert(this->priv_addr() + pos, s, s + n); + return *this; + } + + //! <b>Requires</b>: pos <= size() and s points to an array of at least traits::length(s) + 1 elements of CharT + //! + //! <b>Effects</b>: Calls insert(pos, s, traits::length(s)). + //! + //! <b>Throws</b>: If memory allocation throws, out_of_range if pos > size() + //! length_error if size() > max_size() - Traits::length(s) + //! + //! <b>Returns</b>: *this + basic_string& insert(size_type pos, const CharT* s) + { + if (pos > size()) + this->throw_out_of_range(); + size_type len = Traits::length(s); + if (this->size() > this->max_size() - len) + this->throw_length_error(); + this->insert(this->priv_addr() + pos, s, s + len); + return *this; + } + + //! <b>Effects</b>: Equivalent to insert(pos, basic_string(n, c)). + //! + //! <b>Throws</b>: If memory allocation throws, out_of_range if pos > size() + //! length_error if size() > max_size() - n + //! + //! <b>Returns</b>: *this + basic_string& insert(size_type pos, size_type n, CharT c) + { + if (pos > this->size()) + this->throw_out_of_range(); + if (this->size() > this->max_size() - n) + this->throw_length_error(); + this->insert(const_iterator(this->priv_addr() + pos), n, c); + return *this; + } + + //! <b>Requires</b>: p is a valid iterator on *this. + //! + //! <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) + { + size_type new_offset = p - this->priv_addr() + 1; + this->insert(p, cvalue_iterator(c, 1), cvalue_iterator()); + return this->priv_addr() + new_offset; + } + + + //! <b>Requires</b>: p is a valid iterator on *this. + //! + //! <b>Effects</b>: Inserts n copies of c before the character referred to by p. + //! + //! <b>Returns</b>: An iterator which refers to the copy of the first + //! inserted character, or p if n == 0. + void insert(const_iterator p, size_type n, CharT c) + { + this->insert(p, cvalue_iterator(c, n), cvalue_iterator()); + } + + //! <b>Requires</b>: p is a valid iterator on *this. [first,last) is a valid range. + //! + //! <b>Effects</b>: Equivalent to insert(p - begin(), basic_string(first, last)). + //! + //! <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) + { + //Dispatch depending on integer/iterator + const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_insert_dispatch(p, first, last, Result()); + } + + //! <b>Requires</b>: pos <= size() + //! + //! <b>Effects</b>: Determines the effective length xlen of the string to be removed as the smaller of n and size() - pos. + //! The function then replaces the string controlled by *this with a string of length size() - xlen + //! whose first pos elements are a copy of the initial elements of the original string controlled by *this, + //! 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>: out_of_range if pos > size(). + //! + //! <b>Returns</b>: *this + 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. + //! + //! <b>Throws</b>: Nothing + //! + //! <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) + { + // 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), + this->priv_size() - (p - this->priv_addr())); + this->priv_size(this->priv_size()-1); + return iterator(ptr); + } + + //! <b>Requires</b>: first and last are valid iterators on *this, defining a range [first,last). + //! + //! <b>Effects</b>: Removes the characters in the range [first,last). + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: An iterator which points to the element pointed to by last prior to + //! the other elements being erased. If no such element exists, end() is returned. + iterator erase(const_iterator first, const_iterator last) + { + CharT * f = const_cast<CharT*>(container_detail::to_raw_pointer(first)); + if (first != last) { // The move includes the terminating null. + size_type num_erased = last - first; + Traits::move(f, + 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); + } + return iterator(f); + } + + //! <b>Requires</b>: !empty() + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Effects</b>: Equivalent to erase(size() - 1, 1). + void pop_back() + { + Traits::assign(this->priv_addr()[this->priv_size()-1], this->priv_null()); + this->priv_size(this->priv_size()-1);; + } + + //! <b>Requires</b>: pos1 <= size(). + //! + //! <b>Effects</b>: Calls replace(pos1, n1, str.data(), str.size()). + //! + //! <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) + { + 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, + str.begin(), str.end()); + } + + //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size(). + //! + //! <b>Effects</b>: Determines the effective length rlen of the string to be + //! inserted as the smaller of n2 and str.size() - pos2 and calls + //! replace(pos1, n1, str.data() + pos2, rlen). + //! + //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or pos2 > str.size(). + //! + //! <b>Returns</b>: *this + basic_string& replace(size_type pos1, size_type n1, + const basic_string& str, size_type pos2, size_type n2) + { + if (pos1 > size() || pos2 > str.size()) + this->throw_out_of_range(); + const size_type len1 = container_detail::min_value(n1, size() - pos1); + const size_type len2 = container_detail::min_value(n2, str.size() - pos2); + if (this->size() - len1 >= this->max_size() - len2) + this->throw_length_error(); + return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len1, + str.priv_addr() + pos2, str.priv_addr() + pos2 + len2); + } + + //! <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 + //! 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 + //! 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) + { + if (pos1 > size()) + this->throw_out_of_range(); + const size_type len = container_detail::min_value(n1, size() - pos1); + if (n2 > this->max_size() || size() - len >= this->max_size() - n2) + this->throw_length_error(); + return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len, + s, s + n2); + } + + //! <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 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 + //! 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) + { + if (pos > size()) + this->throw_out_of_range(); + const size_type len = container_detail::min_value(n1, size() - pos); + const size_type n2 = Traits::length(s); + if (n2 > this->max_size() || size() - len >= this->max_size() - n2) + this->throw_length_error(); + return this->replace(this->priv_addr() + pos, this->priv_addr() + pos + len, + s, s + Traits::length(s)); + } + + //! <b>Requires</b>: pos1 <= size(). + //! + //! <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 + //! 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) + { + if (pos1 > size()) + this->throw_out_of_range(); + const size_type len = container_detail::min_value(n1, size() - pos1); + if (n2 > this->max_size() || size() - len >= this->max_size() - n2) + this->throw_length_error(); + return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len, n2, c); + } + + //! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges. + //! + //! <b>Effects</b>: Calls replace(i1 - begin(), i2 - i1, str). + //! + //! <b>Throws</b>: if memory allocation throws + //! + //! <b>Returns</b>: *this + 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 + //! s points to an array of at least n elements + //! + //! <b>Effects</b>: Calls replace(i1 - begin(), i2 - i1, s, n). + //! + //! <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) + { return this->replace(i1, i2, s, s + n); } + + //! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges and s points to an + //! array of at least traits::length(s) + 1 elements of CharT. + //! + //! <b>Effects</b>: Calls replace(i1 - begin(), i2 - i1, s, traits::length(s)). + //! + //! <b>Throws</b>: if memory allocation throws + //! + //! <b>Returns</b>: *this + 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. + //! + //! <b>Effects</b>: Calls replace(i1 - begin(), i2 - i1, basic_string(n, c)). + //! + //! <b>Throws</b>: if memory allocation throws + //! + //! <b>Returns</b>: *this + basic_string& replace(const_iterator i1, const_iterator i2, size_type n, CharT c) + { + const size_type len = static_cast<size_type>(i2 - i1); + if (len >= n) { + Traits::assign(const_cast<CharT*>(container_detail::to_raw_pointer(i1)), n, c); + erase(i1 + n, i2); + } + else { + Traits::assign(const_cast<CharT*>(container_detail::to_raw_pointer(i1)), len, c); + insert(i2, n - len, c); + } + return *this; + } + + //! <b>Requires</b>: [begin(),i1), [i1,i2) and [j1,j2) are valid ranges. + //! + //! <b>Effects</b>: Calls replace(i1 - begin(), i2 - i1, basic_string(j1, j2)). + //! + //! <b>Throws</b>: if memory allocation throws + //! + //! <b>Returns</b>: *this + template <class InputIter> + 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; + typedef container_detail::bool_<aux_boolean> Result; + return this->priv_replace_dispatch(i1, i2, j1, j2, Result()); + } + + //! <b>Requires</b>: pos <= size() + //! + //! <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 + //! 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 + { + if (pos > size()) + this->throw_out_of_range(); + const size_type len = container_detail::min_value(n, size() - pos); + Traits::copy(s, container_detail::to_raw_pointer(this->priv_addr() + pos), len); + return len; + } + + //! <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 + void swap(basic_string& x) + { + this->base_t::swap_data(x); + container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag; + container_detail::swap_alloc(this->alloc(), x.alloc(), flag); + } + + //! <b>Requires</b>: The program shall not alter any of the values stored in the character array. + //! + //! <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 + { 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. + //! + //! <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 + { return container_detail::to_raw_pointer(this->priv_addr()); } + + //! <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 + { return find(s.c_str(), pos, s.size()); } + + //! <b>Requires</b>: s points to an array of at least n elements of CharT. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find(basic_string<CharT,traits,Allocator>(s,n),pos). + size_type find(const CharT* s, size_type pos, size_type n) const + { + if (pos + n > size()) + return npos; + else { + pointer finish = this->priv_addr() + this->priv_size(); + const const_iterator result = + 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; + } + } + + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find(basic_string(s), pos). + size_type find(const CharT* s, size_type pos = 0) const + { return find(s, pos, Traits::length(s)); } + + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find(basic_string<CharT,traits,Allocator>(1,c), pos). + size_type find(CharT c, size_type pos = 0) const + { + if (pos >= size()) + return npos; + else { + pointer finish = this->priv_addr() + this->priv_size(); + const const_iterator result = + std::find_if(this->priv_addr() + pos, finish, + std::bind2nd(Eq_traits<Traits>(), c)); + return result != finish ? result - begin() : npos; + } + } + + //! <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. + //! + //! <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 + { return rfind(str.c_str(), pos, str.size()); } + + //! <b>Requires</b>: s points to an array of at least n elements of CharT. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: rfind(basic_string(s, n), pos). + size_type rfind(const CharT* s, size_type pos, size_type n) const + { + const size_type len = size(); + + if (n > len) + return npos; + else if (n == 0) + return container_detail::min_value(len, pos); + else { + const const_iterator last = begin() + container_detail::min_value(len - n, pos) + n; + const const_iterator result = find_end(begin(), last, + s, s + n, + Eq_traits<Traits>()); + return result != last ? result - begin() : npos; + } + } + + //! <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 + { return rfind(s, pos, Traits::length(s)); } + + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: rfind(basic_string<CharT,traits,Allocator>(1,c),pos). + size_type rfind(CharT c, size_type pos = npos) const + { + const size_type len = size(); + + if (len < 1) + return npos; + else { + const const_iterator last = begin() + container_detail::min_value(len - 1, pos) + 1; + const_reverse_iterator rresult = + std::find_if(const_reverse_iterator(last), rend(), + std::bind2nd(Eq_traits<Traits>(), c)); + return rresult != rend() ? (rresult.base() - 1) - begin() : npos; + } + } + + //! <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 some element 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_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. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find_first_of(basic_string(s, n), pos). + size_type find_first_of(const CharT* s, size_type pos, size_type n) const + { + if (pos >= size()) + return npos; + else { + pointer finish = this->priv_addr() + this->priv_size(); + const_iterator result = std::find_first_of(this->priv_addr() + pos, finish, + s, s + n, + Eq_traits<Traits>()); + return result != finish ? result - begin() : npos; + } + } + + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <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 + { 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. + //! + //! <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 + { return find(c, pos); } + + //! <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. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. + size_type find_last_of(const basic_string& str, size_type pos = npos) const + { return find_last_of(str.c_str(), pos, str.size()); } + + //! <b>Requires</b>: s points to an array of at least n elements of CharT. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find_last_of(basic_string(s, n), pos). + size_type find_last_of(const CharT* s, size_type pos, size_type n) const + { + const size_type len = size(); + + if (len < 1) + return npos; + else { + const const_iterator last = this->priv_addr() + container_detail::min_value(len - 1, pos) + 1; + const const_reverse_iterator rresult = + std::find_first_of(const_reverse_iterator(last), rend(), + s, s + n, + Eq_traits<Traits>()); + return rresult != rend() ? (rresult.base() - 1) - this->priv_addr() : npos; + } + } + + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <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 + { 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 + { return rfind(c, pos); } + + //! <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. + //! + //! <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 + { 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. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find_first_not_of(basic_string(s, n), pos). + size_type find_first_not_of(const CharT* s, size_type pos, size_type n) const + { + if (pos > size()) + return npos; + else { + pointer finish = this->priv_addr() + this->priv_size(); + const_iterator result = std::find_if(this->priv_addr() + pos, finish, + Not_within_traits<Traits>(s, s + n)); + return result != finish ? result - this->priv_addr() : npos; + } + } + + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <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 + { return find_first_not_of(s, pos, Traits::length(s)); } + + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find_first_not_of(basic_string(1, c), pos). + size_type find_first_not_of(CharT c, size_type pos = 0) const + { + if (pos > size()) + return npos; + else { + pointer finish = this->priv_addr() + this->priv_size(); + const_iterator result + = std::find_if(this->priv_addr() + pos, finish, + std::not1(std::bind2nd(Eq_traits<Traits>(), c))); + return result != finish ? result - begin() : npos; + } + } + + //! <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 no element 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_last_not_of(const basic_string& str, size_type pos = npos) const + { return find_last_not_of(str.c_str(), pos, str.size()); } + + //! <b>Requires</b>: s points to an array of at least n elements of CharT. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find_last_not_of(basic_string(s, n), pos). + size_type find_last_not_of(const CharT* s, size_type pos, size_type n) const + { + const size_type len = size(); + + if (len < 1) + return npos; + else { + const const_iterator last = begin() + container_detail::min_value(len - 1, pos) + 1; + const const_reverse_iterator rresult = + std::find_if(const_reverse_iterator(last), rend(), + Not_within_traits<Traits>(s, s + n)); + return rresult != rend() ? (rresult.base() - 1) - begin() : npos; + } + } + + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find_last_not_of(basic_string(s), pos). + size_type find_last_not_of(const CharT* s, size_type pos = npos) const + { return find_last_not_of(s, pos, Traits::length(s)); } + + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: find_last_not_of(basic_string(1, c), pos). + size_type find_last_not_of(CharT c, size_type pos = npos) const + { + const size_type len = size(); + + if (len < 1) + return npos; + else { + const const_iterator last = begin() + container_detail::min_value(len - 1, pos) + 1; + const_reverse_iterator rresult = + std::find_if(const_reverse_iterator(last), rend(), + std::not1(std::bind2nd(Eq_traits<Traits>(), c))); + return rresult != rend() ? (rresult.base() - 1) - begin() : npos; + } + } + + //! <b>Requires</b>: Requires: pos <= size() + //! + //! <b>Effects</b>: Determines the effective length rlen of the string to copy as + //! the smaller of n and size() - pos. + //! + //! <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 + { + if (pos > size()) + this->throw_out_of_range(); + return basic_string(this->priv_addr() + pos, + this->priv_addr() + pos + container_detail::min_value(n, size() - pos), this->alloc()); + } + + //! <b>Effects</b>: Determines the effective length rlen of the string to copy as + //! the smaller of size() and str.size(). The function then compares the two strings by + //! calling traits::compare(data(), str.data(), rlen). + //! + //! <b>Throws</b>: Nothing + //! + //! <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 + { 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() + //! + //! <b>Effects</b>: Determines the effective length rlen of the string to copy as + //! the smaller of + //! + //! <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 + { + if (pos1 > size()) + this->throw_out_of_range(); + 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>Effects</b>: Determines the effective length rlen of the string to copy as + //! the smaller of + //! + //! <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, + 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, + this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1), + 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 + { return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), s, s + Traits::length(s)); } + + + //! <b>Requires</b>: pos1 > size() and s points to an array of at least n2 elements of CharT. + //! + //! <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, size_type n2) const + { + if (pos1 > size()) + this->throw_out_of_range(); + return s_compare(this->priv_addr() + pos1, + this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1), + s, s + n2); + } + + //! <b>Requires</b>: pos1 > size() and s points to an array of at least traits::length(s) + 1 elements of CharT. + //! + //! <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 + { 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 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), + container_detail::min_value(n1, n2)); + return cmp != 0 ? cmp : (n1 < n2 ? -1 : (n1 > n2 ? 1 : 0)); + } + + template<class AllocVersion> + void priv_shrink_to_fit_dynamic_buffer + ( AllocVersion + , typename container_detail::enable_if<container_detail::is_same<AllocVersion, allocator_v1> >::type* = 0) + { + //Allocate a new buffer. + size_type real_cap = 0; + pointer long_addr = this->priv_long_addr(); + size_type long_size = this->priv_long_size(); + size_type long_storage = this->priv_long_storage(); + //We can make this nothrow as chars are always NoThrowCopyables + try{ + std::pair<pointer, bool> ret = this->allocation_command + (allocate_new, long_size+1, long_size+1, real_cap, long_addr); + //Copy and update + Traits::copy( container_detail::to_raw_pointer(ret.first) + , container_detail::to_raw_pointer(this->priv_long_addr()) + , long_size+1); + this->priv_long_addr(ret.first); + this->priv_storage(real_cap); + //And release old buffer + this->alloc().deallocate(long_addr, long_storage); + } + catch(...){ + return; + } + } + + template<class AllocVersion> + void priv_shrink_to_fit_dynamic_buffer + ( AllocVersion + , typename container_detail::enable_if<container_detail::is_same<AllocVersion, allocator_v2> >::type* = 0) + { + size_type received_size; + if(this->alloc().allocation_command + ( shrink_in_place | nothrow_allocation + , this->priv_long_storage(), this->priv_long_size()+1 + , received_size, this->priv_long_addr()).first){ + this->priv_storage(received_size); + } + } + + void priv_construct_null(pointer p) + { this->construct(p, 0); } + + static CharT priv_null() + { return (CharT) 0; } + + // 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() + { this->priv_construct_null(this->priv_addr() + this->priv_size()); } + + template <class InputIter> + void priv_range_initialize(InputIter f, InputIter l, + std::input_iterator_tag) + { + this->allocate_initial_block(InternalBufferChars); + this->priv_construct_null(this->priv_addr() + this->priv_size()); + this->append(f, l); + } + + template <class ForwardIter> + void priv_range_initialize(ForwardIter f, ForwardIter l, + std::forward_iterator_tag) + { + difference_type n = std::distance(f, l); + this->allocate_initial_block(container_detail::max_value<difference_type>(n+1, InternalBufferChars)); + priv_uninitialized_copy(f, l, this->priv_addr()); + this->priv_size(n); + this->priv_terminate_string(); + } + + template <class InputIter> + void priv_range_initialize(InputIter f, InputIter l) + { + typedef typename std::iterator_traits<InputIter>::iterator_category Category; + this->priv_range_initialize(f, l, Category()); + } + + template <class Integer> + void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_) + { + this->allocate_initial_block(container_detail::max_value<difference_type>(n+1, InternalBufferChars)); + priv_uninitialized_fill_n(this->priv_addr(), n, x); + this->priv_size(n); + this->priv_terminate_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) + { + //Save initial position + FwdIt init = first; + + BOOST_TRY{ + //Construct objects + for (; count--; ++first){ + this->construct(first, val); + } + } + BOOST_CATCH(...){ + //Call destructors + for (; init != first; ++init){ + this->destroy(init); + } + BOOST_RETHROW + } + BOOST_CATCH_END + } + + template<class InpIt, class FwdIt> inline + size_type priv_uninitialized_copy(InpIt first, InpIt last, FwdIt dest) + { + //Save initial destination position + FwdIt dest_init = dest; + size_type constructed = 0; + + BOOST_TRY{ + //Try to build objects + for (; first != last; ++dest, ++first, ++constructed){ + this->construct(dest, *first); + } + } + BOOST_CATCH(...){ + //Call destructors + for (; constructed--; ++dest_init){ + this->destroy(dest_init); + } + BOOST_RETHROW + } + BOOST_CATCH_END + return (constructed); + } + + template <class Integer> + basic_string& priv_assign_dispatch(Integer n, Integer x, container_detail::true_) + { return this->assign((size_type) n, (CharT) x); } + + template <class InputIter> + basic_string& priv_assign_dispatch(InputIter f, InputIter l, + container_detail::false_) + { + size_type cur = 0; + CharT *ptr = container_detail::to_raw_pointer(this->priv_addr()); + while (f != l && cur != this->priv_size()) { + Traits::assign(*ptr, *f); + ++f; + ++cur; + ++ptr; + } + if (f == l) + this->erase(this->priv_addr() + cur, this->priv_addr() + this->priv_size()); + else + this->append(f, l); + return *this; + } + + template <class InputIter> + void priv_insert(const_iterator p, InputIter first, InputIter last, std::input_iterator_tag) + { + for ( ; first != last; ++first, ++p) { + p = this->insert(p, *first); + } + } + + template <class ForwardIter> + void priv_insert(const_iterator position, ForwardIter first, + ForwardIter last, std::forward_iterator_tag) + { + if (first != last) { + size_type n = std::distance(first, last); + size_type remaining = this->capacity() - this->priv_size(); + const size_type old_size = this->size(); + pointer old_start = this->priv_addr(); + bool enough_capacity = false; + std::pair<pointer, bool> allocation_ret; + size_type new_cap = 0; + + //Check if we have enough capacity + if (remaining >= n){ + 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, + new_cap, new_cap, old_start); + + //Check forward expansion + if(old_start == allocation_ret.first){ + enough_capacity = true; + this->priv_storage(new_cap); + } + } + + //Reuse same buffer + if(enough_capacity){ + const size_type elems_after = + this->priv_size() - (position - this->priv_addr()); + size_type old_length = this->priv_size(); + if (elems_after >= n) { + pointer pointer_past_last = this->priv_addr() + this->priv_size() + 1; + priv_uninitialized_copy(this->priv_addr() + (this->priv_size() - n + 1), + pointer_past_last, pointer_past_last); + + this->priv_size(this->priv_size()+n); + Traits::move(const_cast<CharT*>(container_detail::to_raw_pointer(position + n)), + container_detail::to_raw_pointer(position), + (elems_after - n) + 1); + this->priv_copy(first, last, const_cast<CharT*>(container_detail::to_raw_pointer(position))); + } + else { + ForwardIter mid = first; + std::advance(mid, elems_after + 1); + + priv_uninitialized_copy(mid, last, this->priv_addr() + this->priv_size() + 1); + this->priv_size(this->priv_size() + (n - elems_after)); + priv_uninitialized_copy + (position, const_iterator(this->priv_addr() + old_length + 1), + this->priv_addr() + this->priv_size()); + this->priv_size(this->priv_size() + elems_after); + this->priv_copy(first, mid, const_cast<CharT*>(container_detail::to_raw_pointer(position))); + } + } + else{ + pointer new_start = allocation_ret.first; + if(!allocation_ret.second){ + //Copy data to new buffer + size_type new_length = 0; + //This can't throw, since characters are POD + new_length += priv_uninitialized_copy + (const_iterator(this->priv_addr()), position, new_start); + new_length += priv_uninitialized_copy + (first, last, new_start + new_length); + new_length += priv_uninitialized_copy + (position, const_iterator(this->priv_addr() + this->priv_size()), + new_start + new_length); + this->priv_construct_null(new_start + new_length); + + this->deallocate_block(); + this->is_short(false); + this->priv_long_addr(new_start); + this->priv_long_size(new_length); + this->priv_long_storage(new_cap); + } + else{ + //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); + const value_type *pos = container_detail::to_raw_pointer(position); + size_type before = pos - oldbuf; + + //First move old data + Traits::move(newbuf, oldbuf, before); + Traits::move(newbuf + before + n, pos, old_size - before); + //Now initialize the new data + priv_uninitialized_copy(first, last, new_start + before); + this->priv_construct_null(new_start + (old_size + n)); + this->is_short(false); + this->priv_long_addr(new_start); + this->priv_long_size(old_size + n); + this->priv_long_storage(new_cap); + } + } + } + } + + template <class Integer> + void priv_insert_dispatch(const_iterator p, Integer n, Integer x, + 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_) + { + typedef typename std::iterator_traits<InputIter>::iterator_category Category; + priv_insert(p, first, last, Category()); + } + + template <class InputIterator, class OutIterator> + void priv_copy(InputIterator first, InputIterator last, OutIterator result) + { + for ( ; first != last; ++first, ++result) + Traits::assign(*result, *first); + } + + 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_) + { 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_) + { + typedef typename std::iterator_traits<InputIter>::iterator_category Category; + return this->priv_replace(first, last, f, l, Category()); + } + + + template <class InputIter> + basic_string& priv_replace(const_iterator first, const_iterator last, + InputIter f, InputIter l, std::input_iterator_tag) + { + for ( ; first != last && f != l; ++first, ++f) + Traits::assign(*first, *f); + + if (f == l) + this->erase(first, last); + else + this->insert(last, f, l); + return *this; + } + + template <class ForwardIter> + basic_string& priv_replace(const_iterator first, const_iterator last, + ForwardIter f, ForwardIter l, + std::forward_iterator_tag) + { + difference_type n = std::distance(f, l); + const difference_type len = last - first; + if (len >= n) { + this->priv_copy(f, l, const_cast<CharT*>(container_detail::to_raw_pointer(first))); + this->erase(first + n, last); + } + else { + ForwardIter m = f; + std::advance(m, len); + this->priv_copy(f, m, const_cast<CharT*>(container_detail::to_raw_pointer(first))); + this->insert(last, m, l); + } + return *this; + } + /// @endcond +}; + +//!Typedef for a basic_string of +//!narrow characters +typedef basic_string + <char + ,std::char_traits<char> + ,std::allocator<char> > +string; + +//!Typedef for a basic_string of +//!narrow characters +typedef basic_string + <wchar_t + ,std::char_traits<wchar_t> + ,std::allocator<wchar_t> > +wstring; + +/// @cond + +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 + +// ------------------------------------------------------------ +// Non-member functions. + +// Operator+ + +template <class CharT, class Traits, class A> +inline basic_string<CharT,Traits,A> +operator+(const basic_string<CharT,Traits,A>& x, + const basic_string<CharT,Traits,A>& y) +{ + typedef basic_string<CharT,Traits,A> str_t; + typedef typename str_t::reserve_t reserve_t; + reserve_t reserve; + str_t result(reserve, x.size() + y.size(), x.get_stored_allocator()); + result.append(x); + result.append(y); + return boost::move(result); +} + +template <class CharT, class Traits, class A> inline +BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) + operator+( + BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx + , BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my) +{ + mx += my; + return boost::move(mx); +} + +template <class CharT, class Traits, class A> inline +BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) + operator+( + BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx + , const basic_string<CharT,Traits,A>& y) +{ + mx += y; + return boost::move(mx); +} + +template <class CharT, class Traits, class A> inline +BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) + operator+(const basic_string<CharT,Traits,A>& x, + BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my) +{ + typedef typename basic_string<CharT,Traits,A>::size_type size_type; + my.replace(size_type(0), size_type(0), x); + return boost::move(my); +} + +template <class CharT, class Traits, class A> +inline basic_string<CharT,Traits,A> +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; + reserve_t reserve; + const typename str_t::size_type n = Traits::length(s); + str_t result(reserve, n + y.size()); + result.append(s, s + n); + result.append(y); + return boost::move(result); +} + +template <class CharT, class Traits, class A> inline +BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) +operator+(const CharT* s, + BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my) +{ + typedef typename basic_string<CharT,Traits,A>::size_type size_type; + return boost::move(my.replace(size_type(0), size_type(0), s)); +} + +template <class CharT, class Traits, class A> +inline basic_string<CharT,Traits,A> +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; + reserve_t reserve; + str_t result(reserve, 1 + y.size()); + result.push_back(c); + result.append(y); + return boost::move(result); +} + +template <class CharT, class Traits, class A> inline +BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) +operator+(CharT c, + BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) my) +{ + typedef typename basic_string<CharT,Traits,A>::size_type size_type; + return boost::move(my.replace(size_type(0), size_type(0), &c, &c + 1)); +} + +template <class CharT, class Traits, class A> +inline basic_string<CharT,Traits,A> +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; + reserve_t reserve; + const typename str_t::size_type n = Traits::length(s); + str_t result(reserve, x.size() + n, x.get_stored_allocator()); + result.append(x); + result.append(s, s + n); + return boost::move(result); +} + +template <class CharT, class Traits, class A> +BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) +operator+(BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx + , const CharT* s) +{ + mx += s; + return boost::move(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) +{ + typedef basic_string<CharT,Traits,A> str_t; + typedef typename str_t::reserve_t reserve_t; + reserve_t reserve; + str_t result(reserve, x.size() + 1, x.get_stored_allocator()); + result.append(x); + result.push_back(c); + return boost::move(result); +} + +template <class CharT, class Traits, class A> +BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) +operator+( BOOST_RV_REF_3_TEMPL_ARGS(basic_string, CharT, Traits, A) mx + , const CharT c) +{ + mx += c; + return boost::move(mx); +} + +// Operator== and operator!= + +template <class CharT, class Traits, class A> +inline bool +operator==(const basic_string<CharT,Traits,A>& x, + const basic_string<CharT,Traits,A>& y) +{ + return x.size() == y.size() && + Traits::compare(x.data(), y.data(), x.size()) == 0; +} + +template <class CharT, class Traits, class A> +inline bool +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; +} + +template <class CharT, class Traits, class A> +inline bool +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; +} + +template <class CharT, class Traits, class A> +inline bool +operator!=(const basic_string<CharT,Traits,A>& x, + 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) + { return !(s == y); } + +template <class CharT, class Traits, class A> +inline bool +operator!=(const basic_string<CharT,Traits,A>& x, const CharT* s) + { return !(x == s); } + + +// Operator< (and also >, <=, and >=). + +template <class CharT, class Traits, class A> +inline bool +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> +// ::s_compare(x.begin(), x.end(), y.begin(), y.end()) < 0; +} + +template <class CharT, class Traits, class A> +inline bool +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); +// return basic_string<CharT,Traits,A> +// ::s_compare(s, s + n, y.begin(), y.end()) < 0; +} + +template <class CharT, class Traits, class A> +inline bool +operator<(const basic_string<CharT,Traits,A>& x, + const CharT* s) +{ + return x.compare(s) < 0; +// basic_string<CharT,Traits,A>::size_type n = Traits::length(s); +// return basic_string<CharT,Traits,A> +// ::s_compare(x.begin(), x.end(), s, s + n) < 0; +} + +template <class CharT, class Traits, class A> +inline bool +operator>(const basic_string<CharT,Traits,A>& x, + 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) { + return y < s; +} + +template <class CharT, class Traits, class A> +inline bool +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) +{ + return !(y < x); +} + +template <class CharT, class Traits, class A> +inline bool +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) + { 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) + { return !(x < y); } + +template <class CharT, class Traits, class A> +inline bool +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) + { 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) +{ x.swap(y); } + +/// @cond +// I/O. +namespace container_detail { + +template <class CharT, class Traits> +inline bool +string_fill(std::basic_ostream<CharT, Traits>& os, + std::basic_streambuf<CharT, Traits>* buf, + std::size_t n) +{ + CharT f = os.fill(); + std::size_t i; + bool ok = true; + + for (i = 0; i < n; i++) + ok = ok && !Traits::eq_int_type(buf->sputc(f), Traits::eof()); + return ok; +} + +} //namespace container_detail { +/// @endcond + +template <class CharT, class Traits, class A> +std::basic_ostream<CharT, Traits>& +operator<<(std::basic_ostream<CharT, Traits>& os, const basic_string<CharT,Traits,A>& s) +{ + typename std::basic_ostream<CharT, Traits>::sentry sentry(os); + bool ok = false; + + if (sentry) { + ok = true; + typename basic_string<CharT,Traits,A>::size_type n = s.size(); + typename basic_string<CharT,Traits,A>::size_type pad_len = 0; + const bool left = (os.flags() & std::ios::left) != 0; + const std::size_t w = os.width(0); + std::basic_streambuf<CharT, Traits>* buf = os.rdbuf(); + + if (w != 0 && n < w) + pad_len = w - n; + + if (!left) + ok = container_detail::string_fill(os, buf, pad_len); + + ok = ok && + buf->sputn(s.data(), std::streamsize(n)) == std::streamsize(n); + + if (left) + ok = ok && container_detail::string_fill(os, buf, pad_len); + } + + if (!ok) + os.setstate(std::ios_base::failbit); + + return os; +} + + +template <class CharT, class Traits, class A> +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); + + if (sentry) { + std::basic_streambuf<CharT, Traits>* buf = is.rdbuf(); + const std::ctype<CharT>& ctype = std::use_facet<std::ctype<CharT> >(is.getloc()); + + s.clear(); + std::size_t n = is.width(0); + if (n == 0) + n = static_cast<std::size_t>(-1); + else + s.reserve(n); + + while (n-- > 0) { + typename Traits::int_type c1 = buf->sbumpc(); + + if (Traits::eq_int_type(c1, Traits::eof())) { + is.setstate(std::ios_base::eofbit); + break; + } + else { + CharT c = Traits::to_char_type(c1); + + if (ctype.is(std::ctype<CharT>::space, c)) { + if (Traits::eq_int_type(buf->sputbackc(c), Traits::eof())) + is.setstate(std::ios_base::failbit); + break; + } + else + s.push_back(c); + } + } + + // If we have read no characters, then set failbit. + if (s.size() == 0) + is.setstate(std::ios_base::failbit); + } + else + is.setstate(std::ios_base::failbit); + + return is; +} + +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; + typename std::basic_istream<CharT, Traits>::sentry sentry(is, true); + if (sentry) { + std::basic_streambuf<CharT, Traits>* buf = is.rdbuf(); + s.clear(); + + while (nread < s.max_size()) { + int c1 = buf->sbumpc(); + if (Traits::eq_int_type(c1, Traits::eof())) { + is.setstate(std::ios_base::eofbit); + break; + } + else { + ++nread; + CharT c = Traits::to_char_type(c1); + if (!Traits::eq(c, delim)) + s.push_back(c); + else + break; // Character is extracted but not appended. + } + } + } + if (nread == 0 || nread >= s.max_size()) + is.setstate(std::ios_base::failbit); + + return is; +} + +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'); +} + +template <class Ch, class A> +inline std::size_t hash_value(basic_string<Ch, std::char_traits<Ch>, A> const& v) +{ + return hash_range(v.begin(), v.end()); +} + +}} + +/// @cond + +namespace boost { +/* +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class C, class T, class A> +struct has_trivial_destructor_after_move<boost::container::basic_string<C, T, A> > +{ + static const bool value = has_trivial_destructor<A>::value; +}; +*/ +} + +/// @endcond + +#include <boost/container/detail/config_end.hpp> + +#endif // BOOST_CONTAINER_STRING_HPP diff --git a/src/third_party/boost/boost/container/vector.hpp b/src/third_party/boost/boost/container/vector.hpp new file mode 100644 index 00000000000..742d00d37ef --- /dev/null +++ b/src/third_party/boost/boost/container/vector.hpp @@ -0,0 +1,2036 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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_CONTAINER_VECTOR_HPP +#define BOOST_CONTAINER_CONTAINER_VECTOR_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/container_fwd.hpp> + +#include <cstddef> +#include <memory> +#include <algorithm> +#include <stdexcept> +#include <iterator> +#include <utility> +#include <boost/detail/no_exceptions_support.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#include <boost/type_traits/has_trivial_copy.hpp> +#include <boost/type_traits/has_trivial_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/container/detail/version_type.hpp> +#include <boost/container/detail/allocation_type.hpp> +#include <boost/container/detail/utilities.hpp> +#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/container_fwd.hpp> +#include <boost/move/move.hpp> +#include <boost/move/move_helpers.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/container/detail/mpl.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/advanced_insert_int.hpp> + +namespace boost { +namespace container { + +/// @cond + +namespace container_detail { + +//! Const vector_iterator used to iterate through a vector. +template <class Pointer> +class vector_const_iterator +{ + public: + typedef std::random_access_iterator_tag iterator_category; + typedef typename boost::intrusive::pointer_traits<Pointer>::element_type value_type; + typedef typename boost::intrusive::pointer_traits<Pointer>::difference_type difference_type; + typedef typename boost::intrusive::pointer_traits<Pointer>::template + rebind_pointer<const value_type>::type pointer; + typedef const value_type& reference; + + /// @cond + protected: + Pointer m_ptr; + + public: + Pointer get_ptr() const { return m_ptr; } + explicit vector_const_iterator(Pointer ptr) : m_ptr(ptr){} + /// @endcond + + public: + + //Constructors + vector_const_iterator() : m_ptr(0){} + + //Pointer like operators + reference operator*() const + { return *m_ptr; } + + 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++() + { ++m_ptr; return *this; } + + vector_const_iterator operator++(int) + { Pointer tmp = m_ptr; ++*this; return vector_const_iterator(tmp); } + + vector_const_iterator& operator--() + { --m_ptr; return *this; } + + vector_const_iterator operator--(int) + { Pointer tmp = m_ptr; --*this; return vector_const_iterator(tmp); } + + //Arithmetic + vector_const_iterator& operator+=(difference_type off) + { m_ptr += off; return *this; } + + vector_const_iterator operator+(difference_type off) const + { return vector_const_iterator(m_ptr+off); } + + friend vector_const_iterator operator+(difference_type off, const vector_const_iterator& right) + { return vector_const_iterator(off + right.m_ptr); } + + vector_const_iterator& operator-=(difference_type off) + { m_ptr -= off; return *this; } + + vector_const_iterator operator-(difference_type off) const + { return vector_const_iterator(m_ptr-off); } + + difference_type operator-(const vector_const_iterator& right) const + { return m_ptr - right.m_ptr; } + + //Comparison operators + bool operator== (const vector_const_iterator& r) const + { return m_ptr == r.m_ptr; } + + bool operator!= (const vector_const_iterator& r) const + { return m_ptr != r.m_ptr; } + + bool operator< (const vector_const_iterator& r) const + { return m_ptr < r.m_ptr; } + + bool operator<= (const vector_const_iterator& r) const + { return m_ptr <= r.m_ptr; } + + bool operator> (const vector_const_iterator& r) const + { return m_ptr > r.m_ptr; } + + bool operator>= (const vector_const_iterator& r) const + { return m_ptr >= r.m_ptr; } +}; + +//! Iterator used to iterate through a vector +template <class Pointer> +class vector_iterator + : public vector_const_iterator<Pointer> +{ + public: + explicit vector_iterator(Pointer ptr) + : vector_const_iterator<Pointer>(ptr) + {} + + public: + typedef std::random_access_iterator_tag iterator_category; + typedef typename boost::intrusive::pointer_traits<Pointer>::element_type value_type; + typedef typename boost::intrusive::pointer_traits<Pointer>::difference_type difference_type; + typedef Pointer pointer; + typedef value_type& reference; + + //Constructors + vector_iterator() + {} + + //Pointer like operators + reference operator*() const + { return *this->m_ptr; } + + value_type* operator->() const + { return container_detail::to_raw_pointer(this->m_ptr); } + + reference operator[](difference_type off) const + { return this->m_ptr[off]; } + + //Increment / Decrement + 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; } + + vector_iterator operator--(int) + { vector_iterator tmp = *this; --*this; return vector_iterator(tmp); } + + // Arithmetic + vector_iterator& operator+=(difference_type off) + { this->m_ptr += off; return *this; } + + vector_iterator operator+(difference_type off) const + { return vector_iterator(this->m_ptr+off); } + + friend vector_iterator operator+(difference_type off, const vector_iterator& right) + { return vector_iterator(off + right.m_ptr); } + + vector_iterator& operator-=(difference_type off) + { this->m_ptr -= off; return *this; } + + vector_iterator operator-(difference_type off) const + { return vector_iterator(this->m_ptr-off); } + + difference_type operator-(const vector_const_iterator<Pointer>& right) const + { return static_cast<const vector_const_iterator<Pointer>&>(*this) - right; } +}; + +template <class T, class A> +struct vector_value_traits +{ + typedef T value_type; + typedef A allocator_type; + static const bool trivial_dctr = boost::has_trivial_destructor<value_type>::value; + static const bool trivial_dctr_after_move = trivial_dctr; + //::boost::has_trivial_destructor_after_move<value_type>::value || trivial_dctr; + //static const bool trivial_copy = has_trivial_copy<value_type>::value; + //static const bool nothrow_copy = has_nothrow_copy<value_type>::value; + //static const bool trivial_assign = has_trivial_assign<value_type>::value; + //static const bool nothrow_assign = has_nothrow_assign<value_type>::value; + + static const bool trivial_copy = has_trivial_copy<value_type>::value; + static const bool nothrow_copy = has_nothrow_copy<value_type>::value; + static const bool trivial_assign = has_trivial_assign<value_type>::value; + static const bool nothrow_assign = false; + + //This is the anti-exception array destructor + //to deallocate values already constructed + typedef typename container_detail::if_c + <trivial_dctr + ,container_detail::null_scoped_destructor_n<A> + ,container_detail::scoped_destructor_n<A> + >::type OldArrayDestructor; + //This is the anti-exception array destructor + //to destroy objects created with copy construction + typedef typename container_detail::if_c + <nothrow_copy + ,container_detail::null_scoped_destructor_n<A> + ,container_detail::scoped_destructor_n<A> + >::type ArrayDestructor; + //This is the anti-exception array deallocator + typedef typename container_detail::if_c + <nothrow_copy + ,container_detail::null_scoped_array_deallocator<A> + ,container_detail::scoped_array_deallocator<A> + >::type ArrayDeallocator; +}; + +//!This struct deallocates and allocated memory +template <class A> +struct vector_alloc_holder +{ + typedef boost::container::allocator_traits<A> allocator_traits_type; + typedef typename allocator_traits_type::pointer pointer; + typedef typename allocator_traits_type::size_type size_type; + typedef typename allocator_traits_type::value_type value_type; + typedef vector_value_traits<value_type, A> value_traits; + + //Constructor, does not throw + vector_alloc_holder() + BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor<A>::value) + : members_() + {} + + //Constructor, does not throw + template<class AllocConvertible> + explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_CONTAINER_NOEXCEPT + : members_(boost::forward<AllocConvertible>(a)) + {} + + //Destructor + ~vector_alloc_holder() + { + this->prot_destroy_all(); + this->prot_deallocate(); + } + + typedef container_detail::integral_constant<unsigned, 1> allocator_v1; + typedef container_detail::integral_constant<unsigned, 2> allocator_v2; + typedef container_detail::integral_constant<unsigned, + boost::container::container_detail::version<A>::value> alloc_version; + std::pair<pointer, bool> + allocation_command(allocation_type command, + size_type limit_size, + size_type preferred_size, + size_type &received_size, const pointer &reuse = 0) + { + return allocation_command(command, limit_size, preferred_size, + received_size, reuse, alloc_version()); + } + + std::pair<pointer, bool> + allocation_command(allocation_type command, + size_type limit_size, + size_type preferred_size, + size_type &received_size, + const pointer &reuse, + allocator_v1) + { + (void)limit_size; + (void)reuse; + if(!(command & allocate_new)) + return std::pair<pointer, bool>(pointer(0), false); + received_size = preferred_size; + return std::make_pair(this->alloc().allocate(received_size), false); + } + + std::pair<pointer, bool> + allocation_command(allocation_type command, + size_type limit_size, + size_type preferred_size, + size_type &received_size, + const pointer &reuse, + allocator_v2) + { + 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->members_.m_capacity, additional_objects); + } + + struct members_holder + : public A + { + private: + members_holder(const members_holder&); + + public: + template<class Alloc> + explicit members_holder(BOOST_FWD_REF(Alloc) alloc) + : A(boost::forward<Alloc>(alloc)), m_start(0), m_size(0), m_capacity(0) + {} + + members_holder() + : A(), m_start(0), m_size(0), m_capacity(0) + {} + + pointer m_start; + size_type m_size; + size_type m_capacity; + } members_; + + void swap_members(vector_alloc_holder &x) + { + container_detail::do_swap(this->members_.m_start, x.members_.m_start); + container_detail::do_swap(this->members_.m_size, x.members_.m_size); + container_detail::do_swap(this->members_.m_capacity, x.members_.m_capacity); + } + + A &alloc() + { return members_; } + + const A &alloc() const + { return members_; } + + protected: + void prot_deallocate() + { + if(!this->members_.m_capacity) return; + this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity); + this->members_.m_start = 0; + this->members_.m_size = 0; + this->members_.m_capacity = 0; + } + + void destroy(value_type* p) + { + if(!value_traits::trivial_dctr) + allocator_traits_type::destroy(this->alloc(), p); + } + + void destroy_n(value_type* p, size_type n) + { + if(!value_traits::trivial_dctr){ + for(; n--; ++p){ + allocator_traits_type::destroy(this->alloc(), p); + } + } + } + + void prot_destroy_all() + { + this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size); + this->members_.m_size = 0; + } +}; + +} //namespace container_detail { +/// @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 +//! 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. +#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED +template <class T, class A = std::allocator<T> > +#else +template <class T, class A> +#endif +class vector : private container_detail::vector_alloc_holder<A> +{ + /// @cond + typedef vector<T, A> self_t; + typedef container_detail::vector_alloc_holder<A> base_t; + typedef allocator_traits<A> allocator_traits_type; + /// @endcond + public: + //! The type of object, T, stored in the vector + typedef T value_type; + //! Pointer to T + typedef typename allocator_traits_type::pointer pointer; + //! Const pointer to T + typedef typename allocator_traits_type::const_pointer const_pointer; + //! Reference to T + typedef typename allocator_traits_type::reference reference; + //! Const reference to T + typedef typename allocator_traits_type::const_reference const_reference; + //! An unsigned integral type + typedef typename allocator_traits_type::size_type size_type; + //! A signed integral type + typedef typename allocator_traits_type::difference_type difference_type; + //! The allocator type + typedef A allocator_type; + //! The random access iterator + typedef container_detail::vector_iterator<pointer> iterator; + //! 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> + reverse_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; + + /// @cond + private: + BOOST_COPYABLE_AND_MOVABLE(vector) + typedef container_detail::advanced_insert_aux_int<T*> advanced_insert_aux_int_t; + typedef container_detail::vector_value_traits<value_type, A> value_traits; + + typedef typename base_t::allocator_v1 allocator_v1; + typedef typename base_t::allocator_v2 allocator_v2; + typedef typename base_t::alloc_version alloc_version; + + typedef constant_iterator<T, difference_type> cvalue_iterator; + typedef repeat_iterator<T, difference_type> repeat_it; + typedef boost::move_iterator<repeat_it> repeat_move_it; + /// @endcond + + 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) + : base_t() + {} + + //! <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) + {} + + //! <b>Effects</b>: Constructs a vector that will use a copy of allocator a + //! and inserts n default contructed values. + //! + //! <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() + { + //Allocate + size_type real_cap; + std::pair<pointer, bool> ret = + this->allocation_command(allocate_new, n, n, real_cap, this->members_.m_start); + T *new_mem = container_detail::to_raw_pointer(ret.first); + //Anti-exception rollback + typename value_traits::ArrayDeallocator scoped_alloc(new_mem, this->alloc(), real_cap); + //Default constructor + container_detail::default_construct_aux_proxy<A, T*> proxy(this->alloc(), n); + proxy.uninitialized_copy_remaining_to(new_mem); + //All ok, commit + this->members_.m_start = ret.first; + this->members_.m_size = n; + this->members_.m_capacity = real_cap; + scoped_alloc.release(); + } + + //! <b>Effects</b>: Constructs a vector that will use a copy of allocator a + //! and inserts n copies of value. + //! + //! <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()) + : 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) + : base_t(allocator_traits_type::select_on_container_copy_construction(x.alloc())) + { + 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. 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>: Constructs a vector that will use a copy of allocator a + //! and inserts a copy of the range [first, last) in the vector. + //! + //! <b>Throws</b>: If allocator_type's default constructor or allocation + //! throws or T's constructor taking an dereferenced InIt throws. + //! + //! <b>Complexity</b>: Linear to the range [first, last). + template <class InIt> + vector(InIt first, InIt last, const allocator_type& a = allocator_type()) + : base_t(a) + { this->assign(first, last); } + + //! <b>Effects</b>: Destroys the vector. All stored values are destroyed + //! and used memory is deallocated. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements. + ~vector() BOOST_CONTAINER_NOEXCEPT + {} //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>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>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. + //! + //! <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. + //! + //! <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>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. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT + { return const_reverse_iterator(this->begin()); } + + //! <b>Requires</b>: !empty() + //! + //! <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 of the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_reference front() const BOOST_CONTAINER_NOEXCEPT + { return *this->members_.m_start; } + + //! <b>Requires</b>: !empty() + //! + //! <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]; } + + //! <b>Requires</b>: !empty() + //! + //! <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 + //! from the beginning of the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + 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 + //! 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 + //! 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_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 + //! 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(); } + + //! <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/move constructor throws. + void reserve(size_type new_cap) + { + if (this->capacity() < new_cap){ + //There is not enough memory, allocate a new + //buffer or expand the old one. + bool same_buffer_start; + size_type real_cap = 0; + std::pair<pointer, bool> ret = + this->allocation_command + (allocate_new | expand_fwd | expand_bwd, + new_cap, new_cap, real_cap, this->members_.m_start); + + //Check for forward expansion + same_buffer_start = ret.second && this->members_.m_start == ret.first; + if(same_buffer_start){ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_expand_fwd; + #endif + this->members_.m_capacity = real_cap; + } + + //If there is no forward expansion, move objects + else{ + //We will reuse insert code, so create a dummy input iterator + T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start)); + container_detail::advanced_insert_aux_proxy<A, boost::move_iterator<T*>, T*> + proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it)); + //Backwards (and possibly forward) expansion + if(ret.second){ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_expand_bwd; + #endif + this->priv_range_insert_expand_backwards + ( container_detail::to_raw_pointer(ret.first) + , real_cap + , container_detail::to_raw_pointer(this->members_.m_start) + , 0 + , proxy); + } + //New buffer + else{ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif + this->priv_range_insert_new_allocation + ( container_detail::to_raw_pointer(ret.first) + , real_cap + , container_detail::to_raw_pointer(this->members_.m_start) + , 0 + , proxy); + } + } + } + } + + //! <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>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment throws. + //! + //! <b>Complexity</b>: Linear to the number of elements in x. + vector& operator=(BOOST_COPY_ASSIGN_REF(vector) x) + { + if (&x != this){ + allocator_type &this_alloc = this->alloc(); + const allocator_type &x_alloc = x.alloc(); + container_detail::bool_<allocator_traits_type:: + propagate_on_container_copy_assignment::value> flag; + if(flag && this_alloc != x_alloc){ + this->clear(); + this->shrink_to_fit(); + } + container_detail::assign_alloc(this_alloc, x_alloc, flag); + this->assign( container_detail::to_raw_pointer(x.members_.m_start) + , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size)); + } + return *this; + } + + //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this. + //! + //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had + //! before the function. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Complexity</b>: Linear. + vector& operator=(BOOST_RV_REF(vector) x) + //iG BOOST_CONTAINER_NOEXCEPT_IF(!allocator_type::propagate_on_container_move_assignment::value || is_nothrow_move_assignable<allocator_type>::value);) + BOOST_CONTAINER_NOEXCEPT + { + if (&x != this){ + allocator_type &this_alloc = this->alloc(); + allocator_type &x_alloc = x.alloc(); + //If allocators are equal we can just swap pointers + if(this_alloc == x_alloc){ + //Destroy objects but retain memory in case x reuses it in the future + this->clear(); + this->swap_members(x); + //Move allocator if needed + container_detail::bool_<allocator_traits_type:: + propagate_on_container_move_assignment::value> flag; + container_detail::move_alloc(this_alloc, x_alloc, flag); + } + //If unequal allocators, then do a one by one move + else{ + this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start)) + , boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size))); + } + } + return *this; + } + + //! <b>Effects</b>: Assigns the n copies of val to *this. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy/move constructor/assignment throws. + //! + //! <b>Complexity</b>: Linear to n. + void assign(size_type n, const value_type& val) + { this->assign(cvalue_iterator(val, n), cvalue_iterator()); } + + //! <b>Effects</b>: Assigns the the range [first, last) to *this. + //! + //! <b>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment or + //! T's constructor/assignment from dereferencing InpIt throws. + //! + //! <b>Complexity</b>: Linear to n. + template <class InIt> + void assign(InIt first, InIt last) + { + //Dispatch depending on integer/iterator + const bool aux_boolean = container_detail::is_convertible<InIt, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_assign_dispatch(first, last, Result()); + } + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! <b>Effects</b>: Inserts a copy of x at the end of the vector. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's copy/move constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_back(const T &x); + + //! <b>Effects</b>: Constructs a new element in the end of the vector + //! and moves the resources of mx to this new element. + //! + //! <b>Throws</b>: If memory allocation throws or + //! T's move constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + void push_back(T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back) + #endif + + #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)... in the end of the vector. + //! + //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws or + //! T's move constructor throws. + //! + //! <b>Complexity</b>: Amortized constant time. + template<class ...Args> + void emplace_back(Args &&...args) + { + T* back_pos = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size; + if (this->members_.m_size < this->members_.m_capacity){ + //There is more memory, just construct a new object at the end + allocator_traits_type::construct(this->alloc(), back_pos, ::boost::forward<Args>(args)...); + ++this->members_.m_size; + } + else{ + typedef container_detail::advanced_insert_aux_emplace<A, T*, Args...> type; + type &&proxy = type(this->alloc(), ::boost::forward<Args>(args)...); + priv_range_insert(back_pos, 1, proxy); + } + } + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts an object of type T constructed with + //! std::forward<Args>(args)... before position + //! + //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws or + //! T's move constructor/assignment throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + template<class ...Args> + iterator emplace(const_iterator position, Args && ...args) + { + //Just call more general insert(pos, size, value) and return iterator + size_type pos_n = position - cbegin(); + typedef container_detail::advanced_insert_aux_emplace<A, T*, Args...> type; + type &&proxy = type(this->alloc(), ::boost::forward<Args>(args)...); + priv_range_insert(position.get_ptr(), 1, proxy); + return iterator(this->members_.m_start + pos_n); + } + + #else + + #define BOOST_PP_LOCAL_MACRO(n) \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + T* back_pos = container_detail::to_raw_pointer \ + (this->members_.m_start) + this->members_.m_size; \ + if (this->members_.m_size < this->members_.m_capacity){ \ + allocator_traits_type::construct (this->alloc() \ + , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ + ++this->members_.m_size; \ + } \ + else{ \ + container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ + <A, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \ + (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + priv_range_insert(back_pos, 1, proxy); \ + } \ + } \ + \ + BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ + iterator emplace(const_iterator pos \ + BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + { \ + size_type pos_n = pos - cbegin(); \ + container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \ + <A, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \ + (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + priv_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy); \ + return iterator(this->members_.m_start + pos_n); \ + } \ + //! + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) + #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. + //! + //! <b>Complexity</b>: Constant. + void swap(vector& x) + { + //Just swap internals + this->swap_members(x); + //And now the allocator + container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag; + container_detail::swap_alloc(this->alloc(), x.alloc(), flag); + } + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of x before position. + //! + //! <b>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + iterator insert(const_iterator position, const T &x); + + //! <b>Requires</b>: position must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a new element before position with mx's resources. + //! + //! <b>Throws</b>: If memory allocation throws. + //! + //! <b>Complexity</b>: If position is end(), amortized constant time + //! Linear time otherwise. + iterator insert(const_iterator position, T &&x); + #else + BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator) + #endif + + //! <b>Requires</b>: pos must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert a copy of the [first, last) range before pos. + //! + //! <b>Throws</b>: If memory allocation throws, T's constructor from a + //! dereferenced InpIt throws or T's copy/move constructor/assignment throws. + //! + //! <b>Complexity</b>: Linear to std::distance [first, last). + template <class InIt> + void insert(const_iterator pos, InIt first, InIt last) + { + //Dispatch depending on integer/iterator + const bool aux_boolean = container_detail::is_convertible<InIt, size_type>::value; + typedef container_detail::bool_<aux_boolean> Result; + this->priv_insert_dispatch(pos, first, last, Result()); + } + + //! <b>Requires</b>: pos must be a valid iterator of *this. + //! + //! <b>Effects</b>: Insert n copies of x before pos. + //! + //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws. + //! + //! <b>Complexity</b>: Linear to n. + void insert(const_iterator p, size_type n, const T& x) + { this->insert(p, cvalue_iterator(x, n), cvalue_iterator()); } + + //! <b>Effects</b>: Removes the last element from the vector. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + void pop_back() + { + //Destroy last element + --this->members_.m_size; + this->destroy(container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size); + } + + //! <b>Effects</b>: Erases the element at position pos. + //! + //! <b>Throws</b>: Nothing. + //! + //! <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) + { + T *pos = container_detail::to_raw_pointer(position.get_ptr()); + T *beg = container_detail::to_raw_pointer(this->members_.m_start); + ::boost::move(pos + 1, beg + this->members_.m_size, pos); + --this->members_.m_size; + //Destroy last element + base_t::destroy(container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size); + return iterator(position.get_ptr()); + } + + //! <b>Effects</b>: Erases the elements pointed by [first, last). + //! + //! <b>Throws</b>: Nothing. + //! + //! <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) + { + 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; + T* ptr = container_detail::to_raw_pointer(boost::move + (container_detail::to_raw_pointer(last.get_ptr()) + ,end_pos + ,container_detail::to_raw_pointer(first.get_ptr()) + )); + size_type destroyed = (end_pos - ptr); + this->destroy_n(ptr, destroyed); + this->members_.m_size -= destroyed; + } + return iterator(first.get_ptr()); + } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are copy constructed from x. + //! + //! <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) + { + pointer finish = this->members_.m_start + this->members_.m_size; + if (new_size < size()){ + //Destroy last elements + this->erase(const_iterator(this->members_.m_start + new_size), this->end()); + } + else{ + //Insert new elements at the end + this->insert(const_iterator(finish), new_size - this->size(), x); + } + } + + //! <b>Effects</b>: Inserts or erases elements at the end such that + //! the size becomes n. New elements are default constructed. + //! + //! <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) + { + if (new_size < this->size()){ + //Destroy last elements + this->erase(const_iterator(this->members_.m_start + new_size), this->end()); + } + else{ + size_type n = new_size - this->size(); + this->reserve(new_size); + container_detail::default_construct_aux_proxy<A, T*> proxy(this->alloc(), n); + priv_range_insert(this->cend().get_ptr(), n, proxy); + } + } + + //! <b>Effects</b>: Erases all the elements of the vector. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements in the vector. + void clear() BOOST_CONTAINER_NOEXCEPT + { this->prot_destroy_all(); } + + //! <b>Effects</b>: Tries to deallocate the excess of memory created + //! with previous allocations. The size of the vector is unchanged + //! + //! <b>Throws</b>: If memory allocation throws, or T's copy/move constructor throws. + //! + //! <b>Complexity</b>: Linear to size(). + void shrink_to_fit() + { priv_shrink_to_fit(alloc_version()); } + + /// @cond + + private: + 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(); + this->insert(position, (size_type)1, x); + return iterator(this->members_.m_start + pos_n); + } + + 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(); + this->insert(position + ,repeat_move_it(repeat_it(x, 1)) + ,repeat_move_it(repeat_it())); + return iterator(this->members_.m_start + pos_n); + } + + template <class U> + void priv_push_back(BOOST_MOVE_CATCH_FWD(U) x) + { + if (this->members_.m_size < this->members_.m_capacity){ + //There is more memory, just construct a new object at the end + allocator_traits_type::construct + ( this->alloc() + , container_detail::to_raw_pointer(this->members_.m_start + this->members_.m_size) + , ::boost::forward<U>(x) ); + ++this->members_.m_size; + } + else{ + this->insert(this->cend(), ::boost::forward<U>(x)); + } + } + + template<class AllocVersion> + void priv_shrink_to_fit( AllocVersion + , typename container_detail::enable_if_c< + container_detail::is_same<AllocVersion, allocator_v1>::value >::type * = 0) + { + if(this->members_.m_capacity){ + if(!size()){ + this->prot_deallocate(); + } + else{ + //Allocate a new buffer. + size_type real_cap = 0; + std::pair<pointer, bool> ret = + this->allocation_command + (allocate_new, this->size(), this->size(), real_cap, this->members_.m_start); + if(real_cap < this->capacity()){ + //We will reuse insert code, so create a dummy input iterator + T *dummy_it(container_detail::to_raw_pointer(this->members_.m_start)); + container_detail::advanced_insert_aux_proxy<A, boost::move_iterator<T*>, T*> + proxy(this->alloc(), ::boost::make_move_iterator(dummy_it), ::boost::make_move_iterator(dummy_it)); + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif + this->priv_range_insert_new_allocation + ( container_detail::to_raw_pointer(ret.first) + , real_cap + , container_detail::to_raw_pointer(this->members_.m_start) + , 0 + , proxy); + } + else{ + this->alloc().deallocate(ret.first, real_cap); + } + } + } + } + + template<class AllocVersion> + void priv_shrink_to_fit(AllocVersion + , typename container_detail::enable_if_c< + !container_detail::is_same<AllocVersion, allocator_v1>::value >::type * = 0) + { + if(this->members_.m_capacity){ + if(!size()){ + this->prot_deallocate(); + } + else{ + size_type received_size; + if(this->alloc().allocation_command + ( shrink_in_place | nothrow_allocation + , this->capacity(), this->size() + , received_size, this->members_.m_start).first){ + this->members_.m_capacity = received_size; + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_shrink; + #endif + } + } + } + } + + template <class FwdIt> + void priv_range_insert(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag) + { + 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); + } + } + + template <class InIt> + void priv_range_insert(const_iterator pos, InIt first, InIt last, std::input_iterator_tag) + { + for(;first != last; ++first){ + this->emplace(pos, *first); + } + } + + void priv_range_insert(pointer pos, const size_type n, advanced_insert_aux_int_t &interf) + { + //Check if we have enough memory or try to expand current memory + size_type remaining = this->members_.m_capacity - this->members_.m_size; + bool same_buffer_start; + std::pair<pointer, bool> ret; + size_type real_cap = this->members_.m_capacity; + + //Check if we already have room + if (n <= remaining){ + same_buffer_start = true; + } + else{ + //There is not enough memory, allocate a new + //buffer or expand the old one. + size_type new_cap = this->next_capacity(n); + ret = this->allocation_command + (allocate_new | expand_fwd | expand_bwd, + this->members_.m_size + n, new_cap, real_cap, this->members_.m_start); + + //Check for forward expansion + same_buffer_start = ret.second && this->members_.m_start == ret.first; + if(same_buffer_start){ + 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 + ++this->num_expand_fwd; + #endif + this->priv_range_insert_expand_forward + (container_detail::to_raw_pointer(pos), n, interf); + } + //Backwards (and possibly forward) expansion + else if(ret.second){ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_expand_bwd; + #endif + this->priv_range_insert_expand_backwards + ( container_detail::to_raw_pointer(ret.first) + , real_cap + , container_detail::to_raw_pointer(pos) + , n + , interf); + } + //New buffer + else{ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif + this->priv_range_insert_new_allocation + ( container_detail::to_raw_pointer(ret.first) + , real_cap + , container_detail::to_raw_pointer(pos) + , n + , interf); + } + } + + 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 + if(!n) return; + //There is enough memory + T* old_finish = container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size; + const size_type elems_after = old_finish - pos; + + if (elems_after >= n){ + //New elements can be just copied. + //Move to uninitialized memory last objects + ::boost::container::uninitialized_move_alloc + (this->alloc(), old_finish - n, old_finish, old_finish); + this->members_.m_size += n; + //Copy previous to last objects to the initialized end + boost::move_backward(pos, old_finish - n, old_finish); + //Insert new objects in the pos + interf.copy_remaining_to(pos); + } + else { + //The new elements don't fit in the [pos, end()) range. Copy + //to the beginning of the unallocated zone the last new elements. + interf.uninitialized_copy_some_and_update(old_finish, elems_after, false); + this->members_.m_size += n - elems_after; + //Copy old [pos, end()) elements to the uninitialized memory + ::boost::container::uninitialized_move_alloc + (this->alloc(), pos, old_finish, container_detail::to_raw_pointer(this->members_.m_start) + this->members_.m_size); + this->members_.m_size += elems_after; + //Copy first new elements in pos + interf.copy_remaining_to(pos); + } + } + + void priv_range_insert_new_allocation + (T* new_start, size_type new_cap, T* pos, size_type n, advanced_insert_aux_int_t &interf) + { + //n can be zero, if we want to reallocate! + T *new_finish = new_start; + T *old_finish; + //Anti-exception rollbacks + 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 + //the start of the new buffer + T *old_buffer = container_detail::to_raw_pointer(this->members_.m_start); + if(old_buffer){ + new_finish = ::boost::container::uninitialized_move_alloc + (this->alloc(), container_detail::to_raw_pointer(this->members_.m_start), pos, old_finish = new_finish); + constructed_values_destroyer.increment_size(new_finish - old_finish); + } + //Initialize new objects, starting from previous point + 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, + //starting from previous point + if(old_buffer){ + new_finish = ::boost::container::uninitialized_move_alloc + (this->alloc(), pos, old_buffer + this->members_.m_size, new_finish); + //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->alloc().deallocate(this->members_.m_start, this->members_.m_capacity); + } + this->members_.m_start = new_start; + this->members_.m_size = new_finish - new_start; + this->members_.m_capacity = new_cap; + //All construction successful, disable rollbacks + constructed_values_destroyer.release(); + scoped_alloc.release(); + } + + void priv_range_insert_expand_backwards + (T* new_start, size_type new_capacity, + T* pos, const size_type n, advanced_insert_aux_int_t &interf) + { + //n can be zero to just expand capacity + //Backup old data + T* old_start = container_detail::to_raw_pointer(this->members_.m_start); + T* old_finish = old_start + this->members_.m_size; + size_type old_size = this->members_.m_size; + + //We can have 8 possibilities: + const size_type elemsbefore = (size_type)(pos - old_start); + const size_type s_before = (size_type)(old_start - new_start); + + //Update the vector buffer information to a safe state + this->members_.m_start = new_start; + this->members_.m_capacity = new_capacity; + this->members_.m_size = 0; + + //If anything goes wrong, this object will destroy + //all the old objects to fulfill previous vector state + typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size); + //Check if s_before is big enough to hold the beginning of old data + new data + if(difference_type(s_before) >= difference_type(elemsbefore + n)){ + //Copy first old values before pos, after that the new objects + ::boost::container::uninitialized_move_alloc(this->alloc(), old_start, pos, new_start); + this->members_.m_size = elemsbefore; + interf.uninitialized_copy_remaining_to(new_start + elemsbefore); + this->members_.m_size += n; + //Check if s_before is so big that even copying the old data + new data + //there is a gap between the new data and the old data + if(s_before >= (old_size + n)){ + //Old situation: + // _________________________________________________________ + //| raw_mem | old_begin | old_end | + //| __________________________________|___________|_________| + // + //New situation: + // _________________________________________________________ + //| old_begin | new | old_end | raw_mem | + //|___________|__________|_________|________________________| + // + //Now initialize the rest of memory with the last old values + ::boost::container::uninitialized_move_alloc + (this->alloc(), pos, old_finish, new_start + elemsbefore + n); + //All new elements correctly constructed, avoid new element destruction + this->members_.m_size = old_size + n; + //Old values destroyed automatically with "old_values_destroyer" + //when "old_values_destroyer" goes out of scope unless the have trivial + //destructor after move. + if(value_traits::trivial_dctr_after_move) + old_values_destroyer.release(); + } + //s_before is so big that divides old_end + else{ + //Old situation: + // __________________________________________________ + //| raw_mem | old_begin | old_end | + //| ___________________________|___________|_________| + // + //New situation: + // __________________________________________________ + //| old_begin | new | old_end | raw_mem | + //|___________|__________|_________|_________________| + // + //Now initialize the rest of memory with the last old values + //All new elements correctly constructed, avoid new element destruction + size_type raw_gap = s_before - (elemsbefore + n); + //Now initialize the rest of s_before memory with the + //first of elements after new values + ::boost::container::uninitialized_move_alloc + (this->alloc(), pos, pos + raw_gap, new_start + elemsbefore + n); + //Update size since we have a contiguous buffer + this->members_.m_size = old_size + s_before; + //All new elements correctly constructed, avoid old element destruction + old_values_destroyer.release(); + //Now copy remaining last objects in the old buffer begin + T *to_destroy = ::boost::move(pos + raw_gap, old_finish, old_start); + //Now destroy redundant elements except if they were moved and + //they have trivial destructor after move + size_type n_destroy = old_finish - to_destroy; + if(!value_traits::trivial_dctr_after_move) + this->destroy_n(to_destroy, n_destroy); + this->members_.m_size -= n_destroy; + } + } + else{ + //Check if we have to do the insertion in two phases + //since maybe s_before is not big enough and + //the buffer was expanded both sides + // + //Old situation: + // _________________________________________________ + //| raw_mem | old_begin + old_end | raw_mem | + //|_________|_____________________|_________________| + // + //New situation with do_after: + // _________________________________________________ + //| old_begin + new + old_end | raw_mem | + //|___________________________________|_____________| + // + //New without do_after: + // _________________________________________________ + //| old_begin + new + old_end | raw_mem | + //|____________________________|____________________| + // + bool do_after = n > s_before; + + //Now we can have two situations: the raw_mem of the + //beginning divides the old_begin, or the new elements: + if (s_before <= elemsbefore) { + //The raw memory divides the old_begin group: + // + //If we need two phase construction (do_after) + //new group is divided in new = new_beg + new_end groups + //In this phase only new_beg will be inserted + // + //Old situation: + // _________________________________________________ + //| raw_mem | old_begin | old_end | raw_mem | + //|_________|___________|_________|_________________| + // + //New situation with do_after(1): + //This is not definitive situation, the second phase + //will include + // _________________________________________________ + //| old_begin | new_beg | old_end | raw_mem | + //|___________|_________|_________|_________________| + // + //New situation without do_after: + // _________________________________________________ + //| old_begin | new | old_end | raw_mem | + //|___________|_____|_________|_____________________| + // + //Copy the first part of old_begin to raw_mem + 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, + //release destroyer and update size + old_values_destroyer.release(); + this->members_.m_size = old_size + s_before; + //Now copy the second part of old_begin overwriting himself + T* next = ::boost::move(start_n, pos, old_start); + if(do_after){ + //Now copy the new_beg elements + interf.copy_some_and_update(next, s_before, true); + } + else{ + //Now copy the all the new elements + interf.copy_remaining_to(next); + T* move_start = next + n; + //Now displace old_end elements + T* move_end = ::boost::move(pos, old_finish, move_start); + //Destroy remaining moved elements from old_end except if + //they have trivial destructor after being moved + difference_type n_destroy = s_before - n; + if(!value_traits::trivial_dctr_after_move) + this->destroy_n(move_end, n_destroy); + this->members_.m_size -= n_destroy; + } + } + else { + //If we have to expand both sides, + //we will play if the first new values so + //calculate the upper bound of new values + + //The raw memory divides the new elements + // + //If we need two phase construction (do_after) + //new group is divided in new = new_beg + new_end groups + //In this phase only new_beg will be inserted + // + //Old situation: + // _______________________________________________________ + //| raw_mem | old_begin | old_end | raw_mem | + //|_______________|___________|_________|_________________| + // + //New situation with do_after(): + // ____________________________________________________ + //| old_begin | new_beg | old_end | raw_mem | + //|___________|_______________|_________|______________| + // + //New situation without do_after: + // ______________________________________________________ + //| old_begin | new | old_end | raw_mem | + //|___________|_____|_________|__________________________| + // + //First copy whole old_begin and part of new to raw_mem + ::boost::container::uninitialized_move_alloc + (this->alloc(), old_start, pos, new_start); + this->members_.m_size = elemsbefore; + + const size_type mid_n = difference_type(s_before) - elemsbefore; + interf.uninitialized_copy_some_and_update(new_start + elemsbefore, mid_n, true); + this->members_.m_size = old_size + s_before; + //The buffer is all constructed until old_end, + //release destroyer and update size + old_values_destroyer.release(); + + if(do_after){ + //Copy new_beg part + interf.copy_some_and_update(old_start, s_before - mid_n, true); + } + else{ + //Copy all new elements + interf.copy_remaining_to(old_start); + T* move_start = old_start + (n-mid_n); + //Displace old_end + T* move_end = ::boost::move(pos, old_finish, move_start); + //Destroy remaining moved elements from old_end except if they + //have trivial destructor after being moved + difference_type n_destroy = s_before - n; + if(!value_traits::trivial_dctr_after_move) + this->destroy_n(move_end, n_destroy); + this->members_.m_size -= n_destroy; + } + } + + //This is only executed if two phase construction is needed + //This can be executed without exception handling since we + //have to just copy and append in raw memory and + //old_values_destroyer has been released in phase 1. + if(do_after){ + //The raw memory divides the new elements + // + //Old situation: + // ______________________________________________________ + //| raw_mem | old_begin | old_end | raw_mem | + //|______________|___________|____________|______________| + // + //New situation with do_after(1): + // _______________________________________________________ + //| old_begin + new_beg | new_end |old_end | raw_mem | + //|__________________________|_________|________|_________| + // + //New situation with do_after(2): + // ______________________________________________________ + //| old_begin + new | old_end |raw | + //|_______________________________________|_________|____| + // + const size_type n_after = n - s_before; + const difference_type elemsafter = old_size - elemsbefore; + + //We can have two situations: + if (elemsafter > difference_type(n_after)){ + //The raw_mem from end will divide displaced old_end + // + //Old situation: + // ______________________________________________________ + //| raw_mem | old_begin | old_end | raw_mem | + //|______________|___________|____________|______________| + // + //New situation with do_after(1): + // _______________________________________________________ + //| old_begin + new_beg | new_end |old_end | raw_mem | + //|__________________________|_________|________|_________| + // + //First copy the part of old_end raw_mem + T* finish_n = old_finish - difference_type(n_after); + ::boost::container::uninitialized_move_alloc + (this->alloc(), finish_n, old_finish, old_finish); + this->members_.m_size += n_after; + //Displace the rest of old_end to the new position + boost::move_backward(pos, finish_n, old_finish); + //Now overwrite with new_end + //The new_end part is [first + (n - n_after), last) + interf.copy_remaining_to(pos); + } + else { + //The raw_mem from end will divide new_end part + // + //Old situation: + // _____________________________________________________________ + //| raw_mem | old_begin | old_end | raw_mem | + //|______________|___________|____________|_____________________| + // + //New situation with do_after(2): + // _____________________________________________________________ + //| old_begin + new_beg | new_end |old_end | raw_mem | + //|__________________________|_______________|________|_________| + // + size_type mid_last_dist = n_after - elemsafter; + //First initialize data in raw memory + //The new_end part is [first + (n - n_after), last) + interf.uninitialized_copy_some_and_update(old_finish, elemsafter, false); + this->members_.m_size += mid_last_dist; + ::boost::container::uninitialized_move_alloc + (this->alloc(), pos, old_finish, old_finish + mid_last_dist); + this->members_.m_size += n_after - mid_last_dist; + //Now copy the part of new_end over constructed elements + interf.copy_remaining_to(pos); + } + } + } + } + + template <class InIt> + void priv_assign_aux(InIt first, InIt last, std::input_iterator_tag) + { + //Overwrite all elements we can from [first, last) + iterator cur = begin(); + for ( ; first != last && cur != end(); ++cur, ++first){ + *cur = *first; + } + + if (first == last){ + //There are no more elements in the sequence, erase remaining + this->erase(cur, cend()); + } + else{ + //There are more elements in the range, insert the remaining ones + this->insert(this->cend(), first, last); + } + } + + template <class FwdIt> + void priv_assign_aux(FwdIt first, FwdIt last, std::forward_iterator_tag) + { + size_type n = std::distance(first, last); + if(!n){ + this->prot_destroy_all(); + return; + } + //Check if we have enough memory or try to expand current memory + size_type remaining = this->members_.m_capacity - this->members_.m_size; + bool same_buffer_start; + std::pair<pointer, bool> ret; + size_type real_cap = this->members_.m_capacity; + + if (n <= remaining){ + same_buffer_start = true; + } + else{ + //There is not enough memory, allocate a new buffer + size_type new_cap = this->next_capacity(n); + ret = this->allocation_command + (allocate_new | expand_fwd | expand_bwd, + this->size() + n, new_cap, real_cap, this->members_.m_start); + same_buffer_start = ret.second && this->members_.m_start == ret.first; + if(same_buffer_start){ + 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){ + //There is memory, but there are more old elements than new ones + //Overwrite old elements with new ones + std::copy(first, last, start); + //Destroy remaining old elements + this->destroy_n(start + n, this->members_.m_size - n); + this->members_.m_size = n; + } + else{ + //There is memory, but there are less old elements than new ones + //First overwrite some old elements with new ones + FwdIt mid = first; + std::advance(mid, this->size()); + // iG T *end = std::copy(first, mid, start); + T *end = std::copy(first, mid, start); + //Initialize the remaining new elements in the uninitialized memory + ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), mid, last, end); + this->members_.m_size = n; + } + } + else if(!ret.second){ + typename value_traits::ArrayDeallocator scoped_alloc(ret.first, this->alloc(), real_cap); + ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), first, last, container_detail::to_raw_pointer(ret.first)); + 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->alloc().deallocate(this->members_.m_start, this->members_.m_capacity); + } + this->members_.m_start = ret.first; + this->members_.m_size = n; + this->members_.m_capacity = real_cap; + } + else{ + //Backwards expansion + //If anything goes wrong, this object will destroy old objects + T *old_start = container_detail::to_raw_pointer(this->members_.m_start); + size_type old_size = this->members_.m_size; + typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size); + //If something goes wrong size will be 0 + //but holding the whole buffer + 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); + + FwdIt mid = first; + std::advance(mid, first_count); + ::boost::container::uninitialized_copy_or_move_alloc + (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" + this->members_.m_size = n; + } + else{ + //We have constructed objects from the new begin until + //the old end so release the rollback destruction + old_values_destroyer.release(); + this->members_.m_start = ret.first; + this->members_.m_size = first_count + old_size; + //Now overwrite the old values + size_type second_count = container_detail::min_value(old_size, n - first_count); + FwdIt mid2 = mid; + 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){ + // iG std::copy(mid2, last, old_start + old_size); + std::copy(mid2, last, old_start + old_size); + } + else{ + //We have to destroy some old values + this->destroy_n + (old_start + second_count, old_size - second_count); + this->members_.m_size = n; + } + this->members_.m_size = n; + } + } + } + + template <class Integer> + void priv_assign_dispatch(Integer n, Integer val, container_detail::true_) + { this->assign((size_type) n, (value_type)val); } + + 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()); + } + + template <class Integer> + 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, + InIt last, container_detail::false_) + { + //Dispatch depending on integer/iterator + typedef typename std::iterator_traits<InIt>::iterator_category ItCat; + this->priv_range_insert(pos, first, last, ItCat()); + } + + void priv_check_range(size_type n) const + { + //If n is out of range, throw an out_of_range exception + if (n >= size()) + throw std::out_of_range("vector::at"); + } + + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + public: + unsigned int num_expand_fwd; + unsigned int num_expand_bwd; + unsigned int num_shrink; + unsigned int num_alloc; + void reset_alloc_stats() + { num_expand_fwd = num_expand_bwd = num_alloc = 0, num_shrink = 0; } + #endif + /// @endcond +}; + +template <class T, class A> +inline bool +operator==(const vector<T, A>& x, const vector<T, A>& y) +{ + //Check first size and each element if needed + return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); +} + +template <class T, class A> +inline bool +operator!=(const vector<T, A>& x, const vector<T, A>& y) +{ + //Check first size and each element if needed + return x.size() != y.size() || !std::equal(x.begin(), x.end(), y.begin()); +} + +template <class T, class A> +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()); +} + +template <class T, class A> +inline void swap(vector<T, A>& x, vector<T, A>& y) +{ x.swap(y); } + +}} + +/// @cond + +namespace boost { + +/* + +//!has_trivial_destructor_after_move<> == true_type +//!specialization for optimizations +template <class T, class A> +struct has_trivial_destructor_after_move<boost::container::vector<T, A> > +{ + static const bool value = has_trivial_destructor<A>::value; +}; + +*/ + +} + +/// @endcond + +#include <boost/container/detail/config_end.hpp> + +#endif // #ifndef BOOST_CONTAINER_CONTAINER_VECTOR_HPP + diff --git a/src/third_party/boost/boost/intrusive/any_hook.hpp b/src/third_party/boost/boost/intrusive/any_hook.hpp new file mode 100644 index 00000000000..cccc820e7d3 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/any_hook.hpp @@ -0,0 +1,344 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_ANY_HOOK_HPP +#define BOOST_INTRUSIVE_ANY_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/any_node_and_algorithms.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +template<class VoidPointer> +struct get_any_node_algo +{ + typedef any_algorithms<VoidPointer> type; +}; +/// @endcond + +//! Helper metafunction to define a \c \c any_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_any_base_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_any_node_algo<typename packed_options::void_pointer> + , typename packed_options::tag + , packed_options::link_mode + , detail::AnyBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from this hook in order to store objects of that class +//! in an intrusive container. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<> and +//! \c link_mode<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c any_base_hook, then each \c any_base_hook needs its +//! unique tag. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, \c safe_link). +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class any_base_hook + : public make_any_base_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3> + #else + <Options...> + #endif + ::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + any_base_hook(); + + //! <b>Effects</b>: If link_mode is or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + any_base_hook(const any_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + any_base_hook& operator=(const any_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a container an assertion is raised. + //! + //! <b>Throws</b>: Nothing. + ~any_base_hook(); + + //! <b>Precondition</b>: link_mode must be \c safe_link. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c container::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + #endif +}; + +//! Helper metafunction to define a \c \c any_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_any_member_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_any_node_algo<typename packed_options::void_pointer> + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Store this hook in a class to be inserted +//! in an intrusive container. +//! +//! The hook admits the following options: \c void_pointer<> and +//! \c link_mode<>. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link or \c safe_link). +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class any_member_hook + : public make_any_member_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3> + #else + <Options...> + #endif + ::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + any_member_hook(); + + //! <b>Effects</b>: If link_mode is or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + any_member_hook(const any_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + any_member_hook& operator=(const any_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a container an assertion is raised. + //! + //! <b>Throws</b>: Nothing. + ~any_member_hook(); + + //! <b>Precondition</b>: link_mode must be \c safe_link. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c container::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + #endif +}; + +/// @cond + +namespace detail{ + +template<class ValueTraits> +struct any_to_get_base_pointer_type +{ + typedef typename pointer_traits<typename ValueTraits::boost_intrusive_tags::node_traits::node_ptr>::template + rebind_pointer<void>::type type; +}; + +template<class ValueTraits> +struct any_to_get_member_pointer_type +{ + typedef typename pointer_traits + <typename ValueTraits::node_ptr>::template rebind_pointer<void>::type type; +}; + +//!This option setter specifies that the container +//!must use the specified base hook +template<class BaseHook, template <class> class NodeTraits> +struct any_to_some_hook +{ + typedef typename BaseHook::template pack<none>::value_traits old_value_traits; + template<class Base> + struct pack : public Base + { + struct value_traits : public old_value_traits + { + static const bool is_any_hook = true; + typedef typename detail::eval_if_c + < detail::internal_base_hook_bool_is_true<old_value_traits>::value + , any_to_get_base_pointer_type<old_value_traits> + , any_to_get_member_pointer_type<old_value_traits> + >::type void_pointer; + typedef NodeTraits<void_pointer> node_traits; + }; + }; +}; + +} //namespace detail{ + +/// @endcond + +//!This option setter specifies that +//!any hook should behave as an slist hook +template<class BaseHook> +struct any_to_slist_hook +/// @cond + : public detail::any_to_some_hook<BaseHook, any_slist_node_traits> +/// @endcond +{}; + +//!This option setter specifies that +//!any hook should behave as an list hook +template<class BaseHook> +struct any_to_list_hook +/// @cond + : public detail::any_to_some_hook<BaseHook, any_list_node_traits> +/// @endcond +{}; + +//!This option setter specifies that +//!any hook should behave as a set hook +template<class BaseHook> +struct any_to_set_hook +/// @cond + : public detail::any_to_some_hook<BaseHook, any_rbtree_node_traits> +/// @endcond +{}; + +//!This option setter specifies that +//!any hook should behave as an avl_set hook +template<class BaseHook> +struct any_to_avl_set_hook +/// @cond + : public detail::any_to_some_hook<BaseHook, any_avltree_node_traits> +/// @endcond +{}; + +//!This option setter specifies that any +//!hook should behave as a bs_set hook +template<class BaseHook> +struct any_to_bs_set_hook +/// @cond + : public detail::any_to_some_hook<BaseHook, any_tree_node_traits> +/// @endcond +{}; + +//!This option setter specifies that any hook +//!should behave as an unordered set hook +template<class BaseHook> +struct any_to_unordered_set_hook +/// @cond + : public detail::any_to_some_hook<BaseHook, any_unordered_node_traits> +/// @endcond +{}; + + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_ANY_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/avl_set.hpp b/src/third_party/boost/boost/intrusive/avl_set.hpp new file mode 100644 index 00000000000..92baf473ce9 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/avl_set.hpp @@ -0,0 +1,2358 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_AVL_SET_HPP +#define BOOST_INTRUSIVE_AVL_SET_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/avltree.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/move/move.hpp> +#include <iterator> + +namespace boost { +namespace intrusive { + +//! The class template avl_set is an intrusive container, that mimics most of +//! the interface of std::set as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class avl_set_impl +{ + /// @cond + typedef avltree_impl<Config> tree_type; + //! This class is + //! movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_set_impl) + + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare object throws. + avl_set_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty avl_set and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is std::distance(last, first). + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + avl_set_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(true, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + avl_set_impl(BOOST_RV_REF(avl_set_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + avl_set_impl& operator=(BOOST_RV_REF(avl_set_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the avl_set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~avl_set_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of avl_set. + //! + //! <b>Effects</b>: Returns a const reference to the avl_set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static avl_set_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<avl_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &avl_set_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of avl_set. + //! + //! <b>Effects</b>: Returns a const reference to the set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const avl_set_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<avl_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &avl_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of set. + //! + //! <b>Effects</b>: Returns a reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static avl_set_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<avl_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &avl_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of set. + //! + //! <b>Effects</b>: Returns a const reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const avl_set_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<avl_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &avl_set_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the avl_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true is the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the avl_set. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two sets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(avl_set_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const avl_set_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Treaps to inserts value into the avl_set. + //! + //! <b>Returns</b>: If the value + //! is not already present inserts it and returns a pair containing the + //! iterator to the new value and true. If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert(reference value) + { return tree_.insert_unique(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Treaps to to insert x into the avl_set, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the + //! new element was inserted into the avl_set. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_unique(hint, value); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the avl_set, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the avl_set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(key, key_value_comp, commit_data); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the avl_set, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the avl_set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(hint, key, key_value_comp, commit_data); } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the avl_set between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_commit(reference value, const insert_commit_data &commit_data) + { return tree_.insert_unique_commit(value, commit_data); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the avl_set. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_unique(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate. "value" must not be equal to any + //! inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" or "value" is not unique tree ordering and uniqueness + //! invariants will be broken respectively. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be greater than + //! any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than or equal to the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be less + //! than any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than or equal to the the mimum inserted key tree ordering or uniqueness + //! invariants will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size()) + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If the comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). Basic guarantee. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.find(value) != end(); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp) != end(); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! avl_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! avl_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a avl_set/avl_multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + /// @cond + friend bool operator==(const avl_set_impl &x, const avl_set_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const avl_set_impl &x, const avl_set_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y) +#else +(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y) +#else +(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y) +#else +(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y) +#else +(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(avl_set_impl<T, Options...> &x, avl_set_impl<T, Options...> &y) +#else +(avl_set_impl<Config> &x, avl_set_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c avl_set that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_avl_set +{ + /// @cond + typedef avl_set_impl + < typename make_avltree_opt + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <T, O1, O2, O3, O4> + #else + <T, Options...> + #endif + ::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class avl_set + : public make_avl_set + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <T, O1, O2, O3, O4> + #else + <T, Options...> + #endif + ::type +{ + typedef typename make_avl_set + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <T, O1, O2, O3, O4> + #else + <T, Options...> + #endif + ::type Base; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_set) + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + avl_set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + avl_set( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + avl_set(BOOST_RV_REF(avl_set) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + avl_set& operator=(BOOST_RV_REF(avl_set) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static avl_set &container_from_end_iterator(iterator end_iterator) + { return static_cast<avl_set &>(Base::container_from_end_iterator(end_iterator)); } + + static const avl_set &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const avl_set &>(Base::container_from_end_iterator(end_iterator)); } + + static avl_set &container_from_iterator(iterator end_iterator) + { return static_cast<avl_set &>(Base::container_from_iterator(end_iterator)); } + + static const avl_set &container_from_iterator(const_iterator end_iterator) + { return static_cast<const avl_set &>(Base::container_from_iterator(end_iterator)); } +}; + +#endif + +//! The class template avl_multiset is an intrusive container, that mimics most of +//! the interface of std::avl_multiset as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class avl_multiset_impl +{ + /// @cond + typedef avltree_impl<Config> tree_type; + + //Movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_multiset_impl) + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + avl_multiset_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty avl_multiset and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + avl_multiset_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(false, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + avl_multiset_impl(BOOST_RV_REF(avl_multiset_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + avl_multiset_impl& operator=(BOOST_RV_REF(avl_multiset_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the avl_multiset + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~avl_multiset_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of avl_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the avl_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static avl_multiset_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<avl_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &avl_multiset_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of avl_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the avl_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const avl_multiset_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<avl_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &avl_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static avl_multiset_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<avl_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &avl_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const avl_multiset_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<avl_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &avl_multiset_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the avl_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true is the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the avl_multiset. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two avl_multisets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(avl_multiset_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const avl_multiset_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the avl_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(reference value) + { return tree_.insert_equal(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts x into the avl_multiset, using pos as a hint to + //! where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_equal(hint, value); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the avl_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_equal(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate. "value" must not be equal to any + //! inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" or "value" is not unique tree ordering and uniqueness + //! invariants will be broken respectively. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be greater than + //! any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than or equal to the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be less + //! than any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than or equal to the the mimum inserted key tree ordering or uniqueness + //! invariants will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.count(value); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.count(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_multiset + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! avl_multiset that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_multiset + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! avl_multiset that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a avl_multiset/avl_multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + /// @cond + friend bool operator==(const avl_multiset_impl &x, const avl_multiset_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const avl_multiset_impl &x, const avl_multiset_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y) +#else +(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y) +#else +(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y) +#else +(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y) +#else +(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(avl_multiset_impl<T, Options...> &x, avl_multiset_impl<T, Options...> &y) +#else +(avl_multiset_impl<Config> &x, avl_multiset_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c avl_multiset that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_avl_multiset +{ + /// @cond + typedef avl_multiset_impl + < typename make_avltree_opt + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <T, O1, O2, O3, O4> + #else + <T, Options...> + #endif + ::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class avl_multiset + : public make_avl_multiset<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_avl_multiset + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <T, O1, O2, O3, O4> + #else + <T, Options...> + #endif + ::type Base; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_multiset) + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + avl_multiset( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + avl_multiset( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + avl_multiset(BOOST_RV_REF(avl_multiset) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + avl_multiset& operator=(BOOST_RV_REF(avl_multiset) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static avl_multiset &container_from_end_iterator(iterator end_iterator) + { return static_cast<avl_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static const avl_multiset &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const avl_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static avl_multiset &container_from_iterator(iterator end_iterator) + { return static_cast<avl_multiset &>(Base::container_from_iterator(end_iterator)); } + + static const avl_multiset &container_from_iterator(const_iterator end_iterator) + { return static_cast<const avl_multiset &>(Base::container_from_iterator(end_iterator)); } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_AVL_SET_HPP diff --git a/src/third_party/boost/boost/intrusive/avl_set_hook.hpp b/src/third_party/boost/boost/intrusive/avl_set_hook.hpp new file mode 100644 index 00000000000..23b1f0bd8f2 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/avl_set_hook.hpp @@ -0,0 +1,297 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_AVL_SET_HOOK_HPP +#define BOOST_INTRUSIVE_AVL_SET_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/avltree_node.hpp> +#include <boost/intrusive/avltree_algorithms.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +template<class VoidPointer, bool OptimizeSize = false> +struct get_avl_set_node_algo +{ + typedef avltree_algorithms<avltree_node_traits<VoidPointer, OptimizeSize> > type; +}; +/// @endcond + +//! Helper metafunction to define a \c avl_set_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none, class O4 = none> +#endif +struct make_avl_set_base_hook +{ + /// @cond + typedef typename pack_options + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <hook_defaults, O1, O2, O3, O4> + #else + <hook_defaults, Options...> + #endif + ::type packed_options; + + typedef detail::generic_hook + < get_avl_set_node_algo<typename packed_options::void_pointer + ,packed_options::optimize_size> + , typename packed_options::tag + , packed_options::link_mode + , detail::AvlSetBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from avl_set_base_hook in order to store objects in +//! in an avl_set/avl_multiset. avl_set_base_hook holds the data necessary to maintain +//! the avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<>, +//! \c link_mode<> and \c optimize_size<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its +//! unique tag. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c optimize_size<> will tell the hook to optimize the hook for size instead +//! of speed. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3, class O4> +#endif +class avl_set_base_hook + : public make_avl_set_base_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3, O4> + #else + <Options...> + #endif + ::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + avl_set_base_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + avl_set_base_hook(const avl_set_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + avl_set_base_hook& operator=(const avl_set_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~avl_set_base_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(avl_set_base_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +//! Helper metafunction to define a \c avl_set_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none, class O4 = none> +#endif +struct make_avl_set_member_hook +{ + /// @cond + typedef typename pack_options + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <hook_defaults, O1, O2, O3, O4> + #else + <hook_defaults, Options...> + #endif + ::type packed_options; + + typedef detail::generic_hook + < get_avl_set_node_algo<typename packed_options::void_pointer + ,packed_options::optimize_size> + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Put a public data member avl_set_member_hook in order to store objects of this class in +//! an avl_set/avl_multiset. avl_set_member_hook holds the data necessary for maintaining the +//! avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset. +//! +//! The hook admits the following options: \c void_pointer<>, +//! \c link_mode<> and \c optimize_size<>. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c optimize_size<> will tell the hook to optimize the hook for size instead +//! of speed. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3, class O4> +#endif +class avl_set_member_hook + : public make_avl_set_member_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3, O4> + #else + <Options...> + #endif + ::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + avl_set_member_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + avl_set_member_hook(const avl_set_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + avl_set_member_hook& operator=(const avl_set_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~avl_set_member_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(avl_set_member_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_AVL_SET_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/avltree.hpp b/src/third_party/boost/boost/intrusive/avltree.hpp new file mode 100644 index 00000000000..20903ddef77 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/avltree.hpp @@ -0,0 +1,1688 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_AVLTREE_HPP +#define BOOST_INTRUSIVE_AVLTREE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <algorithm> +#include <cstddef> +#include <functional> +#include <iterator> +#include <utility> + +#include <boost/intrusive/detail/assert.hpp> +#include <boost/static_assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/avl_set_hook.hpp> +#include <boost/intrusive/detail/avltree_node.hpp> +#include <boost/intrusive/detail/tree_node.hpp> +#include <boost/intrusive/detail/ebo_functor_holder.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/avltree_algorithms.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/move/move.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +template <class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize> +struct avl_setopt +{ + typedef ValueTraits value_traits; + typedef Compare compare; + typedef SizeType size_type; + static const bool constant_time_size = ConstantTimeSize; +}; + +template <class T> +struct avl_set_defaults + : pack_options + < none + , base_hook<detail::default_avl_set_hook> + , constant_time_size<true> + , size_type<std::size_t> + , compare<std::less<T> > + >::type +{}; + +/// @endcond + +//! The class template avltree is an intrusive AVL tree container, that +//! is used to construct intrusive avl_set and avl_multiset containers. +//! The no-throw guarantee holds only, if the value_compare object +//! doesn't throw. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class avltree_impl + : private detail::clear_on_destructor_base<avltree_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + public: + typedef typename Config::value_traits value_traits; + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + /// @endcond + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + typedef typename boost::intrusive:: + pointer_traits<pointer>::element_type value_type; + typedef value_type key_type; + typedef typename boost::intrusive:: + pointer_traits<pointer>::reference reference; + typedef typename boost::intrusive:: + pointer_traits<const_pointer>::reference const_reference; + typedef typename boost::intrusive:: + pointer_traits<pointer>::difference_type difference_type; + typedef typename Config::size_type size_type; + typedef typename Config::compare value_compare; + typedef value_compare key_compare; + typedef tree_iterator<avltree_impl, false> iterator; + typedef tree_iterator<avltree_impl, true> const_iterator; + typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator; + typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <node>::type node_ptr; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <const node>::type const_node_ptr; + typedef avltree_algorithms<node_traits> node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + static const bool stateful_value_traits = detail::store_cont_ptr_on_it<avltree_impl>::value; + + /// @cond + private: + typedef detail::size_holder<constant_time_size, size_type> size_traits; + + //noncopyable, movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + //Constant-time size is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink))); + + struct header_plus_size : public size_traits + { node header_; }; + + struct node_plus_pred_t : public detail::ebo_functor_holder<value_compare> + { + node_plus_pred_t(const value_compare &comp) + : detail::ebo_functor_holder<value_compare>(comp) + {} + header_plus_size header_plus_size_; + }; + + struct data_t : public avltree_impl::value_traits + { + typedef typename avltree_impl::value_traits value_traits; + data_t(const value_compare & comp, const value_traits &val_traits) + : value_traits(val_traits), node_plus_pred_(comp) + {} + node_plus_pred_t node_plus_pred_; + } data_; + + const value_compare &priv_comp() const + { return data_.node_plus_pred_.get(); } + + value_compare &priv_comp() + { return data_.node_plus_pred_.get(); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + node_ptr priv_header_ptr() + { return pointer_traits<node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); } + + const_node_ptr priv_header_ptr() const + { return pointer_traits<const_node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); } + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + size_traits &priv_size_traits() + { return data_.node_plus_pred_.header_plus_size_; } + + const size_traits &priv_size_traits() const + { return data_.node_plus_pred_.header_plus_size_; } + + const real_value_traits &get_real_value_traits(detail::bool_<false>) const + { return data_; } + + const real_value_traits &get_real_value_traits(detail::bool_<true>) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::bool_<false>) + { return data_; } + + real_value_traits &get_real_value_traits(detail::bool_<true>) + { return data_.get_value_traits(*this); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + typedef typename node_algorithms::insert_commit_data insert_commit_data; + + //! <b>Effects</b>: Constructs an empty tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare object throws. Basic guarantee. + avltree_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty tree and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. Basic guarantee. + template<class Iterator> + avltree_impl( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + if(unique) + this->insert_unique(b, e); + else + this->insert_equal(b, e); + } + + //! <b>Effects</b>: to-do + //! + avltree_impl(BOOST_RV_REF(avltree_impl) x) + : data_(::boost::move(x.priv_comp()), ::boost::move(x.priv_value_traits())) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + this->swap(x); + } + + //! <b>Effects</b>: to-do + //! + avltree_impl& operator=(BOOST_RV_REF(avltree_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called), but the nodes according to + //! the value_traits template parameter are reinitialized and thus can be reused. + //! + //! <b>Complexity</b>: Linear to elements contained in *this. + //! + //! <b>Throws</b>: Nothing. + ~avltree_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return cbegin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return const_iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return iterator (this->priv_header_ptr(), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return cend(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return const_iterator (uncast(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return const_reverse_iterator(begin()); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of avltree. + //! + //! <b>Effects</b>: Returns a const reference to the avltree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static avltree_impl &container_from_end_iterator(iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of avltree. + //! + //! <b>Effects</b>: Returns a const reference to the avltree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const avltree_impl &container_from_end_iterator(const_iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: it must be a valid iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static avltree_impl &container_from_iterator(iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Precondition</b>: it must be a valid end const_iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const avltree_impl &container_from_iterator(const_iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Effects</b>: Returns the value_compare object used by the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return priv_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return node_algorithms::unique(this->priv_header_ptr()); } + + //! <b>Effects</b>: Returns the number of elements stored in the tree. + //! + //! <b>Complexity</b>: Linear to elements contained in *this + //! if constant-time size option is disabled. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { + if(constant_time_size) + return this->priv_size_traits().get_size(); + else{ + return (size_type)node_algorithms::size(this->priv_header_ptr()); + } + } + + //! <b>Effects</b>: Swaps the contents of two avltrees. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the comparison functor's swap call throws. + void swap(avltree_impl& other) + { + //This can throw + using std::swap; + swap(priv_comp(), priv_comp()); + //These can't throw + node_algorithms::swap_tree(this->priv_header_ptr(), other.priv_header_ptr()); + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree before the upper bound. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(reference value) + { + detail::key_nodeptr_comp<value_compare, avltree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret(node_algorithms::insert_equal_upper_bound + (this->priv_header_ptr(), to_insert, key_node_comp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator. + //! + //! <b>Effects</b>: Inserts x into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case) + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(const_iterator hint, reference value) + { + detail::key_nodeptr_comp<value_compare, avltree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret(node_algorithms::insert_equal + (this->priv_header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a each element of a range into the tree + //! before the upper bound of the key of each element. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_equal(Iterator b, Iterator e) + { + iterator end(this->end()); + for (; b != e; ++b) + this->insert_equal(end, *b); + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree if the value + //! is not already present. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert_unique(reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(value, priv_comp(), commit_data); + if(!ret.second) + return ret; + return std::pair<iterator, bool> (insert_unique_commit(value, commit_data), true); + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator + //! + //! <b>Effects</b>: Tries to insert x into the tree, using "hint" as a hint + //! to where it will be inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time (two comparisons in the worst case) + //! if t is inserted immediately before hint. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_unique(const_iterator hint, reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(hint, value, priv_comp(), commit_data); + if(!ret.second) + return ret.first; + return insert_unique_commit(value, commit_data); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Tries to insert each element of a range into the tree. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_unique(Iterator b, Iterator e) + { + if(this->empty()){ + iterator end(this->end()); + for (; b != e; ++b) + this->insert_unique(end, *b); + } + else{ + for (; b != e; ++b) + this->insert_unique(*b); + } + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), key, comp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), hint.pointed_node(), key, comp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the container between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + node_algorithms::insert_unique_commit + (this->priv_header_ptr(), to_insert, commit_data); + this->priv_size_traits().increment(); + return iterator(to_insert, this); + } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" tree ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret(node_algorithms::insert_before + (this->priv_header_ptr(), pos.pointed_node(), to_insert), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no less + //! than the greatest inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + node_algorithms::push_back(this->priv_header_ptr(), to_insert); + this->priv_size_traits().increment(); + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no greater + //! than the minimum inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + node_algorithms::push_front(this->priv_header_ptr(), to_insert); + this->priv_size_traits().increment(); + } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { + const_iterator ret(i); + ++ret; + node_ptr to_erase(i.pointed_node()); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); + node_algorithms::erase(this->priv_header_ptr(), to_erase); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + return ret.unconst(); + } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { size_type n; return private_erase(b, e, n); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return this->erase(value, priv_comp()); } + + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { + node_ptr to_erase(i.pointed_node()); + iterator ret(this->erase(i)); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + return ret; + } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { size_type n; return private_erase(b, e, n, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { + std::pair<iterator,iterator> p = this->equal_range(value); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { + if(safemode_or_autounlink){ + this->clear_and_dispose(detail::null_disposer()); + } + else{ + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + } + + //! <b>Effects</b>: Erases all of the elements calling disposer(p) for + //! each node to be erased. + //! <b>Complexity</b>: Average complexity for is at most O(log(size() + N)), + //! where N is the number of elements in the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. Calls N times to disposer functor. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { + node_algorithms::clear_and_dispose(this->priv_header_ptr() + , detail::node_disposer<Disposer, avltree_impl>(disposer, this)); + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given value. + //! + //! <b>Throws</b>: Nothing. + size_type count(const_reference value) const + { return this->count(value, priv_comp()); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType &key, KeyValueCompare comp) const + { + std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp); + return std::distance(ret.first, ret.second); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator lower_bound(const_reference value) + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator lower_bound(const_reference value) const + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator upper_bound(const_reference value) + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator upper_bound(const_reference value) const + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator find(const_reference value) + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + return iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator find(const_reference value) const + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + return const_iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<iterator,iterator> equal_range(const_reference value) + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<iterator, iterator>(iterator(ret.first, this), iterator(ret.second, this)); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, avltree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<const_iterator, const_iterator>(const_iterator(ret.first, this), const_iterator(ret.second, this)); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const avltree_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + if(!src.empty()){ + detail::exception_disposer<avltree_impl, Disposer> + rollback(*this, disposer); + node_algorithms::clone + (src.priv_header_ptr() + ,this->priv_header_ptr() + ,detail::node_cloner<Cloner, avltree_impl>(cloner, this) + ,detail::node_disposer<Disposer, avltree_impl>(disposer, this)); + this->priv_size_traits().set_size(src.priv_size_traits().get_size()); + this->priv_comp() = src.priv_comp(); + rollback.release(); + } + } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { + node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance + (this->priv_header_ptr())); + if(!to_be_disposed) + return 0; + this->priv_size_traits().decrement(); + if(safemode_or_autounlink)//If this is commented does not work with normal_link + node_algorithms::init(to_be_disposed); + return get_real_value_traits().to_value_ptr(to_be_disposed); + } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { + node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this) + , this->priv_header_ptr() + , get_real_value_traits().to_node_ptr(with_this)); + if(safemode_or_autounlink) + node_algorithms::init(replace_this.pointed_node()); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return iterator (value_traits::to_node_ptr(value), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return iterator (value_traits::to_node_ptr(value), this); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this); } + + //! <b>Requires</b>: value shall not be in a tree. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { node_algorithms::init(value_traits::to_node_ptr(value)); } + +/* + //! <b>Effects</b>: removes x from a tree of the appropriate type. It has no effect, + //! if x is not in such a tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This static function is only usable with the "safe mode" + //! hook and non-constant time size lists. Otherwise, the user must use + //! the non-static "erase(reference )" member. If the user calls + //! this function with a non "safe mode" or constant time size list + //! a compilation error will be issued. + template<class T> + static void remove_node(T& value) + { + //This function is only usable for safe mode hooks and non-constant + //time lists. + //BOOST_STATIC_ASSERT((!(safemode_or_autounlink && constant_time_size))); + BOOST_STATIC_ASSERT((!constant_time_size)); + BOOST_STATIC_ASSERT((boost::is_convertible<T, value_type>::value)); + node_ptr to_remove(value_traits::to_node_ptr(value)); + node_algorithms::unlink_and_rebalance(to_remove); + if(safemode_or_autounlink) + node_algorithms::init(to_remove); + } +*/ + + /// @cond + + private: + template<class Disposer> + iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer) + { + for(n = 0; b != e; ++n) + this->erase_and_dispose(b++, disposer); + return b.unconst(); + } + + iterator private_erase(const_iterator b, const_iterator e, size_type &n) + { + for(n = 0; b != e; ++n) + this->erase(b++); + return b.unconst(); + } + /// @endcond + + private: + static avltree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) + { + header_plus_size *r = detail::parent_from_member<header_plus_size, node> + ( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), &header_plus_size::header_); + node_plus_pred_t *n = detail::parent_from_member + <node_plus_pred_t, header_plus_size>(r, &node_plus_pred_t::header_plus_size_); + data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(n, &data_t::node_plus_pred_); + avltree_impl *avl = detail::parent_from_member<avltree_impl, data_t>(d, &avltree_impl::data_); + return *avl; + } + + static avltree_impl &priv_container_from_iterator(const const_iterator &it) + { return priv_container_from_end_iterator(it.end_iterator_from_it()); } +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator< +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y) +#else +(const avltree_impl<Config> &x, const avltree_impl<Config> &y) +#endif +{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +bool operator== +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y) +#else +(const avltree_impl<Config> &x, const avltree_impl<Config> &y) +#endif +{ + typedef avltree_impl<Config> tree_type; + typedef typename tree_type::const_iterator const_iterator; + + if(tree_type::constant_time_size && x.size() != y.size()){ + return false; + } + const_iterator end1 = x.end(); + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + if(tree_type::constant_time_size){ + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; + } + else{ + const_iterator end2 = y.end(); + while (i1 != end1 && i2 != end2 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1 && i2 == end2; + } +} + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y) +#else +(const avltree_impl<Config> &x, const avltree_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y) +#else +(const avltree_impl<Config> &x, const avltree_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y) +#else +(const avltree_impl<Config> &x, const avltree_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y) +#else +(const avltree_impl<Config> &x, const avltree_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(avltree_impl<T, Options...> &x, avltree_impl<T, Options...> &y) +#else +(avltree_impl<Config> &x, avltree_impl<Config> &y) +#endif +{ x.swap(y); } + +/// @cond + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none + > +#else +template<class T, class ...Options> +#endif +struct make_avltree_opt +{ + typedef typename pack_options + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + < avl_set_defaults<T>, O1, O2, O3, O4> + #else + < avl_set_defaults<T>, Options...> + #endif + ::type packed_options; + + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + + typedef avl_setopt + < value_traits + , typename packed_options::compare + , typename packed_options::size_type + , packed_options::constant_time_size + > type; +}; +/// @endcond + +//! Helper metafunction to define a \c avltree that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_avltree +{ + /// @cond + typedef avltree_impl + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + < typename make_avltree_opt<T, O1, O2, O3, O4>::type + #else + < typename make_avltree_opt<T, Options...>::type + #endif + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class avltree + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + : public make_avltree<T, O1, O2, O3, O4>::type + #else + : public make_avltree<T, Options...>::type + #endif +{ + typedef typename make_avltree + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <T, O1, O2, O3, O4> + #else + <T, Options...> + #endif + ::type Base; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::real_value_traits real_value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + + avltree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + avltree( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(unique, b, e, cmp, v_traits) + {} + + avltree(BOOST_RV_REF(avltree) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + avltree& operator=(BOOST_RV_REF(avltree) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static avltree &container_from_end_iterator(iterator end_iterator) + { return static_cast<avltree &>(Base::container_from_end_iterator(end_iterator)); } + + static const avltree &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const avltree &>(Base::container_from_end_iterator(end_iterator)); } + + static avltree &container_from_iterator(iterator it) + { return static_cast<avltree &>(Base::container_from_iterator(it)); } + + static const avltree &container_from_iterator(const_iterator it) + { return static_cast<const avltree &>(Base::container_from_iterator(it)); } +}; + +#endif + + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_AVLTREE_HPP diff --git a/src/third_party/boost/boost/intrusive/avltree_algorithms.hpp b/src/third_party/boost/boost/intrusive/avltree_algorithms.hpp new file mode 100644 index 00000000000..9b917c767d7 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/avltree_algorithms.hpp @@ -0,0 +1,943 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Daniel K. O. 2005. +// (C) Copyright Ion Gaztanaga 2007. +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +#include <cstddef> +#include <boost/intrusive/intrusive_fwd.hpp> + +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/tree_algorithms.hpp> +#include <boost/intrusive/pointer_traits.hpp> + + +namespace boost { +namespace intrusive { + +//! avltree_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <tt>balance</tt>: The type of the balance factor +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_parent(const_node_ptr n);</tt> +//! +//! <tt>static void set_parent(node_ptr n, node_ptr parent);</tt> +//! +//! <tt>static node_ptr get_left(const_node_ptr n);</tt> +//! +//! <tt>static void set_left(node_ptr n, node_ptr left);</tt> +//! +//! <tt>static node_ptr get_right(const_node_ptr n);</tt> +//! +//! <tt>static void set_right(node_ptr n, node_ptr right);</tt> +//! +//! <tt>static balance get_balance(const_node_ptr n);</tt> +//! +//! <tt>static void set_balance(node_ptr n, balance b);</tt> +//! +//! <tt>static balance negative();</tt> +//! +//! <tt>static balance zero();</tt> +//! +//! <tt>static balance positive();</tt> +template<class NodeTraits> +class avltree_algorithms +{ + public: + typedef typename NodeTraits::node node; + typedef NodeTraits node_traits; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + typedef typename NodeTraits::balance balance; + + /// @cond + private: + typedef detail::tree_algorithms<NodeTraits> tree_algorithms; + + template<class F> + struct avltree_node_cloner + : private detail::ebo_functor_holder<F> + { + typedef detail::ebo_functor_holder<F> base_t; + + avltree_node_cloner(F f) + : base_t(f) + {} + + node_ptr operator()(const node_ptr &p) + { + node_ptr n = base_t::get()(p); + NodeTraits::set_balance(n, NodeTraits::get_balance(p)); + return n; + } + }; + + struct avltree_erase_fixup + { + void operator()(const node_ptr &to_erase, const node_ptr &successor) + { NodeTraits::set_balance(successor, NodeTraits::get_balance(to_erase)); } + }; + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + /// @endcond + + public: + static node_ptr begin_node(const const_node_ptr & header) + { return tree_algorithms::begin_node(header); } + + static node_ptr end_node(const const_node_ptr & header) + { return tree_algorithms::end_node(header); } + + //! This type is the information that will be + //! filled by insert_unique_check + typedef typename tree_algorithms::insert_commit_data insert_commit_data; + + //! <b>Requires</b>: header1 and header2 must be the header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two trees. After the function header1 will contain + //! links to the second tree and header2 will have links to the first tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static void swap_tree(const node_ptr & header1, const node_ptr & header2) + { return tree_algorithms::swap_tree(header1, header2); } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & node2) + { + if(node1 == node2) + return; + + node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2)); + swap_nodes(node1, header1, node2, header2); + } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees with header header1 and header2. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) + { + if(node1 == node2) return; + + tree_algorithms::swap_nodes(node1, header1, node2, header2); + //Swap balance + balance c = NodeTraits::get_balance(node1); + NodeTraits::set_balance(node1, NodeTraits::get_balance(node2)); + NodeTraits::set_balance(node2, c); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing and comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) + { + if(node_to_be_replaced == new_node) + return; + replace_node(node_to_be_replaced, tree_algorithms::get_header(node_to_be_replaced), new_node); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! with header "header" and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::replace_node(node_to_be_replaced, header, new_node); + NodeTraits::set_balance(new_node, NodeTraits::get_balance(node_to_be_replaced)); + } + + //! <b>Requires</b>: node is a tree node but not the header. + //! + //! <b>Effects</b>: Unlinks the node and rebalances the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + static void unlink(const node_ptr & node) + { + node_ptr x = NodeTraits::get_parent(node); + if(x){ + while(!is_header(x)) + x = NodeTraits::get_parent(x); + erase(x, node); + } + } + + //! <b>Requires</b>: header is the header of a tree. + //! + //! <b>Effects</b>: Unlinks the leftmost node from the tree, and + //! updates the header link to the new leftmost node. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + static node_ptr unlink_leftmost_without_rebalance(const node_ptr & header) + { return tree_algorithms::unlink_leftmost_without_rebalance(header); } + + //! <b>Requires</b>: node is a node of the tree or an node initialized + //! by init(...). + //! + //! <b>Effects</b>: Returns true if the node is initialized by init(). + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + static bool unique(const const_node_ptr & node) + { return tree_algorithms::unique(node); } + + //! <b>Requires</b>: node is a node of the tree but it's not the header. + //! + //! <b>Effects</b>: Returns the number of nodes of the subtree. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & node) + { return tree_algorithms::count(node); } + + //! <b>Requires</b>: header is the header node of the tree. + //! + //! <b>Effects</b>: Returns the number of nodes above the header. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t size(const const_node_ptr & header) + { return tree_algorithms::size(header); } + + //! <b>Requires</b>: p is a node from the tree except the header. + //! + //! <b>Effects</b>: Returns the next node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr next_node(const node_ptr & p) + { return tree_algorithms::next_node(p); } + + //! <b>Requires</b>: p is a node from the tree except the leftmost node. + //! + //! <b>Effects</b>: Returns the previous node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr prev_node(const node_ptr & p) + { return tree_algorithms::prev_node(p); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: After the function unique(node) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init(const node_ptr & node) + { tree_algorithms::init(node); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: Initializes the header to represent an empty tree. + //! unique(header) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init_header(const node_ptr & header) + { + tree_algorithms::init_header(header); + NodeTraits::set_balance(header, NodeTraits::zero()); + } + + //! <b>Requires</b>: header must be the header of a tree, z a node + //! of that tree and z != header. + //! + //! <b>Effects</b>: Erases node "z" from the tree with header "header". + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr erase(const node_ptr & header, const node_ptr & z) + { + typename tree_algorithms::data_for_rebalance info; + tree_algorithms::erase(header, z, avltree_erase_fixup(), info); + node_ptr x = info.x; + node_ptr x_parent = info.x_parent; + + //Rebalance avltree + rebalance_after_erasure(header, x, x_parent); + return z; + } + + //! <b>Requires</b>: "cloner" must be a function + //! object taking a node_ptr and returning a new cloned node of it. "disposer" must + //! take a node_ptr and shouldn't throw. + //! + //! <b>Effects</b>: First empties target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! Then, duplicates the entire tree pointed by "source_header" cloning each + //! source node with <tt>node_ptr Cloner::operator()(const node_ptr &)</tt> to obtain + //! the nodes of the target tree. If "cloner" throws, the cloned target nodes + //! are disposed using <tt>void disposer(const node_ptr &)</tt>. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template <class Cloner, class Disposer> + static void clone + (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) + { + avltree_node_cloner<Cloner> new_cloner(cloner); + tree_algorithms::clone(source_header, target_header, new_cloner, disposer); + } + + //! <b>Requires</b>: "disposer" must be an object function + //! taking a node_ptr parameter and shouldn't throw. + //! + //! <b>Effects</b>: Empties the target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template<class Disposer> + static void clear_and_dispose(const node_ptr & header, Disposer disposer) + { tree_algorithms::clear_and_dispose(header, disposer); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is + //! not less than "key" according to "comp" or "header" if that element does + //! not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr lower_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::lower_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is greater + //! than "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr upper_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::upper_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the element that is equivalent to + //! "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr find + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::find(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an a pair of node_ptr delimiting a range containing + //! all elements that are equivalent to "key" according to "comp" or an + //! empty range that indicates the position where those elements would be + //! if they there are no equivalent elements. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, node_ptr> equal_range + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::equal_range(header, key, comp); } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the upper bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal_upper_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp) + { + tree_algorithms::insert_equal_upper_bound(h, new_node, comp); + rebalance_after_insertion(h, new_node); + return new_node; + } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the lower bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal_lower_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp) + { + tree_algorithms::insert_equal_lower_bound(h, new_node, comp); + rebalance_after_insertion(h, new_node); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. "hint" is node from + //! the "header"'s tree. + //! + //! <b>Effects</b>: Inserts new_node into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case). + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if new_node is inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal + (const node_ptr & header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp) + { + tree_algorithms::insert_equal(header, hint, new_node, comp); + rebalance_after_insertion(header, new_node); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "pos" must be a valid iterator or header (end) node. + //! "pos" must be an iterator pointing to the successor to "new_node" + //! once inserted according to the order of already inserted nodes. This function does not + //! check "pos" and this precondition must be guaranteed by the caller. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "pos" is not the successor of the newly inserted "new_node" + //! tree invariants might be broken. + static node_ptr insert_before + (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node) + { + tree_algorithms::insert_before(header, pos, new_node); + rebalance_after_insertion(header, new_node); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering no less than the + //! greatest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is less than the greatest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + static void push_back(const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::push_back(header, new_node); + rebalance_after_insertion(header, new_node); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering, no greater than the + //! lowest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is greater than the lowest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + static void push_front(const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::push_front(header, new_node); + rebalance_after_insertion(header, new_node); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { return tree_algorithms::insert_unique_check(header, key, comp, commit_data); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! "hint" is node from the "header"'s tree. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" using "hint" as a hint to where it should be + //! inserted and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! If "hint" is the upper_bound the function has constant time + //! complexity (two comparisons in the worst case). + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic, but it is + //! amortized constant time if new_node should be inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const node_ptr &hint, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { return tree_algorithms::insert_unique_check(header, hint, key, comp, commit_data); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "commit_data" must have been obtained from a previous call to + //! "insert_unique_check". No objects should have been inserted or erased + //! from the set between the "insert_unique_check" that filled "commit_data" + //! and the call to "insert_commit". + //! + //! + //! <b>Effects</b>: Inserts new_node in the set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_unique_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + static void insert_unique_commit + (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data) + { + tree_algorithms::insert_unique_commit(header, new_value, commit_data); + rebalance_after_insertion(header, new_value); + } + + //! <b>Requires</b>: "n" must be a node inserted in a tree. + //! + //! <b>Effects</b>: Returns a pointer to the header node of the tree. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_header(const node_ptr & n) + { return tree_algorithms::get_header(n); } + + /// @cond + private: + + //! <b>Requires</b>: p is a node of a tree. + //! + //! <b>Effects</b>: Returns true if p is the header of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool is_header(const const_node_ptr & p) + { return NodeTraits::get_balance(p) == NodeTraits::zero() && tree_algorithms::is_header(p); } + + static void rebalance_after_erasure(const node_ptr & header, const node_ptr & xnode, const node_ptr & xnode_parent) + { + node_ptr x(xnode), x_parent(xnode_parent); + for (node_ptr root = NodeTraits::get_parent(header); x != root; root = NodeTraits::get_parent(header)) { + const balance x_parent_balance = NodeTraits::get_balance(x_parent); + if(x_parent_balance == NodeTraits::zero()){ + NodeTraits::set_balance(x_parent, + (x == NodeTraits::get_right(x_parent) ? NodeTraits::negative() : NodeTraits::positive())); + break; // the height didn't change, let's stop here + } + else if(x_parent_balance == NodeTraits::negative()){ + if (x == NodeTraits::get_left(x_parent)) { + NodeTraits::set_balance(x_parent, NodeTraits::zero()); // balanced + x = x_parent; + x_parent = NodeTraits::get_parent(x_parent); + } + else { + // x is right child + // a is left child + node_ptr a = NodeTraits::get_left(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(a); + if (NodeTraits::get_balance(a) == NodeTraits::positive()) { + // a MUST have a right child + BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_right(a)); + rotate_left_right(x_parent, header); + x = NodeTraits::get_parent(x_parent); + x_parent = NodeTraits::get_parent(x); + } + else { + rotate_right(x_parent, header); + x = NodeTraits::get_parent(x_parent); + x_parent = NodeTraits::get_parent(x); + } + + // if changed from negative to NodeTraits::positive(), no need to check above + if (NodeTraits::get_balance(x) == NodeTraits::positive()){ + break; + } + } + } + else if(x_parent_balance == NodeTraits::positive()){ + if (x == NodeTraits::get_right(x_parent)) { + NodeTraits::set_balance(x_parent, NodeTraits::zero()); // balanced + x = x_parent; + x_parent = NodeTraits::get_parent(x_parent); + } + else { + // x is left child + // a is right child + node_ptr a = NodeTraits::get_right(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(a); + if (NodeTraits::get_balance(a) == NodeTraits::negative()) { + // a MUST have then a left child + BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_left(a)); + rotate_right_left(x_parent, header); + + x = NodeTraits::get_parent(x_parent); + x_parent = NodeTraits::get_parent(x); + } + else { + rotate_left(x_parent, header); + x = NodeTraits::get_parent(x_parent); + x_parent = NodeTraits::get_parent(x); + } + // if changed from NodeTraits::positive() to negative, no need to check above + if (NodeTraits::get_balance(x) == NodeTraits::negative()){ + break; + } + } + } + else{ + BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached + } + } + } + + static void rebalance_after_insertion(const node_ptr & header, const node_ptr & xnode) + { + node_ptr x(xnode); + NodeTraits::set_balance(x, NodeTraits::zero()); + // Rebalance. + for(node_ptr root = NodeTraits::get_parent(header); x != root; root = NodeTraits::get_parent(header)){ + const balance x_parent_balance = NodeTraits::get_balance(NodeTraits::get_parent(x)); + + if(x_parent_balance == NodeTraits::zero()){ + // if x is left, parent will have parent->bal_factor = negative + // else, parent->bal_factor = NodeTraits::positive() + NodeTraits::set_balance( NodeTraits::get_parent(x) + , x == NodeTraits::get_left(NodeTraits::get_parent(x)) + ? NodeTraits::negative() : NodeTraits::positive() ); + x = NodeTraits::get_parent(x); + } + else if(x_parent_balance == NodeTraits::positive()){ + // if x is a left child, parent->bal_factor = zero + if (x == NodeTraits::get_left(NodeTraits::get_parent(x))) + NodeTraits::set_balance(NodeTraits::get_parent(x), NodeTraits::zero()); + else{ // x is a right child, needs rebalancing + if (NodeTraits::get_balance(x) == NodeTraits::negative()) + rotate_right_left(NodeTraits::get_parent(x), header); + else + rotate_left(NodeTraits::get_parent(x), header); + } + break; + } + else if(x_parent_balance == NodeTraits::negative()){ + // if x is a left child, needs rebalancing + if (x == NodeTraits::get_left(NodeTraits::get_parent(x))) { + if (NodeTraits::get_balance(x) == NodeTraits::positive()) + rotate_left_right(NodeTraits::get_parent(x), header); + else + rotate_right(NodeTraits::get_parent(x), header); + } + else + NodeTraits::set_balance(NodeTraits::get_parent(x), NodeTraits::zero()); + break; + } + else{ + BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached + } + } + } + + static void left_right_balancing(const node_ptr & a, const node_ptr & b, const node_ptr & c) + { + // balancing... + const balance c_balance = NodeTraits::get_balance(c); + const balance zero_balance = NodeTraits::zero(); + NodeTraits::set_balance(c, zero_balance); + if(c_balance == NodeTraits::negative()){ + NodeTraits::set_balance(a, NodeTraits::positive()); + NodeTraits::set_balance(b, zero_balance); + } + else if(c_balance == zero_balance){ + NodeTraits::set_balance(a, zero_balance); + NodeTraits::set_balance(b, zero_balance); + } + else if(c_balance == NodeTraits::positive()){ + NodeTraits::set_balance(a, zero_balance); + NodeTraits::set_balance(b, NodeTraits::negative()); + } + else{ + BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached + } + } + + static void rotate_left_right(const node_ptr a, const node_ptr & hdr) + { + // | | // + // a(-2) c // + // / \ / \ // + // / \ ==> / \ // + // (pos)b [g] b a // + // / \ / \ / \ // + // [d] c [d] e f [g] // + // / \ // + // e f // + node_ptr b = NodeTraits::get_left(a), c = NodeTraits::get_right(b); + tree_algorithms::rotate_left(b, hdr); + tree_algorithms::rotate_right(a, hdr); + left_right_balancing(a, b, c); + } + + static void rotate_right_left(const node_ptr a, const node_ptr & hdr) + { + // | | // + // a(pos) c // + // / \ / \ // + // / \ / \ // + // [d] b(neg) ==> a b // + // / \ / \ / \ // + // c [g] [d] e f [g] // + // / \ // + // e f // + node_ptr b = NodeTraits::get_right(a), c = NodeTraits::get_left(b); + tree_algorithms::rotate_right(b, hdr); + tree_algorithms::rotate_left(a, hdr); + left_right_balancing(b, a, c); + } + + static void rotate_left(const node_ptr x, const node_ptr & hdr) + { + const node_ptr y = NodeTraits::get_right(x); + tree_algorithms::rotate_left(x, hdr); + + // reset the balancing factor + if (NodeTraits::get_balance(y) == NodeTraits::positive()) { + NodeTraits::set_balance(x, NodeTraits::zero()); + NodeTraits::set_balance(y, NodeTraits::zero()); + } + else { // this doesn't happen during insertions + NodeTraits::set_balance(x, NodeTraits::positive()); + NodeTraits::set_balance(y, NodeTraits::negative()); + } + } + + static void rotate_right(const node_ptr x, const node_ptr & hdr) + { + const node_ptr y = NodeTraits::get_left(x); + tree_algorithms::rotate_right(x, hdr); + + // reset the balancing factor + if (NodeTraits::get_balance(y) == NodeTraits::negative()) { + NodeTraits::set_balance(x, NodeTraits::zero()); + NodeTraits::set_balance(y, NodeTraits::zero()); + } + else { // this doesn't happen during insertions + NodeTraits::set_balance(x, NodeTraits::negative()); + NodeTraits::set_balance(y, NodeTraits::positive()); + } + } + + /// @endcond +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/bs_set_hook.hpp b/src/third_party/boost/boost/intrusive/bs_set_hook.hpp new file mode 100644 index 00000000000..bf8e2de09a6 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/bs_set_hook.hpp @@ -0,0 +1,296 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_BS_SET_HOOK_HPP +#define BOOST_INTRUSIVE_BS_SET_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/tree_node.hpp> +#include <boost/intrusive/detail/tree_algorithms.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +template<class VoidPointer> +struct get_bs_set_node_algo +{ + typedef detail::tree_algorithms<tree_node_traits<VoidPointer> > type; +}; +/// @endcond + +//! Helper metafunction to define a \c bs_set_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_bs_set_base_hook +{ + /// @cond + typedef typename pack_options + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + < hook_defaults, O1, O2, O3> + #else + < hook_defaults, Options...> + #endif + ::type packed_options; + + //Scapegoat trees can't be auto unlink trees + BOOST_STATIC_ASSERT(((int)packed_options::link_mode != (int)auto_unlink)); + + typedef detail::generic_hook + < get_bs_set_node_algo<typename packed_options::void_pointer> + , typename packed_options::tag + , packed_options::link_mode + , detail::BsSetBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from bs_set_base_hook in order to store objects in +//! in a bs_set/bs_multiset. bs_set_base_hook holds the data necessary to maintain +//! the bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<>, +//! \c link_mode<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its +//! unique tag. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class bs_set_base_hook + : public make_bs_set_base_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3> + #else + <Options...> + #endif + ::type + +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + bs_set_base_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + bs_set_base_hook(const bs_set_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + bs_set_base_hook& operator=(const bs_set_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~bs_set_base_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(bs_set_base_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +//! Helper metafunction to define a \c bs_set_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_bs_set_member_hook +{ + /// @cond + typedef typename pack_options + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + < hook_defaults, O1, O2, O3> + #else + < hook_defaults, Options...> + #endif + + ::type packed_options; + + //Scapegoat trees can't be auto unlink trees + BOOST_STATIC_ASSERT(((int)packed_options::link_mode != (int)auto_unlink)); + + typedef detail::generic_hook + < get_bs_set_node_algo<typename packed_options::void_pointer> + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Put a public data member bs_set_member_hook in order to store objects of this class in +//! a bs_set/bs_multiset. bs_set_member_hook holds the data necessary for maintaining the +//! bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset. +//! +//! The hook admits the following options: \c void_pointer<>, \c link_mode<>. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class bs_set_member_hook + : public make_bs_set_member_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3> + #else + <Options...> + #endif + ::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + bs_set_member_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + bs_set_member_hook(const bs_set_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + bs_set_member_hook& operator=(const bs_set_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~bs_set_member_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(bs_set_member_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_BS_SET_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/circular_list_algorithms.hpp b/src/third_party/boost/boost/intrusive/circular_list_algorithms.hpp new file mode 100644 index 00000000000..c5de423b629 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/circular_list_algorithms.hpp @@ -0,0 +1,413 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <cstddef> + +namespace boost { +namespace intrusive { + +//! circular_list_algorithms provides basic algorithms to manipulate nodes +//! forming a circular doubly linked list. An empty circular list is formed by a node +//! whose pointers point to itself. +//! +//! circular_list_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_previous(const_node_ptr n);</tt> +//! +//! <tt>static void set_previous(node_ptr n, node_ptr prev);</tt> +//! +//! <tt>static node_ptr get_next(const_node_ptr n);</tt> +//! +//! <tt>static void set_next(node_ptr n, node_ptr next);</tt> +template<class NodeTraits> +class circular_list_algorithms +{ + public: + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + typedef NodeTraits node_traits; + + //! <b>Effects</b>: Constructs an non-used list element, so that + //! inited(this_node) == true + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void init(const node_ptr &this_node) + { + NodeTraits::set_next(this_node, node_ptr()); + NodeTraits::set_previous(this_node, node_ptr()); + } + + //! <b>Effects</b>: Returns true is "this_node" is in a non-used state + //! as if it was initialized by the "init" function. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static bool inited(const const_node_ptr &this_node) + { return !NodeTraits::get_next(this_node); } + + //! <b>Effects</b>: Constructs an empty list, making this_node the only + //! node of the circular list: + //! <tt>NodeTraits::get_next(this_node) == NodeTraits::get_previous(this_node) + //! == this_node</tt>. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void init_header(const node_ptr &this_node) + { + NodeTraits::set_next(this_node, this_node); + NodeTraits::set_previous(this_node, this_node); + } + + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Returns true is "this_node" is the only node of a circular list: + //! <tt>return NodeTraits::get_next(this_node) == this_node</tt> + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static bool unique(const const_node_ptr &this_node) + { + node_ptr next = NodeTraits::get_next(this_node); + return !next || next == this_node; + } + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Returns the number of nodes in a circular list. If the circular list + //! is empty, returns 1. + //! + //! <b>Complexity</b>: Linear + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr &this_node) + { + std::size_t result = 0; + const_node_ptr p = this_node; + do{ + p = NodeTraits::get_next(p); + ++result; + }while (p != this_node); + return result; + } + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Unlinks the node from the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static node_ptr unlink(const node_ptr &this_node) + { + node_ptr next(NodeTraits::get_next(this_node)); + if(next){ + node_ptr prev(NodeTraits::get_previous(this_node)); + NodeTraits::set_next(prev, next); + NodeTraits::set_previous(next, prev); + return next; + } + else{ + return this_node; + } + } + + //! <b>Requires</b>: b and e must be nodes of the same circular list or an empty range. + //! + //! <b>Effects</b>: Unlinks the node [b, e) from the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void unlink(const node_ptr &b, const node_ptr &e) + { + if (b != e) { + node_ptr prevb(NodeTraits::get_previous(b)); + NodeTraits::set_previous(e, prevb); + NodeTraits::set_next(prevb, e); + } + } + + //! <b>Requires</b>: nxt_node must be a node of a circular list. + //! + //! <b>Effects</b>: Links this_node before nxt_node in the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void link_before(const node_ptr &nxt_node, const node_ptr &this_node) + { + node_ptr prev(NodeTraits::get_previous(nxt_node)); + NodeTraits::set_previous(this_node, prev); + NodeTraits::set_next(this_node, nxt_node); + //nxt_node might be an alias for prev->next_ + //so use it before update it before NodeTraits::set_next(prev, ...) + //is called and the reference changes it's value + NodeTraits::set_previous(nxt_node, this_node); + NodeTraits::set_next(prev, this_node); + } + + //! <b>Requires</b>: prev_node must be a node of a circular list. + //! + //! <b>Effects</b>: Links this_node after prev_node in the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void link_after(const node_ptr &prev_node, const node_ptr &this_node) + { + node_ptr next(NodeTraits::get_next(prev_node)); + NodeTraits::set_previous(this_node, prev_node); + NodeTraits::set_next(this_node, next); + //prev_node might be an alias for next->next_ + //so use it before update it before NodeTraits::set_previous(next, ...) + //is called and the reference changes it's value + NodeTraits::set_next(prev_node, this_node); + NodeTraits::set_previous(next, this_node); + } + + //! <b>Requires</b>: this_node and other_node must be nodes inserted + //! in circular lists or be empty circular lists. + //! + //! <b>Effects</b>: Swaps the position of the nodes: this_node is inserted in + //! other_nodes position in the second circular list and the other_node is inserted + //! in this_node's position in the first circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. +/* + static void swap_nodes(const node_ptr &this_node, const node_ptr &other_node) + { + + if (other_node == this_node) + return; + bool empty1 = unique(this_node); + bool empty2 = unique(other_node); + + node_ptr next_this(NodeTraits::get_next(this_node)); + node_ptr prev_this(NodeTraits::get_previous(this_node)); + node_ptr next_other(NodeTraits::get_next(other_node)); + node_ptr prev_other(NodeTraits::get_previous(other_node)); + + //Do the swap + NodeTraits::set_next(this_node, next_other); + NodeTraits::set_next(other_node, next_this); + + NodeTraits::set_previous(this_node, prev_other); + NodeTraits::set_previous(other_node, prev_this); + + if (empty2){ + init(this_node); + } + else{ + NodeTraits::set_next(prev_other, this_node); + NodeTraits::set_previous(next_other, this_node); + } + if (empty1){ + init(other_node); + } + else{ + NodeTraits::set_next(prev_this, other_node); + NodeTraits::set_previous(next_this, other_node); + } + } +*/ + + //Watanabe version + private: + static void swap_prev(const node_ptr &this_node, const node_ptr &other_node) + { + node_ptr temp(NodeTraits::get_previous(this_node)); + NodeTraits::set_previous(this_node, NodeTraits::get_previous(other_node)); + NodeTraits::set_previous(other_node, temp); + } + static void swap_next(const node_ptr &this_node, const node_ptr &other_node) + { + node_ptr temp(NodeTraits::get_next(this_node)); + NodeTraits::set_next(this_node, NodeTraits::get_next(other_node)); + NodeTraits::set_next(other_node, temp); + } + + public: + static void swap_nodes(const node_ptr &this_node, const node_ptr &other_node) + { + if (other_node == this_node) + return; + bool this_inited = inited(this_node); + bool other_inited = inited(other_node); + if(this_inited){ + init_header(this_node); + } + if(other_inited){ + init_header(other_node); + } + + node_ptr next_this(NodeTraits::get_next(this_node)); + node_ptr prev_this(NodeTraits::get_previous(this_node)); + node_ptr next_other(NodeTraits::get_next(other_node)); + node_ptr prev_other(NodeTraits::get_previous(other_node)); + //these first two swaps must happen before the other two + swap_prev(next_this, next_other); + swap_next(prev_this, prev_other); + swap_next(this_node, other_node); + swap_prev(this_node, other_node); + + if(this_inited){ + init(other_node); + } + if(other_inited){ + init(this_node); + } + } + + //! <b>Requires</b>: b and e must be nodes of the same circular list or an empty range. + //! and p must be a node of a different circular list or may not be an iterator in + // [b, e). + //! + //! <b>Effects</b>: Removes the nodes from [b, e) range from their circular list and inserts + //! them before p in p's circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void transfer(const node_ptr &p, const node_ptr &b, const node_ptr &e) + { + if (b != e) { + node_ptr prev_p(NodeTraits::get_previous(p)); + node_ptr prev_b(NodeTraits::get_previous(b)); + node_ptr prev_e(NodeTraits::get_previous(e)); + NodeTraits::set_next(prev_e, p); + NodeTraits::set_previous(p, prev_e); + NodeTraits::set_next(prev_b, e); + NodeTraits::set_previous(e, prev_b); + NodeTraits::set_next(prev_p, b); + NodeTraits::set_previous(b, prev_p); + } + } + + //! <b>Requires</b>: i must a node of a circular list + //! and p must be a node of a different circular list. + //! + //! <b>Effects</b>: Removes the node i from its circular list and inserts + //! it before p in p's circular list. + //! If p == i or p == NodeTraits::get_next(i), this function is a null operation. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void transfer(const node_ptr &p, const node_ptr &i) + { + node_ptr n(NodeTraits::get_next(i)); + if(n != p && i != p){ + node_ptr prev_p(NodeTraits::get_previous(p)); + node_ptr prev_i(NodeTraits::get_previous(i)); + NodeTraits::set_next(prev_p, i); + NodeTraits::set_previous(i, prev_p); + NodeTraits::set_next(i, p); + NodeTraits::set_previous(p, i); + NodeTraits::set_previous(n, prev_i); + NodeTraits::set_next(prev_i, n); + + } + } + + //! <b>Effects</b>: Reverses the order of elements in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: This function is linear time. + static void reverse(const node_ptr &p) + { + node_ptr f(NodeTraits::get_next(p)); + node_ptr i(NodeTraits::get_next(f)), e(p); + + while(i != e) { + node_ptr n = i; + i = NodeTraits::get_next(i); + transfer(f, n, i); + f = n; + } + } + + //! <b>Effects</b>: Moves the node p n positions towards the end of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of moved positions. + static void move_backwards(const node_ptr &p, std::size_t n) + { + //Null shift, nothing to do + if(!n) return; + node_ptr first = NodeTraits::get_next(p); + //size() == 0 or 1, nothing to do + if(first == NodeTraits::get_previous(p)) return; + unlink(p); + //Now get the new first node + while(n--){ + first = NodeTraits::get_next(first); + } + link_before(first, p); + } + + //! <b>Effects</b>: Moves the node p n positions towards the beginning of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of moved positions. + static void move_forward(const node_ptr &p, std::size_t n) + { + //Null shift, nothing to do + if(!n) return; + node_ptr last = NodeTraits::get_previous(p); + //size() == 0 or 1, nothing to do + if(last == NodeTraits::get_next(p)) return; + + unlink(p); + //Now get the new last node + while(n--){ + last = NodeTraits::get_previous(last); + } + link_after(last, p); + } +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/circular_slist_algorithms.hpp b/src/third_party/boost/boost/intrusive/circular_slist_algorithms.hpp new file mode 100644 index 00000000000..b843590c153 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/circular_slist_algorithms.hpp @@ -0,0 +1,405 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/common_slist_algorithms.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <cstddef> + +namespace boost { +namespace intrusive { + +//! circular_slist_algorithms provides basic algorithms to manipulate nodes +//! forming a circular singly linked list. An empty circular list is formed by a node +//! whose pointer to the next node points to itself. +//! +//! circular_slist_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_next(const_node_ptr n);</tt> +//! +//! <tt>static void set_next(node_ptr n, node_ptr next);</tt> +template<class NodeTraits> +class circular_slist_algorithms + /// @cond + : public detail::common_slist_algorithms<NodeTraits> + /// @endcond +{ + /// @cond + typedef detail::common_slist_algorithms<NodeTraits> base_t; + /// @endcond + public: + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + typedef NodeTraits node_traits; + + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + + //! <b>Effects</b>: Constructs an non-used list element, putting the next + //! pointer to null: + //! <tt>NodeTraits::get_next(this_node) == node_ptr()</tt> + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void init(node_ptr this_node); + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Returns true is "this_node" is the only node of a circular list: + //! or it's a not inserted node: + //! <tt>return node_ptr() == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node</tt> + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static bool unique(const_node_ptr this_node); + + //! <b>Effects</b>: Returns true is "this_node" has the same state as + //! if it was inited using "init(node_ptr)" + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static bool inited(const_node_ptr this_node); + + //! <b>Requires</b>: prev_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Unlinks the next node of prev_node from the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void unlink_after(node_ptr prev_node); + + //! <b>Requires</b>: prev_node and last_node must be in a circular list + //! or be an empty circular list. + //! + //! <b>Effects</b>: Unlinks the range (prev_node, last_node) from the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void unlink_after(node_ptr prev_node, node_ptr last_node); + + //! <b>Requires</b>: prev_node must be a node of a circular list. + //! + //! <b>Effects</b>: Links this_node after prev_node in the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void link_after(node_ptr prev_node, node_ptr this_node); + + //! <b>Requires</b>: b and e must be nodes of the same circular list or an empty range. + //! and p must be a node of a different circular list. + //! + //! <b>Effects</b>: Removes the nodes from (b, e] range from their circular list and inserts + //! them after p in p's circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void transfer_after(node_ptr p, node_ptr b, node_ptr e); + + #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + + //! <b>Effects</b>: Constructs an empty list, making this_node the only + //! node of the circular list: + //! <tt>NodeTraits::get_next(this_node) == this_node</tt>. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void init_header(const node_ptr &this_node) + { NodeTraits::set_next(this_node, this_node); } + + //! <b>Requires</b>: this_node and prev_init_node must be in the same circular list. + //! + //! <b>Effects</b>: Returns the previous node of this_node in the circular list starting. + //! the search from prev_init_node. The first node checked for equality + //! is NodeTraits::get_next(prev_init_node). + //! + //! <b>Complexity</b>: Linear to the number of elements between prev_init_node and this_node. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_previous_node(const node_ptr &prev_init_node, const node_ptr &this_node) + { return base_t::get_previous_node(prev_init_node, this_node); } + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Returns the previous node of this_node in the circular list. + //! + //! <b>Complexity</b>: Linear to the number of elements in the circular list. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_previous_node(const node_ptr & this_node) + { return base_t::get_previous_node(this_node, this_node); } + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Returns the previous node of the previous node of this_node in the circular list. + //! + //! <b>Complexity</b>: Linear to the number of elements in the circular list. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_previous_previous_node(const node_ptr & this_node) + { return get_previous_previous_node(this_node, this_node); } + + //! <b>Requires</b>: this_node and prev_prev_init_node must be in the same circular list. + //! + //! <b>Effects</b>: Returns the previous node of the previous node of this_node in the + //! circular list starting. the search from prev_init_node. The first node checked + //! for equality is NodeTraits::get_next((NodeTraits::get_next(prev_prev_init_node)). + //! + //! <b>Complexity</b>: Linear to the number of elements in the circular list. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_previous_previous_node(const node_ptr & prev_prev_init_node, const node_ptr & this_node) + { + node_ptr p = prev_prev_init_node; + node_ptr p_next = NodeTraits::get_next(p); + node_ptr p_next_next = NodeTraits::get_next(p_next); + while (this_node != p_next_next){ + p = p_next; + p_next = p_next_next; + p_next_next = NodeTraits::get_next(p_next); + } + return p; + } + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Returns the number of nodes in a circular list. If the circular list + //! is empty, returns 1. + //! + //! <b>Complexity</b>: Linear + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & this_node) + { + std::size_t result = 0; + const_node_ptr p = this_node; + do{ + p = NodeTraits::get_next(p); + ++result; + } while (p != this_node); + return result; + } + + //! <b>Requires</b>: this_node must be in a circular list, be an empty circular list or be inited. + //! + //! <b>Effects</b>: Unlinks the node from the circular list. + //! + //! <b>Complexity</b>: Linear to the number of elements in the circular list + //! + //! <b>Throws</b>: Nothing. + static void unlink(const node_ptr & this_node) + { + if(NodeTraits::get_next(this_node)) + base_t::unlink_after(get_previous_node(this_node)); + } + + //! <b>Requires</b>: nxt_node must be a node of a circular list. + //! + //! <b>Effects</b>: Links this_node before nxt_node in the circular list. + //! + //! <b>Complexity</b>: Linear to the number of elements in the circular list. + //! + //! <b>Throws</b>: Nothing. + static void link_before (const node_ptr & nxt_node, const node_ptr & this_node) + { base_t::link_after(get_previous_node(nxt_node), this_node); } + + //! <b>Requires</b>: this_node and other_node must be nodes inserted + //! in circular lists or be empty circular lists. + //! + //! <b>Effects</b>: Swaps the position of the nodes: this_node is inserted in + //! other_nodes position in the second circular list and the other_node is inserted + //! in this_node's position in the first circular list. + //! + //! <b>Complexity</b>: Linear to number of elements of both lists + //! + //! <b>Throws</b>: Nothing. + static void swap_nodes(const node_ptr & this_node, const node_ptr & other_node) + { + if (other_node == this_node) + return; + bool this_inited = base_t::inited(this_node); + bool other_inited = base_t::inited(other_node); + if(this_inited){ + base_t::init_header(this_node); + } + if(other_inited){ + base_t::init_header(other_node); + } + + bool empty1 = base_t::unique(this_node); + bool empty2 = base_t::unique(other_node); + node_ptr prev_this (get_previous_node(this_node)); + node_ptr prev_other(get_previous_node(other_node)); + + node_ptr this_next (NodeTraits::get_next(this_node)); + node_ptr other_next(NodeTraits::get_next(other_node)); + NodeTraits::set_next(this_node, other_next); + NodeTraits::set_next(other_node, this_next); + NodeTraits::set_next(empty1 ? other_node : prev_this, other_node); + NodeTraits::set_next(empty2 ? this_node : prev_other, this_node); + + if(this_inited){ + base_t::init(other_node); + } + if(other_inited){ + base_t::init(this_node); + } + } + + //! <b>Effects</b>: Reverses the order of elements in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: This function is linear to the contained elements. + static void reverse(const node_ptr & p) + { + node_ptr i = NodeTraits::get_next(p), e(p); + for (;;) { + node_ptr nxt(NodeTraits::get_next(i)); + if (nxt == e) + break; + base_t::transfer_after(e, i, nxt); + } + } + + //! <b>Effects</b>: Moves the node p n positions towards the end of the list. + //! + //! <b>Returns</b>: The previous node of p after the function if there has been any movement, + //! Null if n leads to no movement. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements plus the number moved positions. + static node_ptr move_backwards(const node_ptr & p, std::size_t n) + { + //Null shift, nothing to do + if(!n) return node_ptr(); + node_ptr first = NodeTraits::get_next(p); + + //count() == 1 or 2, nothing to do + if(NodeTraits::get_next(first) == p) + return node_ptr(); + + bool end_found = false; + node_ptr new_last = node_ptr(); + + //Now find the new last node according to the shift count. + //If we find p before finding the new last node + //unlink p, shortcut the search now that we know the size of the list + //and continue. + for(std::size_t i = 1; i <= n; ++i){ + new_last = first; + first = NodeTraits::get_next(first); + if(first == p){ + //Shortcut the shift with the modulo of the size of the list + n %= i; + if(!n) + return node_ptr(); + i = 0; + //Unlink p and continue the new first node search + first = NodeTraits::get_next(p); + base_t::unlink_after(new_last); + end_found = true; + } + } + + //If the p has not been found in the previous loop, find it + //starting in the new first node and unlink it + if(!end_found){ + base_t::unlink_after(base_t::get_previous_node(first, p)); + } + + //Now link p after the new last node + base_t::link_after(new_last, p); + return new_last; + } + + //! <b>Effects</b>: Moves the node p n positions towards the beginning of the list. + //! + //! <b>Returns</b>: The previous node of p after the function if there has been any movement, + //! Null if n leads equals to no movement. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements plus the number moved positions. + static node_ptr move_forward(const node_ptr & p, std::size_t n) + { + //Null shift, nothing to do + if(!n) return node_ptr(); + node_ptr first = node_traits::get_next(p); + + //count() == 1 or 2, nothing to do + if(node_traits::get_next(first) == p) return node_ptr(); + + //Iterate until p is found to know where the current last node is. + //If the shift count is less than the size of the list, we can also obtain + //the position of the new last node after the shift. + node_ptr old_last(first), next_to_it, new_last(p); + std::size_t distance = 1; + while(p != (next_to_it = node_traits::get_next(old_last))){ + if(++distance > n) + new_last = node_traits::get_next(new_last); + old_last = next_to_it; + } + //If the shift was bigger or equal than the size, obtain the equivalent + //forward shifts and find the new last node. + if(distance <= n){ + //Now find the equivalent forward shifts. + //Shortcut the shift with the modulo of the size of the list + std::size_t new_before_last_pos = (distance - (n % distance))% distance; + //If the shift is a multiple of the size there is nothing to do + if(!new_before_last_pos) return node_ptr(); + + for( new_last = p + ; new_before_last_pos-- + ; new_last = node_traits::get_next(new_last)){ + //empty + } + } + + //Now unlink p and link it after the new last node + base_t::unlink_after(old_last); + base_t::link_after(new_last, p); + return new_last; + } +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/derivation_value_traits.hpp b/src/third_party/boost/boost/intrusive/derivation_value_traits.hpp new file mode 100644 index 00000000000..38c5aa57cfe --- /dev/null +++ b/src/third_party/boost/boost/intrusive/derivation_value_traits.hpp @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP +#define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP + +#include <boost/intrusive/link_mode.hpp> +#include <boost/pointer_cast.hpp> +#include <boost/pointer_to_other.hpp> +#include <iterator> + +namespace boost { +namespace intrusive { + +//!This value traits template is used to create value traits +//!from user defined node traits where value_traits::value_type will +//!derive from node_traits::node +template<class T, class NodeTraits, link_mode_type LinkMode = safe_link> +struct derivation_value_traits +{ + public: + typedef NodeTraits node_traits; + typedef T value_type; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef typename boost::pointer_to_other<node_ptr, T>::type pointer; + typedef typename boost::pointer_to_other<node_ptr, const T>::type const_pointer; + typedef typename boost::intrusive:: + pointer_traits<pointer>::reference reference; + typedef typename boost::intrusive:: + pointer_traits<const_pointer>::reference const_reference; + static const link_mode_type link_mode = LinkMode; + + static node_ptr to_node_ptr(reference value) + { return node_ptr(&value); } + + static const_node_ptr to_node_ptr(const_reference value) + { return node_ptr(&value); } + + static pointer to_value_ptr(const node_ptr &n) + { +// This still fails in gcc < 4.4 so forget about it +// using ::boost::static_pointer_cast; +// return static_pointer_cast<value_type>(n)); + return pointer(&static_cast<value_type&>(*n)); + } + + static const_pointer to_value_ptr(const const_node_ptr &n) + { +// This still fails in gcc < 4.4 so forget about it +// using ::boost::static_pointer_cast; +// return static_pointer_cast<const value_type>(n)); + return const_pointer(&static_cast<const value_type&>(*n)); + } +}; + +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/any_node_and_algorithms.hpp b/src/third_party/boost/boost/intrusive/detail/any_node_and_algorithms.hpp new file mode 100644 index 00000000000..bda9ad3c45a --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/any_node_and_algorithms.hpp @@ -0,0 +1,297 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_ANY_NODE_HPP +#define BOOST_INTRUSIVE_ANY_NODE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <cstddef> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/pointer_cast.hpp> + +namespace boost { +namespace intrusive { + +template<class VoidPointer> +struct any_node +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<any_node>::type node_ptr; + node_ptr node_ptr_1; + node_ptr node_ptr_2; + node_ptr node_ptr_3; + std::size_t size_t_1; +}; + +template<class VoidPointer> +struct any_list_node_traits +{ + typedef any_node<VoidPointer> node; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + + static const node_ptr &get_next(const const_node_ptr & n) + { return n->node_ptr_1; } + + static void set_next(const node_ptr & n, const node_ptr & next) + { n->node_ptr_1 = next; } + + static const node_ptr &get_previous(const const_node_ptr & n) + { return n->node_ptr_2; } + + static void set_previous(const node_ptr & n, const node_ptr & prev) + { n->node_ptr_2 = prev; } +}; + + +template<class VoidPointer> +struct any_slist_node_traits +{ + typedef any_node<VoidPointer> node; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + + static const node_ptr &get_next(const const_node_ptr & n) + { return n->node_ptr_1; } + + static void set_next(const node_ptr & n, const node_ptr & next) + { n->node_ptr_1 = next; } +}; + + +template<class VoidPointer> +struct any_unordered_node_traits + : public any_slist_node_traits<VoidPointer> +{ + typedef any_slist_node_traits<VoidPointer> reduced_slist_node_traits; + typedef typename reduced_slist_node_traits::node node; + typedef typename reduced_slist_node_traits::node_ptr node_ptr; + typedef typename reduced_slist_node_traits::const_node_ptr const_node_ptr; + + static const bool store_hash = true; + static const bool optimize_multikey = true; + + static const node_ptr &get_next(const const_node_ptr & n) + { return n->node_ptr_1; } + + static void set_next(const node_ptr & n, const node_ptr & next) + { n->node_ptr_1 = next; } + + static node_ptr get_prev_in_group(const const_node_ptr & n) + { return n->node_ptr_2; } + + static void set_prev_in_group(const node_ptr & n, const node_ptr & prev) + { n->node_ptr_2 = prev; } + + static std::size_t get_hash(const const_node_ptr & n) + { return n->size_t_1; } + + static void set_hash(const node_ptr & n, std::size_t h) + { n->size_t_1 = h; } +}; + + +template<class VoidPointer> +struct any_rbtree_node_traits +{ + typedef any_node<VoidPointer> node; + + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + + typedef std::size_t color; + + static const node_ptr &get_parent(const const_node_ptr & n) + { return n->node_ptr_1; } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { n->node_ptr_1 = p; } + + static const node_ptr &get_left(const const_node_ptr & n) + { return n->node_ptr_2; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->node_ptr_2 = l; } + + static const node_ptr &get_right(const const_node_ptr & n) + { return n->node_ptr_3; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->node_ptr_3 = r; } + + static color get_color(const const_node_ptr & n) + { return n->size_t_1; } + + static void set_color(const node_ptr & n, color c) + { n->size_t_1 = c; } + + static color black() + { return 0u; } + + static color red() + { return 1u; } +}; + + +template<class VoidPointer> +struct any_avltree_node_traits +{ + typedef any_node<VoidPointer> node; + + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + typedef std::size_t balance; + + static const node_ptr &get_parent(const const_node_ptr & n) + { return n->node_ptr_1; } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { n->node_ptr_1 = p; } + + static const node_ptr &get_left(const const_node_ptr & n) + { return n->node_ptr_2; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->node_ptr_2 = l; } + + static const node_ptr &get_right(const const_node_ptr & n) + { return n->node_ptr_3; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->node_ptr_3 = r; } + + static balance get_balance(const const_node_ptr & n) + { return n->size_t_1; } + + static void set_balance(const node_ptr & n, balance b) + { n->size_t_1 = b; } + + static balance negative() + { return 0u; } + + static balance zero() + { return 1u; } + + static balance positive() + { return 2u; } +}; + + +template<class VoidPointer> +struct any_tree_node_traits +{ + typedef any_node<VoidPointer> node; + + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + + static const node_ptr &get_parent(const const_node_ptr & n) + { return n->node_ptr_1; } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { n->node_ptr_1 = p; } + + static const node_ptr &get_left(const const_node_ptr & n) + { return n->node_ptr_2; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->node_ptr_2 = l; } + + static const node_ptr &get_right(const const_node_ptr & n) + { return n->node_ptr_3; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->node_ptr_3 = r; } +}; + +template<class VoidPointer> +class any_node_traits +{ + public: + typedef any_node<VoidPointer> node; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; +}; + +template<class VoidPointer> +class any_algorithms +{ + template <class T> + static void function_not_available_for_any_hooks(typename detail::enable_if<detail::is_same<T, bool> >::type) + {} + + public: + typedef any_node<VoidPointer> node; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + typedef any_node_traits<VoidPointer> node_traits; + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: After the function unique(node) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init(const node_ptr & node) + { node->node_ptr_1 = 0; }; + + //! <b>Effects</b>: Returns true if node is in the same state as if called init(node) + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool inited(const const_node_ptr & node) + { return !node->node_ptr_1; }; + + static bool unique(const const_node_ptr & node) + { return 0 == node->node_ptr_1; } + + static void unlink(const node_ptr &) + { + //Auto-unlink hooks and unlink() are not available for any hooks + any_algorithms<VoidPointer>::template function_not_available_for_any_hooks<node_ptr>(); + } + + static void swap_nodes(const node_ptr & l, const node_ptr & r) + { + //Any nodes have no swap_nodes capability because they don't know + //what algorithm they must use to unlink the node from the container + any_algorithms<VoidPointer>::template function_not_available_for_any_hooks<node_ptr>(); + } +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_ANY_NODE_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/assert.hpp b/src/third_party/boost/boost/intrusive/detail/assert.hpp new file mode 100644 index 00000000000..cfe392bfb08 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/assert.hpp @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_ASSERT_HPP +#define BOOST_INTRUSIVE_DETAIL_ASSERT_HPP + +#if defined(_MSC_VER)&&(_MSC_VER>=1200) +#pragma once +#endif + +#if !defined(BOOST_INTRUSIVE_INVARIANT_ASSERT) + #include <boost/assert.hpp> + #define BOOST_INTRUSIVE_INVARIANT_ASSERT BOOST_ASSERT +#elif defined(BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE) + #include BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE +#endif + +#if !defined(BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT) + #include <boost/assert.hpp> + #define BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT BOOST_ASSERT +#elif defined(BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE) + #include BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE +#endif + +#if !defined(BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT) + #include <boost/assert.hpp> + #define BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT BOOST_ASSERT +#elif defined(BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE) + #include BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE +#endif + +#endif //BOOST_INTRUSIVE_DETAIL_ASSERT_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/avltree_node.hpp b/src/third_party/boost/boost/intrusive/detail/avltree_node.hpp new file mode 100644 index 00000000000..dc600e6695f --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/avltree_node.hpp @@ -0,0 +1,185 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007. +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_AVLTREE_NODE_HPP +#define BOOST_INTRUSIVE_AVLTREE_NODE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/avltree_algorithms.hpp> +#include <boost/intrusive/pointer_plus_bits.hpp> +#include <boost/intrusive/detail/mpl.hpp> + +namespace boost { +namespace intrusive { + +///////////////////////////////////////////////////////////////////////////// +// // +// Generic node_traits for any pointer type // +// // +///////////////////////////////////////////////////////////////////////////// + +//This is the compact representation: 3 pointers +template<class VoidPointer> +struct compact_avltree_node +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <compact_avltree_node<VoidPointer> >::type node_ptr; + enum balance { negative_t, zero_t, positive_t }; + node_ptr parent_, left_, right_; +}; + +//This is the normal representation: 3 pointers + enum +template<class VoidPointer> +struct avltree_node +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <avltree_node<VoidPointer> >::type node_ptr; + enum balance { negative_t, zero_t, positive_t }; + node_ptr parent_, left_, right_; + balance balance_; +}; + +//This is the default node traits implementation +//using a node with 3 generic pointers plus an enum +template<class VoidPointer> +struct default_avltree_node_traits_impl +{ + typedef avltree_node<VoidPointer> node; + + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <const node>::type const_node_ptr; + + typedef typename node::balance balance; + + static const node_ptr & get_parent(const const_node_ptr & n) + { return n->parent_; } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { n->parent_ = p; } + + static const node_ptr & get_left(const const_node_ptr & n) + { return n->left_; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->left_ = l; } + + static const node_ptr & get_right(const const_node_ptr & n) + { return n->right_; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->right_ = r; } + + static balance get_balance(const const_node_ptr & n) + { return n->balance_; } + + static void set_balance(const node_ptr & n, balance b) + { n->balance_ = b; } + + static balance negative() + { return node::negative_t; } + + static balance zero() + { return node::zero_t; } + + static balance positive() + { return node::positive_t; } +}; + +//This is the compact node traits implementation +//using a node with 3 generic pointers +template<class VoidPointer> +struct compact_avltree_node_traits_impl +{ + typedef compact_avltree_node<VoidPointer> node; + + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <const node>::type const_node_ptr; + typedef typename node::balance balance; + + typedef pointer_plus_bits<node_ptr, 2> ptr_bit; + + static node_ptr get_parent(const const_node_ptr & n) + { return ptr_bit::get_pointer(n->parent_); } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { ptr_bit::set_pointer(n->parent_, p); } + + static const node_ptr & get_left(const const_node_ptr & n) + { return n->left_; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->left_ = l; } + + static const node_ptr & get_right(const const_node_ptr & n) + { return n->right_; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->right_ = r; } + + static balance get_balance(const const_node_ptr & n) + { return (balance)ptr_bit::get_bits(n->parent_); } + + static void set_balance(const node_ptr & n, balance b) + { ptr_bit::set_bits(n->parent_, (std::size_t)b); } + + static balance negative() + { return node::negative_t; } + + static balance zero() + { return node::zero_t; } + + static balance positive() + { return node::positive_t; } +}; + +//Dispatches the implementation based on the boolean +template<class VoidPointer, bool Compact> +struct avltree_node_traits_dispatch + : public default_avltree_node_traits_impl<VoidPointer> +{}; + +template<class VoidPointer> +struct avltree_node_traits_dispatch<VoidPointer, true> + : public compact_avltree_node_traits_impl<VoidPointer> +{}; + +//Inherit from the detail::link_dispatch depending on the embedding capabilities +template<class VoidPointer, bool OptimizeSize = false> +struct avltree_node_traits + : public avltree_node_traits_dispatch + < VoidPointer + , OptimizeSize && + max_pointer_plus_bits + < VoidPointer + , detail::alignment_of<compact_avltree_node<VoidPointer> >::value + >::value >= 2u + > +{}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_AVLTREE_NODE_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/clear_on_destructor_base.hpp b/src/third_party/boost/boost/intrusive/detail/clear_on_destructor_base.hpp new file mode 100644 index 00000000000..6765dfa05df --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/clear_on_destructor_base.hpp @@ -0,0 +1,36 @@ +//////} // /////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_CLEAR_ON_DESTRUCTOR_HPP +#define BOOST_INTRUSIVE_DETAIL_CLEAR_ON_DESTRUCTOR_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +namespace boost { +namespace intrusive { +namespace detail { + +template<class Derived> +class clear_on_destructor_base +{ + protected: + ~clear_on_destructor_base() + { + static_cast<Derived*>(this)->clear(); + } +}; + +} // namespace detail { +} // namespace intrusive { +} // namespace boost { + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_CLEAR_ON_DESTRUCTOR_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/common_slist_algorithms.hpp b/src/third_party/boost/boost/intrusive/detail/common_slist_algorithms.hpp new file mode 100644 index 00000000000..15d6b3ff29b --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/common_slist_algorithms.hpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <cstddef> + +namespace boost { +namespace intrusive { +namespace detail { + +template<class NodeTraits> +class common_slist_algorithms +{ + public: + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + typedef NodeTraits node_traits; + + static node_ptr get_previous_node(const node_ptr & prev_init_node, const node_ptr & this_node) + { + node_ptr p = prev_init_node; + for( node_ptr p_next + ; this_node != (p_next = NodeTraits::get_next(p)) + ; p = p_next){ + //Logic error: possible use of linear lists with + //operations only permitted with lists + BOOST_INTRUSIVE_INVARIANT_ASSERT(p); + } + return p; + } + + static void init_header(const node_ptr & this_node) + { NodeTraits::set_next(this_node, this_node); } + + static void init(const node_ptr & this_node) + { NodeTraits::set_next(this_node, node_ptr()); } + + static bool unique(const const_node_ptr & this_node) + { + node_ptr next = NodeTraits::get_next(this_node); + return !next || next == this_node; + } + + static bool inited(const const_node_ptr & this_node) + { return !NodeTraits::get_next(this_node); } + + static void unlink_after(const node_ptr & prev_node) + { + const_node_ptr this_node(NodeTraits::get_next(prev_node)); + NodeTraits::set_next(prev_node, NodeTraits::get_next(this_node)); + } + + static void unlink_after(const node_ptr & prev_node, const node_ptr & last_node) + { NodeTraits::set_next(prev_node, last_node); } + + static void link_after(const node_ptr & prev_node, const node_ptr & this_node) + { + NodeTraits::set_next(this_node, NodeTraits::get_next(prev_node)); + NodeTraits::set_next(prev_node, this_node); + } + + static void incorporate_after(const node_ptr & bp, const node_ptr & b, const node_ptr & be) + { + node_ptr p(NodeTraits::get_next(bp)); + NodeTraits::set_next(bp, b); + NodeTraits::set_next(be, p); + } + + static void transfer_after(const node_ptr & bp, const node_ptr & bb, const node_ptr & be) + { + if (bp != bb && bp != be && bb != be) { + node_ptr next_b = NodeTraits::get_next(bb); + node_ptr next_e = NodeTraits::get_next(be); + node_ptr next_p = NodeTraits::get_next(bp); + NodeTraits::set_next(bb, next_e); + NodeTraits::set_next(be, next_p); + NodeTraits::set_next(bp, next_b); + } + } +}; + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/config_begin.hpp b/src/third_party/boost/boost/intrusive/detail/config_begin.hpp new file mode 100644 index 00000000000..bb126fcdf06 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/config_begin.hpp @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_CONFIG_INCLUDED +#define BOOST_INTRUSIVE_CONFIG_INCLUDED +#include <boost/config.hpp> +#endif + +#ifdef BOOST_MSVC + + #pragma warning (push) + // + //'function' : resolved overload was found by argument-dependent lookup + //A function found by argument-dependent lookup (Koenig lookup) was eventually + //chosen by overload resolution. + // + //In Visual C++ .NET and earlier compilers, a different function would have + //been called. To pick the original function, use an explicitly qualified name. + // + + //warning C4275: non dll-interface class 'x' used as base for + //dll-interface class 'Y' + #pragma warning (disable : 4275) + //warning C4251: 'x' : class 'y' needs to have dll-interface to + //be used by clients of class 'z' + #pragma warning (disable : 4251) + #pragma warning (disable : 4675) + #pragma warning (disable : 4996) + #pragma warning (disable : 4503) + #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4244) // possible loss of data + #pragma warning (disable : 4521) ////Disable "multiple copy constructors specified" + #pragma warning (disable : 4522) + #pragma warning (disable : 4146) + #pragma warning (disable : 4267) //conversion from 'X' to 'Y', possible loss of data + #pragma warning (disable : 4127) //conditional expression is constant + #pragma warning (disable : 4706) //assignment within conditional expression + #pragma warning (disable : 4541) //'typeid' used on polymorphic type 'boost::exception' with /GR- + #pragma warning (disable : 4512) //'typeid' used on polymorphic type 'boost::exception' with /GR- +#endif + +//#define BOOST_INTRUSIVE_USE_ITERATOR_FACADE +//#define BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE diff --git a/src/third_party/boost/boost/intrusive/detail/config_end.hpp b/src/third_party/boost/boost/intrusive/detail/config_end.hpp new file mode 100644 index 00000000000..4277cb576f8 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/config_end.hpp @@ -0,0 +1,15 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#if defined BOOST_MSVC + #pragma warning (pop) +#endif diff --git a/src/third_party/boost/boost/intrusive/detail/ebo_functor_holder.hpp b/src/third_party/boost/boost/intrusive/detail/ebo_functor_holder.hpp new file mode 100644 index 00000000000..d4c2d1593bf --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/ebo_functor_holder.hpp @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Joaquin M Lopez Munoz 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP +#define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/mpl.hpp> + +namespace boost { +namespace intrusive { +namespace detail { + +template<typename T, bool IsEmpty = true> +class ebo_functor_holder_impl +{ + public: + ebo_functor_holder_impl() + {} + ebo_functor_holder_impl(const T& t) + : t_(t) + {} + template<class Arg1, class Arg2> + ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) + : t_(arg1, arg2) + {} + + T& get(){return t_;} + const T& get()const{return t_;} + + private: + T t_; +}; + +template<typename T> +class ebo_functor_holder_impl<T, false> + : public T +{ + public: + ebo_functor_holder_impl() + {} + ebo_functor_holder_impl(const T& t) + : T(t) + {} + template<class Arg1, class Arg2> + ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) + : T(arg1, arg2) + {} + + T& get(){return *this;} + const T& get()const{return *this;} +}; + +template<typename T> +class ebo_functor_holder + : public ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> +{ + private: + typedef ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> super; + + public: + ebo_functor_holder(){} + ebo_functor_holder(const T& t) + : super(t) + {} + + template<class Arg1, class Arg2> + ebo_functor_holder(const Arg1& arg1, const Arg2& arg2) + : super(arg1, arg2) + {} + + ebo_functor_holder& operator=(const ebo_functor_holder& x) + { + this->get()=x.get(); + return *this; + } +}; + + +} //namespace detail { +} //namespace intrusive { +} //namespace boost { + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/function_detector.hpp b/src/third_party/boost/boost/intrusive/detail/function_detector.hpp new file mode 100644 index 00000000000..e00a7efcf21 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/function_detector.hpp @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2009-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +// This code was modified from the code posted by Alexandre Courpron in his +// article "Interface Detection" in The Code Project: +// http://www.codeproject.com/KB/architecture/Detector.aspx +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2007 Alexandre Courpron +// +// Permission to use, copy, modify, redistribute and sell this software, +// provided that this copyright notice appears on all copies of the software. +/////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_FUNCTION_DETECTOR_HPP +#define BOOST_INTRUSIVE_DETAIL_FUNCTION_DETECTOR_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +namespace boost { +namespace intrusive { +namespace function_detector { + + typedef char NotFoundType; + struct StaticFunctionType { NotFoundType x [2]; }; + struct NonStaticFunctionType { NotFoundType x [3]; }; + + enum + { NotFound = 0, + StaticFunction = sizeof( StaticFunctionType ) - sizeof( NotFoundType ), + NonStaticFunction = sizeof( NonStaticFunctionType ) - sizeof( NotFoundType ) + }; + +} //namespace boost { +} //namespace intrusive { +} //namespace function_detector { + +#define BOOST_INTRUSIVE_CREATE_FUNCTION_DETECTOR(Identifier, InstantiationKey) \ + namespace boost { \ + namespace intrusive { \ + namespace function_detector { \ + template < class T, \ + class NonStaticType, \ + class NonStaticConstType, \ + class StaticType > \ + class DetectMember_##InstantiationKey_##Identifier { \ + template < NonStaticType > \ + struct TestNonStaticNonConst ; \ + \ + template < NonStaticConstType > \ + struct TestNonStaticConst ; \ + \ + template < StaticType > \ + struct TestStatic ; \ + \ + template <class U > \ + static NonStaticFunctionType Test( TestNonStaticNonConst<&U::Identifier>*, int ); \ + \ + template <class U > \ + static NonStaticFunctionType Test( TestNonStaticConst<&U::Identifier>*, int ); \ + \ + template <class U> \ + static StaticFunctionType Test( TestStatic<&U::Identifier>*, int ); \ + \ + template <class U> \ + static NotFoundType Test( ... ); \ + public : \ + static const int check = NotFound + (sizeof(Test<T>(0, 0)) - sizeof(NotFoundType));\ + };\ +}}} //namespace boost::intrusive::function_detector { + +#define BOOST_INTRUSIVE_DETECT_FUNCTION(Class, InstantiationKey, ReturnType, Identifier, Params) \ + ::boost::intrusive::function_detector::DetectMember_##InstantiationKey_##Identifier< Class,\ + ReturnType (Class::*)Params,\ + ReturnType (Class::*)Params const,\ + ReturnType (*)Params \ + >::check + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //@ifndef BOOST_INTRUSIVE_DETAIL_FUNCTION_DETECTOR_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/generic_hook.hpp b/src/third_party/boost/boost/intrusive/detail/generic_hook.hpp new file mode 100644 index 00000000000..fc35610b8d4 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/generic_hook.hpp @@ -0,0 +1,209 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_GENERIC_HOOK_HPP +#define BOOST_INTRUSIVE_GENERIC_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/static_assert.hpp> + +namespace boost { +namespace intrusive { +namespace detail { + +/// @cond + +enum +{ NoBaseHook +, ListBaseHook +, SlistBaseHook +, SetBaseHook +, UsetBaseHook +, SplaySetBaseHook +, AvlSetBaseHook +, BsSetBaseHook +, AnyBaseHook +}; + +struct no_default_definer{}; + +template <class Hook, unsigned int> +struct default_definer; + +template <class Hook> +struct default_definer<Hook, ListBaseHook> +{ typedef Hook default_list_hook; }; + +template <class Hook> +struct default_definer<Hook, SlistBaseHook> +{ typedef Hook default_slist_hook; }; + +template <class Hook> +struct default_definer<Hook, SetBaseHook> +{ typedef Hook default_set_hook; }; + +template <class Hook> +struct default_definer<Hook, UsetBaseHook> +{ typedef Hook default_uset_hook; }; + +template <class Hook> +struct default_definer<Hook, SplaySetBaseHook> +{ typedef Hook default_splay_set_hook; }; + +template <class Hook> +struct default_definer<Hook, AvlSetBaseHook> +{ typedef Hook default_avl_set_hook; }; + +template <class Hook> +struct default_definer<Hook, BsSetBaseHook> +{ typedef Hook default_bs_set_hook; }; + +template <class Hook> +struct default_definer<Hook, AnyBaseHook> +{ typedef Hook default_any_hook; }; + +template <class Hook, unsigned int BaseHookType> +struct make_default_definer +{ + typedef typename detail::if_c + < BaseHookType != 0 + , default_definer<Hook, BaseHookType> + , no_default_definer>::type type; +}; + +template + < class GetNodeAlgorithms + , class Tag + , link_mode_type LinkMode + , int HookType + > +struct make_node_holder +{ + typedef typename detail::if_c + <!detail::is_same<Tag, member_tag>::value + , detail::node_holder + < typename GetNodeAlgorithms::type::node + , Tag + , LinkMode + , HookType> + , typename GetNodeAlgorithms::type::node + >::type type; +}; + +/// @endcond + +template + < class GetNodeAlgorithms + , class Tag + , link_mode_type LinkMode + , int HookType + > +class generic_hook + /// @cond + + //If the hook is a base hook, derive generic hook from detail::node_holder + //so that a unique base class is created to convert from the node + //to the type. This mechanism will be used by base_hook_traits. + // + //If the hook is a member hook, generic hook will directly derive + //from the hook. + : public make_default_definer + < generic_hook<GetNodeAlgorithms, Tag, LinkMode, HookType> + , detail::is_same<Tag, default_tag>::value*HookType + >::type + , public make_node_holder<GetNodeAlgorithms, Tag, LinkMode, HookType>::type + /// @endcond +{ + /// @cond + typedef typename GetNodeAlgorithms::type node_algorithms; + typedef typename node_algorithms::node node; + typedef typename node_algorithms::node_ptr node_ptr; + typedef typename node_algorithms::const_node_ptr const_node_ptr; + + public: + struct boost_intrusive_tags + { + static const int hook_type = HookType; + static const link_mode_type link_mode = LinkMode; + typedef Tag tag; + typedef typename GetNodeAlgorithms::type::node_traits node_traits; + static const bool is_base_hook = !detail::is_same<Tag, member_tag>::value; + static const bool safemode_or_autounlink = + (int)link_mode == (int)auto_unlink || (int)link_mode == (int)safe_link; + }; + + node_ptr this_ptr() + { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*this)); } + + const_node_ptr this_ptr() const + { return pointer_traits<const_node_ptr>::pointer_to(static_cast<const node&>(*this)); } + + public: + /// @endcond + + generic_hook() + { + if(boost_intrusive_tags::safemode_or_autounlink){ + node_algorithms::init(this->this_ptr()); + } + } + + generic_hook(const generic_hook& ) + { + if(boost_intrusive_tags::safemode_or_autounlink){ + node_algorithms::init(this->this_ptr()); + } + } + + generic_hook& operator=(const generic_hook& ) + { return *this; } + + ~generic_hook() + { + destructor_impl + (*this, detail::link_dispatch<boost_intrusive_tags::link_mode>()); + } + + void swap_nodes(generic_hook &other) + { + node_algorithms::swap_nodes + (this->this_ptr(), other.this_ptr()); + } + + bool is_linked() const + { + //is_linked() can be only used in safe-mode or auto-unlink + BOOST_STATIC_ASSERT(( boost_intrusive_tags::safemode_or_autounlink )); + return !node_algorithms::unique(this->this_ptr()); + } + + void unlink() + { + BOOST_STATIC_ASSERT(( (int)boost_intrusive_tags::link_mode == (int)auto_unlink )); + node_algorithms::unlink(this->this_ptr()); + node_algorithms::init(this->this_ptr()); + } +}; + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_GENERIC_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/has_member_function_callable_with.hpp b/src/third_party/boost/boost/intrusive/detail/has_member_function_callable_with.hpp new file mode 100644 index 00000000000..33811e32100 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/has_member_function_callable_with.hpp @@ -0,0 +1,356 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (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/intrusive for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +// sample.h + +#if !BOOST_PP_IS_ITERATING + + #ifndef BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED + #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED + + #include <boost/intrusive/detail/config_begin.hpp> + #include <boost/intrusive/detail/workaround.hpp> + #include <boost/intrusive/detail/preprocessor.hpp> + #include <boost/static_assert.hpp> + #include <boost/move/move.hpp> + + //Mark that we don't support 0 arg calls due to compiler ICE in GCC 3.4/4.0/4.1 and + //wrong SFINAE for GCC 4.2/4.3 + #if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__*100 + __GNUC_MINOR__*10) >= 340) && ((__GNUC__*100 + __GNUC_MINOR__*10) <= 430) + #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED + #elif defined(BOOST_INTEL) && (BOOST_INTEL < 1200 ) + #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED + #endif + + namespace boost_intrusive_has_member_function_callable_with { + + struct dont_care + { + dont_care(...); + }; + + struct private_type + { + static private_type p; + private_type const &operator,(int) const; + }; + + typedef char yes_type; // sizeof(yes_type) == 1 + struct no_type{ char dummy[2]; }; // sizeof(no_type) == 2 + + template<typename T> + no_type is_private_type(T const &); + yes_type is_private_type(private_type const &); + + } //boost_intrusive_has_member_function_callable_with + + #include <boost/intrusive/detail/config_end.hpp> + + #endif //BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED + +#else //!BOOST_PP_IS_ITERATING + + #ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME not defined!" + #endif + + #ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN not defined!" + #endif + + #ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END not defined!" + #endif + + #if BOOST_PP_ITERATION_START() != 0 + #error "BOOST_PP_ITERATION_START() must be zero (0)" + #endif + + #if BOOST_PP_ITERATION() == 0 + + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN + + template <typename Type> + class BOOST_PP_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + struct BaseMixin + { + void BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(); + }; + + struct Base : public Type, public BaseMixin { Base(); }; + template <typename T, T t> class Helper{}; + + template <typename U> + static boost_intrusive_has_member_function_callable_with::no_type deduce + (U*, Helper<void (BaseMixin::*)(), &U::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME>* = 0); + static boost_intrusive_has_member_function_callable_with::yes_type deduce(...); + + public: + static const bool value = + sizeof(boost_intrusive_has_member_function_callable_with::yes_type) == sizeof(deduce((Base*)(0))); + }; + + #if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + + template<typename Fun, bool HasFunc + BOOST_PP_ENUM_TRAILING(BOOST_PP_ITERATION_FINISH(), BOOST_INTRUSIVE_PP_TEMPLATE_PARAM_VOID_DEFAULT, _)> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl); + //! + + template<typename Fun BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION_FINISH(), class P)> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl) + <Fun, false BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION_FINISH(), P)> + { + static const bool value = false; + }; + //! + + #if !defined(_MSC_VER) || (_MSC_VER != 1600) + + #if defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + + template<typename Fun> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) + <Fun, true BOOST_PP_ENUM_TRAILING(BOOST_PP_SUB(BOOST_PP_ITERATION_FINISH(), BOOST_PP_ITERATION()), BOOST_INTRUSIVE_PP_IDENTITY, void)> + { + //Mark that we don't support 0 arg calls due to compiler ICE in GCC 3.4/4.0/4.1 and + //wrong SFINAE for GCC 4.2/4.3 + static const bool value = true; + }; + + #else + + //Special case for 0 args + template< class F + , std::size_t N = + sizeof((boost::move_detail::declval<F>(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME (), 0))> + struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + boost_intrusive_has_member_function_callable_with::yes_type dummy; + BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); + }; + + //For buggy compilers like MSVC 7.1+ ((F*)0)->func() does not + //SFINAE-out the zeroarg_checker_ instantiation but sizeof yields to 0. + template<class F> + struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<F, 0> + { + boost_intrusive_has_member_function_callable_with::no_type dummy; + BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); + }; + + template<typename Fun> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) + <Fun, true BOOST_PP_ENUM_TRAILING(BOOST_PP_SUB(BOOST_PP_ITERATION_FINISH(), BOOST_PP_ITERATION()), BOOST_INTRUSIVE_PP_IDENTITY, void)> + { + template<class U> + static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U> + Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*); + + template <class U> + static boost_intrusive_has_member_function_callable_with::no_type Test(...); + + static const bool value = sizeof(Test< Fun >(0)) + == sizeof(boost_intrusive_has_member_function_callable_with::yes_type); + }; + #endif + + #else //#if !defined(_MSC_VER) || (_MSC_VER != 1600) + template<typename Fun> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) + <Fun, true BOOST_PP_ENUM_TRAILING(BOOST_PP_SUB(BOOST_PP_ITERATION_FINISH(), BOOST_PP_ITERATION()), BOOST_INTRUSIVE_PP_IDENTITY, void)> + { + template<class U> + static decltype( boost::move_detail::declval<Fun>().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME() + , boost_intrusive_has_member_function_callable_with::yes_type()) + Test(Fun*); + + template<class U> + static boost_intrusive_has_member_function_callable_with::no_type Test(...); + + static const bool value = sizeof(Test<Fun>(0)) + == sizeof(boost_intrusive_has_member_function_callable_with::yes_type); + }; + #endif //#if !defined(_MSC_VER) || (_MSC_VER != 1600) + + #else //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + + template<typename Fun, bool HasFunc, class ...Args> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl); + + template<typename Fun, class ...Args> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) + <Fun, false, Args...> + { + static const bool value = false; + }; + + //Special case for 0 args + template< class F + , std::size_t N = + sizeof((boost::move_detail::declval<F>(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME (), 0))> + struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + boost_intrusive_has_member_function_callable_with::yes_type dummy; + BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); + }; + + //For buggy compilers like MSVC 7.1+ ((F*)0)->func() does not + //SFINAE-out the zeroarg_checker_ instantiation but sizeof yields to 0. + template<class F> + struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<F, 0> + { + boost_intrusive_has_member_function_callable_with::no_type dummy; + BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); + }; + + template<typename Fun> + struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) + <Fun, true> + { + template<class U> + static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*); + + template <class U> + static boost_intrusive_has_member_function_callable_with::no_type Test(...); + + static const bool value = sizeof(Test< Fun >(0)) + == sizeof(boost_intrusive_has_member_function_callable_with::yes_type); + }; + + template<typename Fun, class ...DontCares> + struct BOOST_PP_CAT( funwrap_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME ) + : Fun + { + BOOST_PP_CAT( funwrap_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME )(); + using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME; + + boost_intrusive_has_member_function_callable_with::private_type + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + ( DontCares...) const; + }; + + template<typename Fun, class ...Args> + struct BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl) + <Fun, true , Args...> + { + template<class T> + struct make_dontcare + { + typedef boost_intrusive_has_member_function_callable_with::dont_care type; + }; + + typedef BOOST_PP_CAT( funwrap_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME ) + <Fun, typename make_dontcare<Args>::type...> FunWrap; + + static bool const value = (sizeof(boost_intrusive_has_member_function_callable_with::no_type) == + sizeof(boost_intrusive_has_member_function_callable_with::is_private_type + ( (::boost::move_detail::declval< FunWrap >(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + ( ::boost::move_detail::declval<Args>()... ), 0) ) + ) + ); + }; + + template<typename Fun, class ...Args> + struct BOOST_PP_CAT( has_member_function_callable_with_ + , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + : public BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_ + , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) + < Fun + , BOOST_PP_CAT( has_member_function_named_ + , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME )<Fun>::value + , Args... > + {}; + + #endif //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + + #else //BOOST_PP_ITERATION() == 0 + + #if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN + + template<typename Fun> + struct BOOST_PP_CAT( BOOST_PP_CAT(funwrap, BOOST_PP_ITERATION()) + , BOOST_PP_CAT(_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)) + : Fun + { + BOOST_PP_CAT( BOOST_PP_CAT(funwrap, BOOST_PP_ITERATION()) + , BOOST_PP_CAT(_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME))(); + + using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME; + boost_intrusive_has_member_function_callable_with::private_type + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + ( BOOST_PP_ENUM(BOOST_PP_ITERATION() + , BOOST_INTRUSIVE_PP_IDENTITY + , boost_intrusive_has_member_function_callable_with::dont_care)) const; + }; + + template<typename Fun BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), class P)> + struct BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_ + , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) + <Fun, true + BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), P) + BOOST_PP_ENUM_TRAILING( BOOST_PP_SUB(BOOST_PP_ITERATION_FINISH(), BOOST_PP_ITERATION()) + , BOOST_INTRUSIVE_PP_IDENTITY + , void)> + { + typedef BOOST_PP_CAT( BOOST_PP_CAT(funwrap, BOOST_PP_ITERATION()) + , BOOST_PP_CAT(_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME))<Fun> + FunWrap; + static bool const value = + (sizeof(boost_intrusive_has_member_function_callable_with::no_type) == + sizeof(boost_intrusive_has_member_function_callable_with::is_private_type + ( (boost::move_detail::declval<FunWrap>(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + ( BOOST_PP_ENUM( BOOST_PP_ITERATION(), BOOST_INTRUSIVE_PP_DECLVAL, _) ), 0 + ) + ) + ) + ); + }; + + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + #endif //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + + #endif //BOOST_PP_ITERATION() == 0 + + #if BOOST_PP_ITERATION() == BOOST_PP_ITERATION_FINISH() + + #if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN + + template<typename Fun + BOOST_PP_ENUM_TRAILING(BOOST_PP_ITERATION_FINISH(), BOOST_INTRUSIVE_PP_TEMPLATE_PARAM_VOID_DEFAULT, _)> + struct BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + : public BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl) + <Fun, BOOST_PP_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun>::value + BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION_FINISH(), P) > + {}; + + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + + #endif //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + + #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN + #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + + #endif //#if BOOST_PP_ITERATION() == BOOST_PP_ITERATION_FINISH() + +#endif //!BOOST_PP_IS_ITERATING diff --git a/src/third_party/boost/boost/intrusive/detail/hashtable_node.hpp b/src/third_party/boost/boost/intrusive/detail/hashtable_node.hpp new file mode 100644 index 00000000000..ac6ab81948c --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/hashtable_node.hpp @@ -0,0 +1,249 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_HASHTABLE_NODE_HPP +#define BOOST_INTRUSIVE_HASHTABLE_NODE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/circular_list_algorithms.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/detail/utilities.hpp> +//#include <boost/intrusive/detail/slist_node.hpp> //remove-me +#include <boost/intrusive/pointer_traits.hpp> +#include <cstddef> +#include <boost/pointer_cast.hpp> +#include <boost/move/move.hpp> + + +namespace boost { +namespace intrusive { +namespace detail { + +template<int Dummy = 0> +struct prime_list_holder +{ + static const std::size_t prime_list[]; + static const std::size_t prime_list_size; +}; + +template<int Dummy> +const std::size_t prime_list_holder<Dummy>::prime_list[] = { + 3ul, 7ul, 11ul, 17ul, 29ul, + 53ul, 97ul, 193ul, 389ul, 769ul, + 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, + 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, + 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, + 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, + 1610612741ul, 3221225473ul, 4294967291ul }; + +template<int Dummy> +const std::size_t prime_list_holder<Dummy>::prime_list_size + = sizeof(prime_list)/sizeof(std::size_t); + +template <class Slist> +struct bucket_impl : public Slist +{ + typedef Slist slist_type; + bucket_impl() + {} + + bucket_impl(const bucket_impl &) + {} + + ~bucket_impl() + { + //This bucket is still being used! + BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty()); + } + + bucket_impl &operator=(const bucket_impl&) + { + //This bucket is still in use! + BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty()); + //Slist::clear(); + return *this; + } +}; + +template<class Slist> +struct bucket_traits_impl +{ + private: + BOOST_COPYABLE_AND_MOVABLE(bucket_traits_impl) + + public: + /// @cond + + typedef typename pointer_traits + <typename Slist::pointer>::template rebind_pointer + < bucket_impl<Slist> >::type bucket_ptr; + typedef typename Slist::size_type size_type; + /// @endcond + + bucket_traits_impl(bucket_ptr buckets, size_type len) + : buckets_(buckets), buckets_len_(len) + {} + + bucket_traits_impl(const bucket_traits_impl &x) + : buckets_(x.buckets_), buckets_len_(x.buckets_len_) + {} + + + bucket_traits_impl(BOOST_RV_REF(bucket_traits_impl) x) + : buckets_(x.buckets_), buckets_len_(x.buckets_len_) + { x.buckets_ = bucket_ptr(); x.buckets_len_ = 0; } + + bucket_traits_impl& operator=(BOOST_RV_REF(bucket_traits_impl) x) + { + buckets_ = x.buckets_; buckets_len_ = x.buckets_len_; + x.buckets_ = bucket_ptr(); x.buckets_len_ = 0; return *this; + } + + bucket_traits_impl& operator=(BOOST_COPY_ASSIGN_REF(bucket_traits_impl) x) + { + buckets_ = x.buckets_; buckets_len_ = x.buckets_len_; return *this; + } + + const bucket_ptr &bucket_begin() const + { return buckets_; } + + size_type bucket_count() const + { return buckets_len_; } + + private: + bucket_ptr buckets_; + size_type buckets_len_; +}; + +template<class Container, bool IsConst> +class hashtable_iterator + : public std::iterator + < std::forward_iterator_tag + , typename Container::value_type + , typename pointer_traits<typename Container::value_type*>::difference_type + , typename detail::add_const_if_c + <typename Container::value_type, IsConst>::type * + , typename detail::add_const_if_c + <typename Container::value_type, IsConst>::type & + > +{ + typedef typename Container::real_value_traits real_value_traits; + typedef typename Container::siterator siterator; + typedef typename Container::const_siterator const_siterator; + typedef typename Container::bucket_type bucket_type; + + typedef typename pointer_traits + <typename Container::pointer>::template rebind_pointer + < const Container >::type const_cont_ptr; + typedef typename Container::size_type size_type; + + static typename Container::node_ptr downcast_bucket(typename bucket_type::node_ptr p) + { + return pointer_traits<typename Container::node_ptr>:: + pointer_to(static_cast<typename Container::node&>(*p)); + } + + public: + typedef typename Container::value_type value_type; + typedef typename detail::add_const_if_c + <typename Container::value_type, IsConst>::type *pointer; + typedef typename detail::add_const_if_c + <typename Container::value_type, IsConst>::type &reference; + + hashtable_iterator () + {} + + explicit hashtable_iterator(siterator ptr, const Container *cont) + : slist_it_ (ptr), cont_ (cont ? pointer_traits<const_cont_ptr>::pointer_to(*cont) : const_cont_ptr() ) + {} + + hashtable_iterator(const hashtable_iterator<Container, false> &other) + : slist_it_(other.slist_it()), cont_(other.get_container()) + {} + + const siterator &slist_it() const + { return slist_it_; } + + hashtable_iterator<Container, false> unconst() const + { return hashtable_iterator<Container, false>(this->slist_it(), this->get_container()); } + + public: + hashtable_iterator& operator++() + { this->increment(); return *this; } + + hashtable_iterator operator++(int) + { + hashtable_iterator result (*this); + this->increment(); + return result; + } + + friend bool operator== (const hashtable_iterator& i, const hashtable_iterator& i2) + { return i.slist_it_ == i2.slist_it_; } + + friend bool operator!= (const hashtable_iterator& i, const hashtable_iterator& i2) + { return !(i == i2); } + + reference operator*() const + { return *this->operator ->(); } + + pointer operator->() const + { + return boost::intrusive::detail::to_raw_pointer(this->get_real_value_traits()->to_value_ptr + (downcast_bucket(slist_it_.pointed_node()))); + } + + const const_cont_ptr &get_container() const + { return cont_; } + + const real_value_traits *get_real_value_traits() const + { return &this->get_container()->get_real_value_traits(); } + + private: + void increment() + { + const Container *cont = boost::intrusive::detail::to_raw_pointer(cont_); + bucket_type* buckets = boost::intrusive::detail::to_raw_pointer(cont->bucket_pointer()); + size_type buckets_len = cont->bucket_count(); + + ++slist_it_; + if(buckets[0].cend().pointed_node() <= slist_it_.pointed_node() && + slist_it_.pointed_node()<= buckets[buckets_len].cend().pointed_node() ){ + //Now get the bucket_impl from the iterator + const bucket_type &b = static_cast<const bucket_type&> + (bucket_type::slist_type::container_from_end_iterator(slist_it_)); + + //Now just calculate the index b has in the bucket array + size_type n_bucket = static_cast<size_type>(&b - &buckets[0]); + do{ + if (++n_bucket == buckets_len){ + slist_it_ = (&buckets[0] + buckets_len)->end(); + break; + } + slist_it_ = buckets[n_bucket].begin(); + } + while (slist_it_ == buckets[n_bucket].end()); + } + } + + siterator slist_it_; + const_cont_ptr cont_; +}; + +} //namespace detail { +} //namespace intrusive { +} //namespace boost { + +#endif diff --git a/src/third_party/boost/boost/intrusive/detail/is_stateful_value_traits.hpp b/src/third_party/boost/boost/intrusive/detail/is_stateful_value_traits.hpp new file mode 100644 index 00000000000..e38f4de4592 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/is_stateful_value_traits.hpp @@ -0,0 +1,77 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2009-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP +#define BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +#if defined(_MSC_VER) && (_MSC_VER <= 1310) + +#include <boost/intrusive/detail/mpl.hpp> + +namespace boost { +namespace intrusive { +namespace detail { + +template<class ValueTraits> +struct is_stateful_value_traits +{ + static const bool value = !detail::is_empty_class<ValueTraits>::value; +}; + +}}} + +#else + +#include <boost/intrusive/detail/function_detector.hpp> + +BOOST_INTRUSIVE_CREATE_FUNCTION_DETECTOR(to_node_ptr, boost_intrusive) +BOOST_INTRUSIVE_CREATE_FUNCTION_DETECTOR(to_value_ptr, boost_intrusive) + +namespace boost { +namespace intrusive { +namespace detail { + +template<class ValueTraits> +struct is_stateful_value_traits +{ + typedef typename ValueTraits::node_ptr node_ptr; + typedef typename ValueTraits::pointer pointer; + typedef typename ValueTraits::value_type value_type; + typedef typename ValueTraits::const_node_ptr const_node_ptr; + typedef typename ValueTraits::const_pointer const_pointer; + + typedef ValueTraits value_traits; + + static const bool value = + (boost::intrusive::function_detector::NonStaticFunction == + (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, node_ptr, to_node_ptr, (value_type&) ))) + || + (boost::intrusive::function_detector::NonStaticFunction == + (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, pointer, to_value_ptr, (node_ptr) ))) + || + (boost::intrusive::function_detector::NonStaticFunction == + (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, const_node_ptr, to_node_ptr, (const value_type&) ))) + || + (boost::intrusive::function_detector::NonStaticFunction == + (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, const_pointer, to_value_ptr, (const_node_ptr) ))) + ; +}; + +}}} + +#endif + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //@ifndef BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/list_node.hpp b/src/third_party/boost/boost/intrusive/detail/list_node.hpp new file mode 100644 index 00000000000..df99912dd23 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/list_node.hpp @@ -0,0 +1,190 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_LIST_NODE_HPP +#define BOOST_INTRUSIVE_LIST_NODE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace intrusive { + +// list_node_traits can be used with circular_list_algorithms and supplies +// a list_node holding the pointers needed for a double-linked list +// it is used by list_derived_node and list_member_node + +template<class VoidPointer> +struct list_node +{ + typedef typename pointer_traits + <VoidPointer>:: template rebind_pointer<list_node>::type node_ptr; + node_ptr next_; + node_ptr prev_; +}; + +template<class VoidPointer> +struct list_node_traits +{ + typedef list_node<VoidPointer> node; + typedef typename pointer_traits + <VoidPointer>:: template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>:: template rebind_pointer<const node>::type const_node_ptr; + + static const node_ptr &get_previous(const const_node_ptr & n) + { return n->prev_; } + + static void set_previous(const node_ptr & n, const node_ptr & prev) + { n->prev_ = prev; } + + static const node_ptr &get_next(const const_node_ptr & n) + { return n->next_; } + + static void set_next(const node_ptr & n, const node_ptr & next) + { n->next_ = next; } +}; + +// list_iterator provides some basic functions for a +// node oriented bidirectional iterator: +template<class Container, bool IsConst> +class list_iterator + : public std::iterator + < std::bidirectional_iterator_tag + , typename Container::value_type + , typename Container::difference_type + , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type + , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type + > +{ + protected: + typedef typename Container::real_value_traits real_value_traits; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename pointer_traits<node_ptr>:: + template rebind_pointer<void>::type void_pointer; + static const bool store_container_ptr = + detail::store_cont_ptr_on_it<Container>::value; + + public: + typedef typename Container::value_type value_type; + typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer; + typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference; + + list_iterator() + : members_ (node_ptr(), 0) + {} + + explicit list_iterator(const node_ptr & node, const Container *cont_ptr) + : members_ (node, cont_ptr) + {} + + list_iterator(list_iterator<Container, false> const& other) + : members_(other.pointed_node(), other.get_container()) + {} + + const node_ptr &pointed_node() const + { return members_.nodeptr_; } + + list_iterator &operator=(const node_ptr &node) + { members_.nodeptr_ = node; return static_cast<list_iterator&>(*this); } + + public: + list_iterator& operator++() + { + node_ptr p = node_traits::get_next(members_.nodeptr_); + members_.nodeptr_ = p; + //members_.nodeptr_ = node_traits::get_next(members_.nodeptr_); + return static_cast<list_iterator&> (*this); + } + + list_iterator operator++(int) + { + list_iterator result (*this); + members_.nodeptr_ = node_traits::get_next(members_.nodeptr_); + return result; + } + + list_iterator& operator--() + { + members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_); + return static_cast<list_iterator&> (*this); + } + + list_iterator operator--(int) + { + list_iterator result (*this); + members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_); + return result; + } + + friend bool operator== (const list_iterator& l, const list_iterator& r) + { return l.pointed_node() == r.pointed_node(); } + + friend bool operator!= (const list_iterator& l, const list_iterator& r) + { return !(l == r); } + + reference operator*() const + { return *operator->(); } + + pointer operator->() const + { return this->get_real_value_traits()->to_value_ptr(members_.nodeptr_); } + + const Container *get_container() const + { + if(store_container_ptr){ + const Container* c = static_cast<const Container*>(members_.get_ptr()); + BOOST_INTRUSIVE_INVARIANT_ASSERT(c != 0); + return c; + } + else{ + return 0; + } + } + + const real_value_traits *get_real_value_traits() const + { + if(store_container_ptr) + return &this->get_container()->get_real_value_traits(); + else + return 0; + } + + list_iterator<Container, false> unconst() const + { return list_iterator<Container, false>(this->pointed_node(), this->get_container()); } + + private: + struct members + : public detail::select_constptr + <void_pointer, store_container_ptr>::type + { + typedef typename detail::select_constptr + <void_pointer, store_container_ptr>::type Base; + + members(const node_ptr &n_ptr, const void *cont) + : Base(cont), nodeptr_(n_ptr) + {} + + node_ptr nodeptr_; + } members_; +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_LIST_NODE_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/memory_util.hpp b/src/third_party/boost/boost/intrusive/detail/memory_util.hpp new file mode 100644 index 00000000000..ad026c6d618 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/memory_util.hpp @@ -0,0 +1,279 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (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/intrusive for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP +#define BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/workaround.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/detail/preprocessor.hpp> + +namespace boost { +namespace intrusive { +namespace 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 <typename T> struct unvoid { typedef T type; }; +template <> struct unvoid<void> { struct type { }; }; +template <> struct unvoid<const void> { struct type { }; }; + +template <typename T> +struct LowPriorityConversion +{ + // Convertible from T with user-defined-conversion rank. + LowPriorityConversion(const T&) { } +}; + +// Infrastructure for providing a default type for T::TNAME if absent. +#define BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(TNAME) \ + template <typename T, typename DefaultType> \ + struct boost_intrusive_default_type_ ## TNAME \ + { \ + template <typename X> \ + static char test(int, typename X::TNAME*); \ + \ + template <typename X> \ + static int test(boost::intrusive::detail:: \ + LowPriorityConversion<int>, void*); \ + \ + struct DefaultWrap { typedef DefaultType TNAME; }; \ + \ + static const bool value = (1 == sizeof(test<T>(0, 0))); \ + \ + typedef typename \ + ::boost::intrusive::detail::if_c \ + <value, T, DefaultWrap>::type::TNAME type; \ + }; \ + \ + template <typename T, typename DefaultType> \ + struct boost_intrusive_eval_default_type_ ## TNAME \ + { \ + template <typename X> \ + static char test(int, typename X::TNAME*); \ + \ + template <typename X> \ + static int test(boost::intrusive::detail:: \ + LowPriorityConversion<int>, void*); \ + \ + struct DefaultWrap \ + { typedef typename DefaultType::type TNAME; }; \ + \ + static const bool value = (1 == sizeof(test<T>(0, 0))); \ + \ + typedef typename \ + ::boost::intrusive::detail::eval_if_c \ + < value \ + , ::boost::intrusive::detail::identity<T> \ + , ::boost::intrusive::detail::identity<DefaultWrap> \ + >::type::TNAME type; \ + }; \ +// + +#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ + typename INSTANTIATION_NS_PREFIX \ + boost_intrusive_default_type_ ## TNAME< T, TIMPL >::type \ +// + +#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ + typename INSTANTIATION_NS_PREFIX \ + boost_intrusive_eval_default_type_ ## TNAME< T, TIMPL >::type \ +// + +}}} //namespace boost::intrusive::detail + +#include <boost/intrusive/detail/has_member_function_callable_with.hpp> + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME pointer_to +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME static_cast_from +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME const_cast_from +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME dynamic_cast_from +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>)) +#include BOOST_PP_ITERATE() + +namespace boost { +namespace intrusive { +namespace detail { + +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(element_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) + +////////////////////// +//struct first_param +////////////////////// + +template <typename T> struct first_param +{ typedef void type; }; + +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + + template <template <typename, typename...> class TemplateClass, typename T, typename... Args> + struct first_param< TemplateClass<T, Args...> > + { + typedef T type; + }; + +#else //C++03 compilers + + #define BOOST_PP_LOCAL_MACRO(n) \ + template < template <typename \ + BOOST_PP_ENUM_TRAILING(n, BOOST_INTRUSIVE_PP_IDENTITY, typename) > \ + class TemplateClass \ + , typename T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> \ + struct first_param \ + < TemplateClass<T BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> > \ + { \ + typedef T type; \ + }; \ + // + #define BOOST_PP_LOCAL_LIMITS (0, BOOST_INTRUSIVE_MAX_CONSTRUCTOR_PARAMETERS) + #include BOOST_PP_LOCAL_ITERATE() + +#endif //!defined(BOOST_NO_VARIADIC_TEMPLATES) + +/////////////////////////// +//struct type_rebind_mode +/////////////////////////// +template <typename Ptr, typename T> +struct type_has_rebind +{ + template <typename X> + static char test(int, typename X::template rebind<T>*); + + template <typename X> + static int test(boost::intrusive::detail::LowPriorityConversion<int>, void*); + + static const bool value = (1 == sizeof(test<Ptr>(0, 0))); +}; + +template <typename Ptr, typename T> +struct type_has_rebind_other +{ + template <typename X> + static char test(int, typename X::template rebind<T>::other*); + + template <typename X> + static int test(boost::intrusive::detail::LowPriorityConversion<int>, void*); + + static const bool value = (1 == sizeof(test<Ptr>(0, 0))); +}; + +template <typename Ptr, typename T> +struct type_rebind_mode +{ + template <typename X> + static char test(int, typename X::template rebind<T>::other*); + + template <typename X> + static int test(boost::intrusive::detail::LowPriorityConversion<int>, void*); + + static const unsigned int rebind = (unsigned int)type_has_rebind<Ptr, T>::value; + static const unsigned int rebind_other = (unsigned int)type_has_rebind_other<Ptr, T>::value; + static const unsigned int mode = rebind + rebind*rebind_other; +}; + +//////////////////////// +//struct type_rebinder +//////////////////////// +template <typename Ptr, typename U, unsigned int RebindMode = type_rebind_mode<Ptr, U>::mode> +struct type_rebinder; + +// Implementation of pointer_traits<Ptr>::rebind if Ptr has +// its own rebind::other type (C++03) +template <typename Ptr, typename U> +struct type_rebinder< Ptr, U, 2u > +{ + typedef typename Ptr::template rebind<U>::other type; +}; + +// Implementation of pointer_traits<Ptr>::rebind if Ptr has +// its own rebind template. +template <typename Ptr, typename U> +struct type_rebinder< Ptr, U, 1u > +{ + typedef typename Ptr::template rebind<U> type; +}; + +// Specialization of pointer_traits<Ptr>::rebind if Ptr does not +// have its own rebind template but has a the form Ptr<class T, +// OtherArgs>, where OtherArgs comprises zero or more type parameters. +// Many pointers fit this form, hence many pointers will get a +// reasonable default for rebind. +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + +template <template <class, class...> class Ptr, typename T, class... Tn, class U> +struct type_rebinder<Ptr<T, Tn...>, U, 0u > +{ + typedef Ptr<U, Tn...> type; +}; + +#else //C++03 compilers + +#define BOOST_PP_LOCAL_MACRO(n) \ +template < template <typename \ + BOOST_PP_ENUM_TRAILING(n, BOOST_INTRUSIVE_PP_IDENTITY, typename) > \ + class Ptr \ + , typename T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ + , class U> \ +struct type_rebinder \ + < Ptr<T BOOST_PP_ENUM_TRAILING_PARAMS(n, P)>, U, 0u > \ +{ \ + typedef Ptr<U BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> type; \ +}; \ +// +#define BOOST_PP_LOCAL_LIMITS (0, BOOST_INTRUSIVE_MAX_CONSTRUCTOR_PARAMETERS) +#include BOOST_PP_LOCAL_ITERATE() + +#endif //!defined(BOOST_NO_VARIADIC_TEMPLATES) + +} //namespace detail { +} //namespace intrusive { +} //namespace boost { + +#include <boost/intrusive/detail/config_end.hpp> + +#endif // ! defined(BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP) diff --git a/src/third_party/boost/boost/intrusive/detail/mpl.hpp b/src/third_party/boost/boost/intrusive/detail/mpl.hpp new file mode 100644 index 00000000000..075381cae28 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/mpl.hpp @@ -0,0 +1,355 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_MPL_HPP +#define BOOST_INTRUSIVE_DETAIL_MPL_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <cstddef> + +namespace boost { +namespace intrusive { +namespace detail { + +typedef char one; +struct two {one _[2];}; + +template< bool C_ > +struct bool_ +{ + static const bool value = C_; +}; + +typedef bool_<true> true_; +typedef bool_<false> false_; + +typedef true_ true_type; +typedef false_ false_type; + +typedef char yes_type; +struct no_type +{ + char padding[8]; +}; + +template <bool B, class T = void> +struct enable_if_c { + typedef T type; +}; + +template <class T> +struct enable_if_c<false, T> {}; + +template <class Cond, class T = void> +struct enable_if : public enable_if_c<Cond::value, T>{}; + +template<class F, class Param> +struct apply +{ + typedef typename F::template apply<Param>::type type; +}; + +template <class T, class U> +class is_convertible +{ + typedef char true_t; + class false_t { char dummy[2]; }; + static true_t dispatch(U); + static false_t dispatch(...); + static const T &trigger(); + public: + static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); +}; + +template< + bool C + , typename T1 + , typename T2 + > +struct if_c +{ + typedef T1 type; +}; + +template< + typename T1 + , typename T2 + > +struct if_c<false,T1,T2> +{ + typedef T2 type; +}; + +template< + typename C + , typename T1 + , typename T2 + > +struct if_ +{ + typedef typename if_c<0 != C::value, T1, T2>::type type; +}; + +template< + bool C + , typename F1 + , typename F2 + > +struct eval_if_c + : if_c<C,F1,F2>::type +{}; + +template< + typename C + , typename T1 + , typename T2 + > +struct eval_if + : if_<C,T1,T2>::type +{}; + +// identity is an extension: it is not part of the standard. +template <class T> +struct identity +{ + typedef T type; +}; + +#if defined(BOOST_MSVC) || defined(__BORLANDC_) +#define BOOST_INTRUSIVE_TT_DECL __cdecl +#else +#define BOOST_INTRUSIVE_TT_DECL +#endif + +#if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) +#define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS +#endif + +template <typename T> +struct is_unary_or_binary_function_impl +{ static const bool value = false; }; + +// see boost ticket #4094 +// avoid duplicate definitions of is_unary_or_binary_function_impl +#ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS + +template <typename R> +struct is_unary_or_binary_function_impl<R (*)()> +{ static const bool value = true; }; + +template <typename R> +struct is_unary_or_binary_function_impl<R (*)(...)> +{ static const bool value = true; }; + +#else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS + +template <typename R> +struct is_unary_or_binary_function_impl<R (__stdcall*)()> +{ static const bool value = true; }; + +template <typename R> +struct is_unary_or_binary_function_impl<R (__fastcall*)()> +{ static const bool value = true; }; + +template <typename R> +struct is_unary_or_binary_function_impl<R (__cdecl*)()> +{ static const bool value = true; }; + +template <typename R> +struct is_unary_or_binary_function_impl<R (__cdecl*)(...)> +{ static const bool value = true; }; + +#endif + +// see boost ticket #4094 +// avoid duplicate definitions of is_unary_or_binary_function_impl +#ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS + +template <typename R, class T0> +struct is_unary_or_binary_function_impl<R (*)(T0)> +{ static const bool value = true; }; + +template <typename R, class T0> +struct is_unary_or_binary_function_impl<R (*)(T0...)> +{ static const bool value = true; }; + +#else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS + +template <typename R, class T0> +struct is_unary_or_binary_function_impl<R (__stdcall*)(T0)> +{ static const bool value = true; }; + +template <typename R, class T0> +struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)> +{ static const bool value = true; }; + +template <typename R, class T0> +struct is_unary_or_binary_function_impl<R (__cdecl*)(T0)> +{ static const bool value = true; }; + +template <typename R, class T0> +struct is_unary_or_binary_function_impl<R (__cdecl*)(T0...)> +{ static const bool value = true; }; + +#endif + +// see boost ticket #4094 +// avoid duplicate definitions of is_unary_or_binary_function_impl +#ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS + +template <typename R, class T0, class T1> +struct is_unary_or_binary_function_impl<R (*)(T0, T1)> +{ static const bool value = true; }; + +template <typename R, class T0, class T1> +struct is_unary_or_binary_function_impl<R (*)(T0, T1...)> +{ static const bool value = true; }; + +#else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS + +template <typename R, class T0, class T1> +struct is_unary_or_binary_function_impl<R (__stdcall*)(T0, T1)> +{ static const bool value = true; }; + +template <typename R, class T0, class T1> +struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)> +{ static const bool value = true; }; + +template <typename R, class T0, class T1> +struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1)> +{ static const bool value = true; }; + +template <typename R, class T0, class T1> +struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1...)> +{ static const bool value = true; }; +#endif + +template <typename T> +struct is_unary_or_binary_function_impl<T&> +{ static const bool value = false; }; + +template<typename T> +struct is_unary_or_binary_function +{ static const bool value = is_unary_or_binary_function_impl<T>::value; }; + +//boost::alignment_of yields to 10K lines of preprocessed code, so we +//need an alternative +template <typename T> struct alignment_of; + +template <typename T> +struct alignment_of_hack +{ + char c; + T t; + alignment_of_hack(); +}; + +template <unsigned A, unsigned S> +struct alignment_logic +{ + static const std::size_t value = A < S ? A : S; +}; + +template< typename T > +struct alignment_of +{ + static const std::size_t value = alignment_logic + < sizeof(alignment_of_hack<T>) - sizeof(T) + , sizeof(T) + >::value; +}; + +template <typename T, typename U> +struct is_same +{ + typedef char yes_type; + struct no_type + { + char padding[8]; + }; + + template <typename V> + static yes_type is_same_tester(V*, V*); + static no_type is_same_tester(...); + + static T *t; + static U *u; + + static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u)); +}; + +template<typename T> +struct add_const +{ typedef const T type; }; + +template<typename T> +struct remove_const +{ typedef T type; }; + +template<typename T> +struct remove_const<const T> +{ typedef T type; }; + +template<class T> +struct remove_reference +{ + typedef T type; +}; + +template<class T> +struct remove_reference<T&> +{ + typedef T type; +}; + +template<class Class> +class is_empty_class +{ + template <typename T> + struct empty_helper_t1 : public T + { + empty_helper_t1(); + int i[256]; + }; + + struct empty_helper_t2 + { int i[256]; }; + + public: + static const bool value = sizeof(empty_helper_t1<Class>) == sizeof(empty_helper_t2); +}; + +template<std::size_t S> +struct ls_zeros +{ + static const std::size_t value = (S & std::size_t(1)) ? 0 : (1 + ls_zeros<(S>>1u)>::value); +}; + +template<> +struct ls_zeros<0> +{ + static const std::size_t value = 0; +}; + +template<> +struct ls_zeros<1> +{ + static const std::size_t value = 0; +}; + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/parent_from_member.hpp b/src/third_party/boost/boost/intrusive/detail/parent_from_member.hpp new file mode 100644 index 00000000000..c06d932a70c --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/parent_from_member.hpp @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP +#define BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <cstddef> + +#if defined(BOOST_MSVC) || ((defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && defined(BOOST_INTEL)) + +#define BOOST_INTRUSIVE_MSVC_COMPLIANT_PTR_TO_MEMBER +#include <boost/cstdint.hpp> +#endif + +namespace boost { +namespace intrusive { +namespace detail { + +template<class Parent, class Member> +inline std::ptrdiff_t offset_from_pointer_to_member(const Member Parent::* ptr_to_member) +{ + //The implementation of a pointer to member is compiler dependent. + #if defined(BOOST_INTRUSIVE_MSVC_COMPLIANT_PTR_TO_MEMBER) + //msvc compliant compilers use their the first 32 bits as offset (even in 64 bit mode) + return *(const boost::int32_t*)(void*)&ptr_to_member; + //This works with gcc, msvc, ac++, ibmcpp + #elif defined(__GNUC__) || defined(__HP_aCC) || defined(BOOST_INTEL) || \ + defined(__IBMCPP__) || defined(__DECCXX) + const Parent * const parent = 0; + const char *const member = reinterpret_cast<const char*>(&(parent->*ptr_to_member)); + return std::ptrdiff_t(member - reinterpret_cast<const char*>(parent)); + #else + //This is the traditional C-front approach: __MWERKS__, __DMC__, __SUNPRO_CC + return (*(const std::ptrdiff_t*)(void*)&ptr_to_member) - 1; + #endif +} + +template<class Parent, class Member> +inline Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member) +{ + return (Parent*)((char*)member - offset_from_pointer_to_member(ptr_to_member)); +} + +template<class Parent, class Member> +inline const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member) +{ + return (const Parent*)((const char*)member - offset_from_pointer_to_member(ptr_to_member)); +} + +} //namespace detail { +} //namespace intrusive { +} //namespace boost { + +#ifdef BOOST_INTRUSIVE_MSVC_COMPLIANT_PTR_TO_MEMBER +#undef BOOST_INTRUSIVE_MSVC_COMPLIANT_PTR_TO_MEMBER +#endif + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/preprocessor.hpp b/src/third_party/boost/boost/intrusive/detail/preprocessor.hpp new file mode 100644 index 00000000000..de662809e3d --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/preprocessor.hpp @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-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/intrusive for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_PREPROCESSOR_HPP +#define BOOST_INTRUSIVE_DETAIL_PREPROCESSOR_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/workaround.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> +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/repetition/enum.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing.hpp> +#include <boost/preprocessor/repetition/enum_shifted_params.hpp> +#include <boost/preprocessor/repetition/enum_shifted.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/logical/not.hpp> +#include <boost/preprocessor/arithmetic/sub.hpp> +#include <boost/preprocessor/arithmetic/add.hpp> +#include <boost/preprocessor/iteration/iterate.hpp> + +#define BOOST_INTRUSIVE_MAX_CONSTRUCTOR_PARAMETERS 10 + +#define BOOST_INTRUSIVE_PP_IDENTITY(z, n, data) data + +#define BOOST_INTRUSIVE_PP_DECLVAL(z, n, data) \ +boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \ +//! + +#define BOOST_INTRUSIVE_PP_TEMPLATE_PARAM_VOID_DEFAULT(z, n, data) \ + BOOST_PP_CAT(class P, n) = void \ +//! + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_PREPROCESSOR_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/rbtree_node.hpp b/src/third_party/boost/boost/intrusive/detail/rbtree_node.hpp new file mode 100644 index 00000000000..dbe0130024a --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/rbtree_node.hpp @@ -0,0 +1,177 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_RBTREE_NODE_HPP +#define BOOST_INTRUSIVE_RBTREE_NODE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/rbtree_algorithms.hpp> +#include <boost/intrusive/pointer_plus_bits.hpp> +#include <boost/intrusive/detail/mpl.hpp> + +namespace boost { +namespace intrusive { + +///////////////////////////////////////////////////////////////////////////// +// // +// Generic node_traits for any pointer type // +// // +///////////////////////////////////////////////////////////////////////////// + +//This is the compact representation: 3 pointers +template<class VoidPointer> +struct compact_rbtree_node +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <compact_rbtree_node<VoidPointer> >::type node_ptr; + enum color { red_t, black_t }; + node_ptr parent_, left_, right_; +}; + +//This is the normal representation: 3 pointers + enum +template<class VoidPointer> +struct rbtree_node +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <rbtree_node<VoidPointer> >::type node_ptr; + + enum color { red_t, black_t }; + node_ptr parent_, left_, right_; + color color_; +}; + +//This is the default node traits implementation +//using a node with 3 generic pointers plus an enum +template<class VoidPointer> +struct default_rbtree_node_traits_impl +{ + typedef rbtree_node<VoidPointer> node; + + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + + typedef typename node::color color; + + static const node_ptr & get_parent(const const_node_ptr & n) + { return n->parent_; } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { n->parent_ = p; } + + static const node_ptr & get_left(const const_node_ptr & n) + { return n->left_; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->left_ = l; } + + static const node_ptr & get_right(const const_node_ptr & n) + { return n->right_; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->right_ = r; } + + static color get_color(const const_node_ptr & n) + { return n->color_; } + + static void set_color(const node_ptr & n, color c) + { n->color_ = c; } + + static color black() + { return node::black_t; } + + static color red() + { return node::red_t; } +}; + +//This is the compact node traits implementation +//using a node with 3 generic pointers +template<class VoidPointer> +struct compact_rbtree_node_traits_impl +{ + typedef compact_rbtree_node<VoidPointer> node; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + + typedef pointer_plus_bits<node_ptr, 1> ptr_bit; + + typedef typename node::color color; + + static node_ptr get_parent(const const_node_ptr & n) + { return ptr_bit::get_pointer(n->parent_); } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { ptr_bit::set_pointer(n->parent_, p); } + + static const node_ptr & get_left(const const_node_ptr & n) + { return n->left_; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->left_ = l; } + + static const node_ptr & get_right(const const_node_ptr & n) + { return n->right_; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->right_ = r; } + + static color get_color(const const_node_ptr & n) + { return (color)ptr_bit::get_bits(n->parent_); } + + static void set_color(const node_ptr & n, color c) + { ptr_bit::set_bits(n->parent_, c != 0); } + + static color black() + { return node::black_t; } + + static color red() + { return node::red_t; } +}; + +//Dispatches the implementation based on the boolean +template<class VoidPointer, bool Compact> +struct rbtree_node_traits_dispatch + : public default_rbtree_node_traits_impl<VoidPointer> +{}; + +template<class VoidPointer> +struct rbtree_node_traits_dispatch<VoidPointer, true> + : public compact_rbtree_node_traits_impl<VoidPointer> +{}; + +//Inherit from the detail::link_dispatch depending on the embedding capabilities +template<class VoidPointer, bool OptimizeSize = false> +struct rbtree_node_traits + : public rbtree_node_traits_dispatch + < VoidPointer + , OptimizeSize && + (max_pointer_plus_bits + < VoidPointer + , detail::alignment_of<compact_rbtree_node<VoidPointer> >::value + >::value >= 1) + > +{}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_RBTREE_NODE_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/slist_node.hpp b/src/third_party/boost/boost/intrusive/detail/slist_node.hpp new file mode 100644 index 00000000000..5b96c097425 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/slist_node.hpp @@ -0,0 +1,163 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_SLIST_NODE_HPP +#define BOOST_INTRUSIVE_SLIST_NODE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace intrusive { + +template<class VoidPointer> +struct slist_node +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<slist_node>::type node_ptr; + node_ptr next_; +}; + +// slist_node_traits can be used with circular_slist_algorithms and supplies +// a slist_node holding the pointers needed for a singly-linked list +// it is used by slist_base_hook and slist_member_hook +template<class VoidPointer> +struct slist_node_traits +{ + typedef slist_node<VoidPointer> node; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr; + + static const node_ptr &get_next(const const_node_ptr & n) + { return n->next_; } + + static void set_next(const node_ptr & n, const node_ptr & next) + { n->next_ = next; } +}; + +// slist_iterator provides some basic functions for a +// node oriented bidirectional iterator: +template<class Container, bool IsConst> +class slist_iterator + : public std::iterator + < std::forward_iterator_tag + , typename Container::value_type + , typename Container::difference_type + , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type + , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type + > +{ + protected: + typedef typename Container::real_value_traits real_value_traits; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename pointer_traits + <node_ptr>::template rebind_pointer <void>::type void_pointer; + static const bool store_container_ptr = + detail::store_cont_ptr_on_it<Container>::value; + + public: + typedef typename Container::value_type value_type; + typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer; + typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference; + + slist_iterator() + : members_ (node_ptr(), 0) + {} + + explicit slist_iterator(const node_ptr & node, const Container *cont_ptr) + : members_ (node, cont_ptr) + {} + + slist_iterator(slist_iterator<Container, false> const& other) + : members_(other.pointed_node(), other.get_container()) + {} + + const node_ptr &pointed_node() const + { return members_.nodeptr_; } + + slist_iterator &operator=(const node_ptr &node) + { members_.nodeptr_ = node; return static_cast<slist_iterator&>(*this); } + + public: + slist_iterator& operator++() + { + members_.nodeptr_ = node_traits::get_next(members_.nodeptr_); + return static_cast<slist_iterator&> (*this); + } + + slist_iterator operator++(int) + { + slist_iterator result (*this); + members_.nodeptr_ = node_traits::get_next(members_.nodeptr_); + return result; + } + + friend bool operator== (const slist_iterator& l, const slist_iterator& r) + { return l.pointed_node() == r.pointed_node(); } + + friend bool operator!= (const slist_iterator& l, const slist_iterator& r) + { return !(l == r); } + + reference operator*() const + { return *operator->(); } + + pointer operator->() const + { return this->get_real_value_traits()->to_value_ptr(members_.nodeptr_); } + + const Container *get_container() const + { + if(store_container_ptr) + return static_cast<const Container*>(members_.get_ptr()); + else + return 0; + } + + slist_iterator<Container, false> unconst() const + { return slist_iterator<Container, false>(this->pointed_node(), this->get_container()); } + + const real_value_traits *get_real_value_traits() const + { + if(store_container_ptr) + return &this->get_container()->get_real_value_traits(); + else + return 0; + } + + private: + struct members + : public detail::select_constptr + <void_pointer, store_container_ptr>::type + { + typedef typename detail::select_constptr + <void_pointer, store_container_ptr>::type Base; + + members(const node_ptr &n_ptr, const void *cont) + : Base(cont), nodeptr_(n_ptr) + {} + + node_ptr nodeptr_; + } members_; +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SLIST_NODE_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/transform_iterator.hpp b/src/third_party/boost/boost/intrusive/detail/transform_iterator.hpp new file mode 100644 index 00000000000..15ef3ab2c97 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/transform_iterator.hpp @@ -0,0 +1,173 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_TRANSFORM_ITERATOR_HPP +#define BOOST_INTRUSIVE_DETAIL_TRANSFORM_ITERATOR_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/detail/mpl.hpp> + +namespace boost { +namespace intrusive { +namespace detail { + +template <class PseudoReference> +struct operator_arrow_proxy +{ + operator_arrow_proxy(const PseudoReference &px) + : m_value(px) + {} + + PseudoReference* operator->() const { return &m_value; } + // This function is needed for MWCW and BCC, which won't call operator-> + // again automatically per 13.3.1.2 para 8 +// operator T*() const { return &m_value; } + mutable PseudoReference m_value; +}; + +template <class T> +struct operator_arrow_proxy<T&> +{ + operator_arrow_proxy(T &px) + : m_value(px) + {} + + T* operator->() const { return &m_value; } + // This function is needed for MWCW and BCC, which won't call operator-> + // again automatically per 13.3.1.2 para 8 +// operator T*() const { return &m_value; } + T &m_value; +}; + +template <class Iterator, class UnaryFunction> +class transform_iterator + : public std::iterator + < typename Iterator::iterator_category + , typename detail::remove_reference<typename UnaryFunction::result_type>::type + , typename Iterator::difference_type + , operator_arrow_proxy<typename UnaryFunction::result_type> + , typename UnaryFunction::result_type> +{ + public: + explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction()) + : members_(it, f) + {} + + explicit transform_iterator() + : members_() + {} + + Iterator get_it() const + { return members_.m_it; } + + //Constructors + transform_iterator& operator++() + { increment(); return *this; } + + transform_iterator operator++(int) + { + transform_iterator result (*this); + increment(); + return result; + } + + friend bool operator== (const transform_iterator& i, const transform_iterator& i2) + { return i.equal(i2); } + + friend bool operator!= (const transform_iterator& i, const transform_iterator& i2) + { return !(i == i2); } + +/* + friend bool operator> (const transform_iterator& i, const transform_iterator& i2) + { return i2 < i; } + + friend bool operator<= (const transform_iterator& i, const transform_iterator& i2) + { return !(i > i2); } + + friend bool operator>= (const transform_iterator& i, const transform_iterator& i2) + { return !(i < i2); } +*/ + friend typename Iterator::difference_type operator- (const transform_iterator& i, const transform_iterator& i2) + { return i2.distance_to(i); } + + //Arithmetic + transform_iterator& operator+=(typename Iterator::difference_type off) + { this->advance(off); return *this; } + + transform_iterator operator+(typename Iterator::difference_type off) const + { + transform_iterator other(*this); + other.advance(off); + return other; + } + + friend transform_iterator operator+(typename Iterator::difference_type off, const transform_iterator& right) + { return right + off; } + + transform_iterator& operator-=(typename Iterator::difference_type off) + { this->advance(-off); return *this; } + + transform_iterator operator-(typename Iterator::difference_type off) const + { return *this + (-off); } + + typename UnaryFunction::result_type operator*() const + { return dereference(); } + + operator_arrow_proxy<typename UnaryFunction::result_type> + operator->() const + { return operator_arrow_proxy<typename UnaryFunction::result_type>(dereference()); } + + private: + struct members + : UnaryFunction + { + members(const Iterator &it, const UnaryFunction &f) + : UnaryFunction(f), m_it(it) + {} + + members() + {} + + Iterator m_it; + } members_; + + + void increment() + { ++members_.m_it; } + + void decrement() + { --members_.m_it; } + + bool equal(const transform_iterator &other) const + { return members_.m_it == other.members_.m_it; } + + bool less(const transform_iterator &other) const + { return other.members_.m_it < members_.m_it; } + + typename UnaryFunction::result_type dereference() const + { return members_(*members_.m_it); } + + void advance(typename Iterator::difference_type n) + { std::advance(members_.m_it, n); } + + typename Iterator::difference_type distance_to(const transform_iterator &other)const + { return std::distance(other.members_.m_it, members_.m_it); } +}; + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_DETAIL_TRANSFORM_ITERATOR_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/tree_algorithms.hpp b/src/third_party/boost/boost/intrusive/detail/tree_algorithms.hpp new file mode 100644 index 00000000000..8d31d9d710e --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/tree_algorithms.hpp @@ -0,0 +1,1697 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007. +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_TREE_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_TREE_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <cstddef> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace intrusive { +namespace detail { + +//! This is an implementation of a binary search tree. +//! A node in the search tree has references to its children and its parent. This +//! is to allow traversal of the whole tree from a given node making the +//! implementation of iterator a pointer to a node. +//! At the top of the tree a node is used specially. This node's parent pointer +//! is pointing to the root of the tree. Its left pointer points to the +//! leftmost node in the tree and the right pointer to the rightmost one. +//! This node is used to represent the end-iterator. +//! +//! +---------+ +//! header------------------------------>| | +//! | | +//! +----------(left)--------| |--------(right)---------+ +//! | +---------+ | +//! | | | +//! | | (parent) | +//! | | | +//! | | | +//! | +---------+ | +//! root of tree ..|......................> | | | +//! | | D | | +//! | | | | +//! | +-------+---------+-------+ | +//! | | | | +//! | | | | +//! | | | | +//! | | | | +//! | | | | +//! | +---------+ +---------+ | +//! | | | | | | +//! | | B | | F | | +//! | | | | | | +//! | +--+---------+--+ +--+---------+--+ | +//! | | | | | | +//! | | | | | | +//! | | | | | | +//! | +---+-----+ +-----+---+ +---+-----+ +-----+---+ | +//! +-->| | | | | | | |<--+ +//! | A | | C | | E | | G | +//! | | | | | | | | +//! +---------+ +---------+ +---------+ +---------+ +//! + +//! tree_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_parent(const_node_ptr n);</tt> +//! +//! <tt>static void set_parent(node_ptr n, node_ptr parent);</tt> +//! +//! <tt>static node_ptr get_left(const_node_ptr n);</tt> +//! +//! <tt>static void set_left(node_ptr n, node_ptr left);</tt> +//! +//! <tt>static node_ptr get_right(const_node_ptr n);</tt> +//! +//! <tt>static void set_right(node_ptr n, node_ptr right);</tt> +template<class NodeTraits> +class tree_algorithms +{ + public: + typedef typename NodeTraits::node node; + typedef NodeTraits node_traits; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + + //! This type is the information that will be filled by insert_unique_check + struct insert_commit_data + { + insert_commit_data() + : link_left(false) + , node() + {} + bool link_left; + node_ptr node; + }; + + struct nop_erase_fixup + { + void operator()(const node_ptr&, const node_ptr&){} + }; + + /// @cond + private: + template<class Disposer> + struct dispose_subtree_disposer + { + dispose_subtree_disposer(Disposer &disp, const node_ptr & subtree) + : disposer_(&disp), subtree_(subtree) + {} + + void release() + { disposer_ = 0; } + + ~dispose_subtree_disposer() + { + if(disposer_){ + dispose_subtree(subtree_, *disposer_); + } + } + Disposer *disposer_; + node_ptr subtree_; + }; + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + /// @endcond + + public: + static node_ptr begin_node(const const_node_ptr & header) + { return node_traits::get_left(header); } + + static node_ptr end_node(const const_node_ptr & header) + { return uncast(header); } + + //! <b>Requires</b>: 'node' is a node of the tree or an node initialized + //! by init(...) or init_node. + //! + //! <b>Effects</b>: Returns true if the node is initialized by init() or init_node(). + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + static bool unique(const const_node_ptr & node) + { return !NodeTraits::get_parent(node); } + + static node_ptr get_header(const const_node_ptr & node) + { + node_ptr h = uncast(node); + if(NodeTraits::get_parent(node)){ + h = NodeTraits::get_parent(node); + while(!is_header(h)) + h = NodeTraits::get_parent(h); + } + return h; + } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & node2) + { + if(node1 == node2) + return; + + node_ptr header1(get_header(node1)), header2(get_header(node2)); + swap_nodes(node1, header1, node2, header2); + } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees with header header1 and header2. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) + { + if(node1 == node2) + return; + + //node1 and node2 must not be header nodes + //BOOST_INTRUSIVE_INVARIANT_ASSERT((header1 != node1 && header2 != node2)); + if(header1 != header2){ + //Update header1 if necessary + if(node1 == NodeTraits::get_left(header1)){ + NodeTraits::set_left(header1, node2); + } + + if(node1 == NodeTraits::get_right(header1)){ + NodeTraits::set_right(header1, node2); + } + + if(node1 == NodeTraits::get_parent(header1)){ + NodeTraits::set_parent(header1, node2); + } + + //Update header2 if necessary + if(node2 == NodeTraits::get_left(header2)){ + NodeTraits::set_left(header2, node1); + } + + if(node2 == NodeTraits::get_right(header2)){ + NodeTraits::set_right(header2, node1); + } + + if(node2 == NodeTraits::get_parent(header2)){ + NodeTraits::set_parent(header2, node1); + } + } + else{ + //If both nodes are from the same tree + //Update header if necessary + if(node1 == NodeTraits::get_left(header1)){ + NodeTraits::set_left(header1, node2); + } + else if(node2 == NodeTraits::get_left(header2)){ + NodeTraits::set_left(header2, node1); + } + + if(node1 == NodeTraits::get_right(header1)){ + NodeTraits::set_right(header1, node2); + } + else if(node2 == NodeTraits::get_right(header2)){ + NodeTraits::set_right(header2, node1); + } + + if(node1 == NodeTraits::get_parent(header1)){ + NodeTraits::set_parent(header1, node2); + } + else if(node2 == NodeTraits::get_parent(header2)){ + NodeTraits::set_parent(header2, node1); + } + + //Adjust data in nodes to be swapped + //so that final link swap works as expected + if(node1 == NodeTraits::get_parent(node2)){ + NodeTraits::set_parent(node2, node2); + + if(node2 == NodeTraits::get_right(node1)){ + NodeTraits::set_right(node1, node1); + } + else{ + NodeTraits::set_left(node1, node1); + } + } + else if(node2 == NodeTraits::get_parent(node1)){ + NodeTraits::set_parent(node1, node1); + + if(node1 == NodeTraits::get_right(node2)){ + NodeTraits::set_right(node2, node2); + } + else{ + NodeTraits::set_left(node2, node2); + } + } + } + + //Now swap all the links + node_ptr temp; + //swap left link + temp = NodeTraits::get_left(node1); + NodeTraits::set_left(node1, NodeTraits::get_left(node2)); + NodeTraits::set_left(node2, temp); + //swap right link + temp = NodeTraits::get_right(node1); + NodeTraits::set_right(node1, NodeTraits::get_right(node2)); + NodeTraits::set_right(node2, temp); + //swap parent link + temp = NodeTraits::get_parent(node1); + NodeTraits::set_parent(node1, NodeTraits::get_parent(node2)); + NodeTraits::set_parent(node2, temp); + + //Now adjust adjacent nodes for newly inserted node 1 + if((temp = NodeTraits::get_left(node1))){ + NodeTraits::set_parent(temp, node1); + } + if((temp = NodeTraits::get_right(node1))){ + NodeTraits::set_parent(temp, node1); + } + if((temp = NodeTraits::get_parent(node1)) && + //The header has been already updated so avoid it + temp != header2){ + if(NodeTraits::get_left(temp) == node2){ + NodeTraits::set_left(temp, node1); + } + if(NodeTraits::get_right(temp) == node2){ + NodeTraits::set_right(temp, node1); + } + } + //Now adjust adjacent nodes for newly inserted node 2 + if((temp = NodeTraits::get_left(node2))){ + NodeTraits::set_parent(temp, node2); + } + if((temp = NodeTraits::get_right(node2))){ + NodeTraits::set_parent(temp, node2); + } + if((temp = NodeTraits::get_parent(node2)) && + //The header has been already updated so avoid it + temp != header1){ + if(NodeTraits::get_left(temp) == node1){ + NodeTraits::set_left(temp, node2); + } + if(NodeTraits::get_right(temp) == node1){ + NodeTraits::set_right(temp, node2); + } + } + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing and comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) + { + if(node_to_be_replaced == new_node) + return; + replace_node(node_to_be_replaced, get_header(node_to_be_replaced), new_node); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! with header "header" and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) + { + if(node_to_be_replaced == new_node) + return; + + //Update header if necessary + if(node_to_be_replaced == NodeTraits::get_left(header)){ + NodeTraits::set_left(header, new_node); + } + + if(node_to_be_replaced == NodeTraits::get_right(header)){ + NodeTraits::set_right(header, new_node); + } + + if(node_to_be_replaced == NodeTraits::get_parent(header)){ + NodeTraits::set_parent(header, new_node); + } + + //Now set data from the original node + node_ptr temp; + NodeTraits::set_left(new_node, NodeTraits::get_left(node_to_be_replaced)); + NodeTraits::set_right(new_node, NodeTraits::get_right(node_to_be_replaced)); + NodeTraits::set_parent(new_node, NodeTraits::get_parent(node_to_be_replaced)); + + //Now adjust adjacent nodes for newly inserted node + if((temp = NodeTraits::get_left(new_node))){ + NodeTraits::set_parent(temp, new_node); + } + if((temp = NodeTraits::get_right(new_node))){ + NodeTraits::set_parent(temp, new_node); + } + if((temp = NodeTraits::get_parent(new_node)) && + //The header has been already updated so avoid it + temp != header){ + if(NodeTraits::get_left(temp) == node_to_be_replaced){ + NodeTraits::set_left(temp, new_node); + } + if(NodeTraits::get_right(temp) == node_to_be_replaced){ + NodeTraits::set_right(temp, new_node); + } + } + } + + //! <b>Requires</b>: 'node' is a node from the tree except the header. + //! + //! <b>Effects</b>: Returns the next node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr next_node(const node_ptr & node) + { + node_ptr p_right(NodeTraits::get_right(node)); + if(p_right){ + return minimum(p_right); + } + else { + node_ptr p(node); + node_ptr x = NodeTraits::get_parent(p); + while(p == NodeTraits::get_right(x)){ + p = x; + x = NodeTraits::get_parent(x); + } + return NodeTraits::get_right(p) != x ? x : uncast(p); + } + } + + //! <b>Requires</b>: 'node' is a node from the tree except the leftmost node. + //! + //! <b>Effects</b>: Returns the previous node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr prev_node(const node_ptr & node) + { + if(is_header(node)){ + return NodeTraits::get_right(node); + //return maximum(NodeTraits::get_parent(node)); + } + else if(NodeTraits::get_left(node)){ + return maximum(NodeTraits::get_left(node)); + } + else { + node_ptr p(node); + node_ptr x = NodeTraits::get_parent(p); + while(p == NodeTraits::get_left(x)){ + p = x; + x = NodeTraits::get_parent(x); + } + return x; + } + } + + //! <b>Requires</b>: 'node' is a node of a tree but not the header. + //! + //! <b>Effects</b>: Returns the minimum node of the subtree starting at p. + //! + //! <b>Complexity</b>: Logarithmic to the size of the subtree. + //! + //! <b>Throws</b>: Nothing. + static node_ptr minimum (const node_ptr & node) + { + node_ptr p(node); + for(node_ptr p_left = NodeTraits::get_left(p) + ;p_left + ;p_left = NodeTraits::get_left(p)){ + p = p_left; + } + return p; + } + + //! <b>Requires</b>: 'node' is a node of a tree but not the header. + //! + //! <b>Effects</b>: Returns the maximum node of the subtree starting at p. + //! + //! <b>Complexity</b>: Logarithmic to the size of the subtree. + //! + //! <b>Throws</b>: Nothing. + static node_ptr maximum(const node_ptr & node) + { + node_ptr p(node); + for(node_ptr p_right = NodeTraits::get_right(p) + ;p_right + ;p_right = NodeTraits::get_right(p)){ + p = p_right; + } + return p; + } + + //! <b>Requires</b>: 'node' must not be part of any tree. + //! + //! <b>Effects</b>: After the function unique(node) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init(const node_ptr & node) + { + NodeTraits::set_parent(node, node_ptr()); + NodeTraits::set_left(node, node_ptr()); + NodeTraits::set_right(node, node_ptr()); + }; + + //! <b>Effects</b>: Returns true if node is in the same state as if called init(node) + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool inited(const const_node_ptr & node) + { + return !NodeTraits::get_parent(node) && + !NodeTraits::get_left(node) && + !NodeTraits::get_right(node) ; + }; + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: Initializes the header to represent an empty tree. + //! unique(header) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init_header(const node_ptr & header) + { + NodeTraits::set_parent(header, node_ptr()); + NodeTraits::set_left(header, header); + NodeTraits::set_right(header, header); + } + + //! <b>Requires</b>: "disposer" must be an object function + //! taking a node_ptr parameter and shouldn't throw. + //! + //! <b>Effects</b>: Empties the target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template<class Disposer> + static void clear_and_dispose(const node_ptr & header, Disposer disposer) + { + node_ptr source_root = NodeTraits::get_parent(header); + if(!source_root) + return; + dispose_subtree(source_root, disposer); + init_header(header); + } + + //! <b>Requires</b>: header is the header of a tree. + //! + //! <b>Effects</b>: Unlinks the leftmost node from the tree, and + //! updates the header link to the new leftmost node. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + static node_ptr unlink_leftmost_without_rebalance(const node_ptr & header) + { + node_ptr leftmost = NodeTraits::get_left(header); + if (leftmost == header) + return node_ptr(); + node_ptr leftmost_parent(NodeTraits::get_parent(leftmost)); + node_ptr leftmost_right (NodeTraits::get_right(leftmost)); + bool is_root = leftmost_parent == header; + + if (leftmost_right){ + NodeTraits::set_parent(leftmost_right, leftmost_parent); + NodeTraits::set_left(header, tree_algorithms::minimum(leftmost_right)); + + if (is_root) + NodeTraits::set_parent(header, leftmost_right); + else + NodeTraits::set_left(NodeTraits::get_parent(header), leftmost_right); + } + else if (is_root){ + NodeTraits::set_parent(header, node_ptr()); + NodeTraits::set_left(header, header); + NodeTraits::set_right(header, header); + } + else{ + NodeTraits::set_left(leftmost_parent, node_ptr()); + NodeTraits::set_left(header, leftmost_parent); + } + return leftmost; + } + + //! <b>Requires</b>: node is a node of the tree but it's not the header. + //! + //! <b>Effects</b>: Returns the number of nodes of the subtree. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & subtree) + { + if(!subtree) return 0; + std::size_t count = 0; + node_ptr p = minimum(uncast(subtree)); + bool continue_looping = true; + while(continue_looping){ + ++count; + node_ptr p_right(NodeTraits::get_right(p)); + if(p_right){ + p = minimum(p_right); + } + else { + for(;;){ + node_ptr q; + if (p == subtree){ + continue_looping = false; + break; + } + q = p; + p = NodeTraits::get_parent(p); + if (NodeTraits::get_left(p) == q) + break; + } + } + } + return count; + } + + //! <b>Requires</b>: node is a node of the tree but it's not the header. + //! + //! <b>Effects</b>: Returns the number of nodes of the subtree. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t size(const const_node_ptr & header) + { + node_ptr beg(begin_node(header)); + node_ptr end(end_node(header)); + std::size_t i = 0; + for(;beg != end; beg = next_node(beg)) ++i; + return i; + } + + //! <b>Requires</b>: header1 and header2 must be the header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two trees. After the function header1 will contain + //! links to the second tree and header2 will have links to the first tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static void swap_tree(const node_ptr & header1, const node_ptr & header2) + { + if(header1 == header2) + return; + + node_ptr tmp; + + //Parent swap + tmp = NodeTraits::get_parent(header1); + NodeTraits::set_parent(header1, NodeTraits::get_parent(header2)); + NodeTraits::set_parent(header2, tmp); + //Left swap + tmp = NodeTraits::get_left(header1); + NodeTraits::set_left(header1, NodeTraits::get_left(header2)); + NodeTraits::set_left(header2, tmp); + //Right swap + tmp = NodeTraits::get_right(header1); + NodeTraits::set_right(header1, NodeTraits::get_right(header2)); + NodeTraits::set_right(header2, tmp); + + //Now test parent + node_ptr h1_parent(NodeTraits::get_parent(header1)); + if(h1_parent){ + NodeTraits::set_parent(h1_parent, header1); + } + else{ + NodeTraits::set_left(header1, header1); + NodeTraits::set_right(header1, header1); + } + + node_ptr h2_parent(NodeTraits::get_parent(header2)); + if(h2_parent){ + NodeTraits::set_parent(h2_parent, header2); + } + else{ + NodeTraits::set_left(header2, header2); + NodeTraits::set_right(header2, header2); + } + } + + static bool is_header(const const_node_ptr & p) + { + node_ptr p_left (NodeTraits::get_left(p)); + node_ptr p_right(NodeTraits::get_right(p)); + if(!NodeTraits::get_parent(p) || //Header condition when empty tree + (p_left && p_right && //Header always has leftmost and rightmost + (p_left == p_right || //Header condition when only node + (NodeTraits::get_parent(p_left) != p || + NodeTraits::get_parent(p_right) != p )) + //When tree size > 1 headers can't be leftmost's + //and rightmost's parent + )){ + return true; + } + return false; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the element that is equivalent to + //! "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr find + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { + node_ptr end = uncast(header); + node_ptr y = lower_bound(header, key, comp); + return (y == end || comp(key, y)) ? end : y; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an a pair of node_ptr delimiting a range containing + //! all elements that are equivalent to "key" according to "comp" or an + //! empty range that indicates the position where those elements would be + //! if they there are no equivalent elements. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, node_ptr> equal_range + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { + node_ptr y = uncast(header); + node_ptr x = NodeTraits::get_parent(header); + + while(x){ + if(comp(x, key)){ + x = NodeTraits::get_right(x); + } + else if(comp(key, x)){ + y = x; + x = NodeTraits::get_left(x); + } + else{ + node_ptr xu(x), yu(y); + y = x, x = NodeTraits::get_left(x); + xu = NodeTraits::get_right(xu); + + while(x){ + if(comp(x, key)){ + x = NodeTraits::get_right(x); + } + else { + y = x; + x = NodeTraits::get_left(x); + } + } + + while(xu){ + if(comp(key, xu)){ + yu = xu; + xu = NodeTraits::get_left(xu); + } + else { + xu = NodeTraits::get_right(xu); + } + } + return std::pair<node_ptr,node_ptr> (y, yu); + } + } + return std::pair<node_ptr,node_ptr> (y, y); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is + //! not less than "key" according to "comp" or "header" if that element does + //! not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr lower_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { + node_ptr y = uncast(header); + node_ptr x = NodeTraits::get_parent(header); + while(x){ + if(comp(x, key)){ + x = NodeTraits::get_right(x); + } + else { + y = x; + x = NodeTraits::get_left(x); + } + } + return y; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is greater + //! than "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr upper_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { + node_ptr y = uncast(header); + node_ptr x = NodeTraits::get_parent(header); + while(x){ + if(comp(key, x)){ + y = x; + x = NodeTraits::get_left(x); + } + else { + x = NodeTraits::get_right(x); + } + } + return y; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "commit_data" must have been obtained from a previous call to + //! "insert_unique_check". No objects should have been inserted or erased + //! from the set between the "insert_unique_check" that filled "commit_data" + //! and the call to "insert_commit". + //! + //! + //! <b>Effects</b>: Inserts new_node in the set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_unique_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + static void insert_unique_commit + (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data) + { return insert_commit(header, new_value, commit_data); } + + static void insert_commit + (const node_ptr & header, const node_ptr & new_node, const insert_commit_data &commit_data) + { + //Check if commit_data has not been initialized by a insert_unique_check call. + BOOST_INTRUSIVE_INVARIANT_ASSERT(commit_data.node != node_ptr()); + node_ptr parent_node(commit_data.node); + if(parent_node == header){ + NodeTraits::set_parent(header, new_node); + NodeTraits::set_right(header, new_node); + NodeTraits::set_left(header, new_node); + } + else if(commit_data.link_left){ + NodeTraits::set_left(parent_node, new_node); + if(parent_node == NodeTraits::get_left(header)) + NodeTraits::set_left(header, new_node); + } + else{ + NodeTraits::set_right(parent_node, new_node); + if(parent_node == NodeTraits::get_right(header)) + NodeTraits::set_right(header, new_node); + } + NodeTraits::set_parent(new_node, parent_node); + NodeTraits::set_right(new_node, node_ptr()); + NodeTraits::set_left(new_node, node_ptr()); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data, std::size_t *pdepth = 0) + { + std::size_t depth = 0; + node_ptr h(uncast(header)); + node_ptr y(h); + node_ptr x(NodeTraits::get_parent(y)); + node_ptr prev = node_ptr(); + + //Find the upper bound, cache the previous value and if we should + //store it in the left or right node + bool left_child = true; + while(x){ + ++depth; + y = x; + x = (left_child = comp(key, x)) ? + NodeTraits::get_left(x) : (prev = y, NodeTraits::get_right(x)); + } + + if(pdepth) *pdepth = depth; + + //Since we've found the upper bound there is no other value with the same key if: + // - There is no previous node + // - The previous node is less than the key + if(!prev || comp(prev, key)){ + commit_data.link_left = left_child; + commit_data.node = y; + return std::pair<node_ptr, bool>(node_ptr(), true); + } + //If the previous value was not less than key, it means that it's equal + //(because we've checked the upper bound) + else{ + return std::pair<node_ptr, bool>(prev, false); + } + } + + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const node_ptr &hint, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data, std::size_t *pdepth = 0) + { + //hint must be bigger than the key + if(hint == header || comp(key, hint)){ + node_ptr prev(hint); + //Previous value should be less than the key + if(hint == begin_node(header)|| comp((prev = prev_node(hint)), key)){ + commit_data.link_left = unique(header) || !NodeTraits::get_left(hint); + commit_data.node = commit_data.link_left ? hint : prev; + if(pdepth){ + *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1; + } + return std::pair<node_ptr, bool>(node_ptr(), true); + } + } + //Hint was wrong, use hintless insertion + return insert_unique_check(header, key, comp, commit_data, pdepth); + } + + template<class NodePtrCompare> + static void insert_equal_check + (const node_ptr &header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp + , insert_commit_data &commit_data, std::size_t *pdepth = 0) + { + if(hint == header || !comp(hint, new_node)){ + node_ptr prev(hint); + if(hint == NodeTraits::get_left(header) || + !comp(new_node, (prev = prev_node(hint)))){ + bool link_left = unique(header) || !NodeTraits::get_left(hint); + commit_data.link_left = link_left; + commit_data.node = link_left ? hint : prev; + if(pdepth){ + *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1; + } + } + else{ + insert_equal_upper_bound_check(header, new_node, comp, commit_data, pdepth); + } + } + else{ + insert_equal_lower_bound_check(header, new_node, comp, commit_data, pdepth); + } + } + + template<class NodePtrCompare> + static void insert_equal_upper_bound_check + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0) + { insert_equal_check_impl(true, h, new_node, comp, commit_data, pdepth); } + + template<class NodePtrCompare> + static void insert_equal_lower_bound_check + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0) + { insert_equal_check_impl(false, h, new_node, comp, commit_data, pdepth); } + + template<class NodePtrCompare> + static node_ptr insert_equal + (const node_ptr & h, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp, std::size_t *pdepth = 0) + { + insert_commit_data commit_data; + insert_equal_check(h, hint, new_node, comp, commit_data, pdepth); + insert_commit(h, new_node, commit_data); + return new_node; + } + + template<class NodePtrCompare> + static node_ptr insert_equal_upper_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, std::size_t *pdepth = 0) + { + insert_commit_data commit_data; + insert_equal_upper_bound_check(h, new_node, comp, commit_data, pdepth); + insert_commit(h, new_node, commit_data); + return new_node; + } + + template<class NodePtrCompare> + static node_ptr insert_equal_lower_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, std::size_t *pdepth = 0) + { + insert_commit_data commit_data; + insert_equal_lower_bound_check(h, new_node, comp, commit_data, pdepth); + insert_commit(h, new_node, commit_data); + return new_node; + } + + static node_ptr insert_before + (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node, std::size_t *pdepth = 0) + { + insert_commit_data commit_data; + insert_before_check(header, pos, commit_data, pdepth); + insert_commit(header, new_node, commit_data); + return new_node; + } + + static void insert_before_check + (const node_ptr &header, const node_ptr & pos + , insert_commit_data &commit_data, std::size_t *pdepth = 0) + { + node_ptr prev(pos); + if(pos != NodeTraits::get_left(header)) + prev = prev_node(pos); + bool link_left = unique(header) || !NodeTraits::get_left(pos); + commit_data.link_left = link_left; + commit_data.node = link_left ? pos : prev; + if(pdepth){ + *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1; + } + } + + static void push_back + (const node_ptr & header, const node_ptr & new_node, std::size_t *pdepth = 0) + { + insert_commit_data commit_data; + push_back_check(header, commit_data, pdepth); + insert_commit(header, new_node, commit_data); + } + + static void push_back_check + (const node_ptr & header, insert_commit_data &commit_data, std::size_t *pdepth = 0) + { + node_ptr prev(NodeTraits::get_right(header)); + if(pdepth){ + *pdepth = prev == header ? 0 : depth(prev) + 1; + } + commit_data.link_left = false; + commit_data.node = prev; + } + + static void push_front + (const node_ptr & header, const node_ptr & new_node, std::size_t *pdepth = 0) + { + insert_commit_data commit_data; + push_front_check(header, commit_data, pdepth); + insert_commit(header, new_node, commit_data); + } + + static void push_front_check + (const node_ptr & header, insert_commit_data &commit_data, std::size_t *pdepth = 0) + { + node_ptr pos(NodeTraits::get_left(header)); + if(pdepth){ + *pdepth = pos == header ? 0 : depth(pos) + 1; + } + commit_data.link_left = true; + commit_data.node = pos; + } + + //! <b>Requires</b>: 'node' can't be a header node. + //! + //! <b>Effects</b>: Calculates the depth of a node: the depth of a + //! node is the length (number of edges) of the path from the root + //! to that node. (The root node is at depth 0.) + //! + //! <b>Complexity</b>: Logarithmic to the number of nodes in the tree. + //! + //! <b>Throws</b>: Nothing. + static std::size_t depth(const const_node_ptr & node) + { + const_node_ptr p(node); + std::size_t depth = 0; + node_ptr p_parent; + while(p != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(p))){ + ++depth; + p = p_parent; + } + return depth; + } + + //! <b>Requires</b>: "cloner" must be a function + //! object taking a node_ptr and returning a new cloned node of it. "disposer" must + //! take a node_ptr and shouldn't throw. + //! + //! <b>Effects</b>: First empties target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! Then, duplicates the entire tree pointed by "source_header" cloning each + //! source node with <tt>node_ptr Cloner::operator()(const node_ptr &)</tt> to obtain + //! the nodes of the target tree. If "cloner" throws, the cloned target nodes + //! are disposed using <tt>void disposer(const node_ptr &)</tt>. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template <class Cloner, class Disposer> + static void clone + (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) + { + if(!unique(target_header)){ + clear_and_dispose(target_header, disposer); + } + + node_ptr leftmost, rightmost; + node_ptr new_root = clone_subtree + (source_header, target_header, cloner, disposer, leftmost, rightmost); + + //Now update header node + NodeTraits::set_parent(target_header, new_root); + NodeTraits::set_left (target_header, leftmost); + NodeTraits::set_right (target_header, rightmost); + } + + template <class Cloner, class Disposer> + static node_ptr clone_subtree + (const const_node_ptr &source_parent, const node_ptr &target_parent + , Cloner cloner, Disposer disposer + , node_ptr &leftmost_out, node_ptr &rightmost_out + ) + { + node_ptr target_sub_root = target_parent; + node_ptr source_root = NodeTraits::get_parent(source_parent); + if(!source_root){ + leftmost_out = rightmost_out = source_root; + } + else{ + //We'll calculate leftmost and rightmost nodes while iterating + node_ptr current = source_root; + node_ptr insertion_point = target_sub_root = cloner(current); + + //We'll calculate leftmost and rightmost nodes while iterating + node_ptr leftmost = target_sub_root; + node_ptr rightmost = target_sub_root; + + //First set the subroot + NodeTraits::set_left(target_sub_root, node_ptr()); + NodeTraits::set_right(target_sub_root, node_ptr()); + NodeTraits::set_parent(target_sub_root, target_parent); + + dispose_subtree_disposer<Disposer> rollback(disposer, target_sub_root); + while(true) { + //First clone left nodes + if( NodeTraits::get_left(current) && + !NodeTraits::get_left(insertion_point)) { + current = NodeTraits::get_left(current); + node_ptr temp = insertion_point; + //Clone and mark as leaf + insertion_point = cloner(current); + NodeTraits::set_left (insertion_point, node_ptr()); + NodeTraits::set_right (insertion_point, node_ptr()); + //Insert left + NodeTraits::set_parent(insertion_point, temp); + NodeTraits::set_left (temp, insertion_point); + //Update leftmost + if(rightmost == target_sub_root) + leftmost = insertion_point; + } + //Then clone right nodes + else if( NodeTraits::get_right(current) && + !NodeTraits::get_right(insertion_point)){ + current = NodeTraits::get_right(current); + node_ptr temp = insertion_point; + //Clone and mark as leaf + insertion_point = cloner(current); + NodeTraits::set_left (insertion_point, node_ptr()); + NodeTraits::set_right (insertion_point, node_ptr()); + //Insert right + NodeTraits::set_parent(insertion_point, temp); + NodeTraits::set_right (temp, insertion_point); + //Update rightmost + rightmost = insertion_point; + } + //If not, go up + else if(current == source_root){ + break; + } + else{ + //Branch completed, go up searching more nodes to clone + current = NodeTraits::get_parent(current); + insertion_point = NodeTraits::get_parent(insertion_point); + } + } + rollback.release(); + leftmost_out = leftmost; + rightmost_out = rightmost; + } + return target_sub_root; + } + + template<class Disposer> + static void dispose_subtree(const node_ptr & node, Disposer disposer) + { + node_ptr save; + node_ptr x(node); + while (x){ + save = NodeTraits::get_left(x); + if (save) { + // Right rotation + NodeTraits::set_left(x, NodeTraits::get_right(save)); + NodeTraits::set_right(save, x); + } + else { + save = NodeTraits::get_right(x); + init(x); + disposer(x); + } + x = save; + } + } + + //! <b>Requires</b>: p is a node of a tree. + //! + //! <b>Effects</b>: Returns true if p is a left child. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool is_left_child(const node_ptr & p) + { return NodeTraits::get_left(NodeTraits::get_parent(p)) == p; } + + //! <b>Requires</b>: p is a node of a tree. + //! + //! <b>Effects</b>: Returns true if p is a right child. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool is_right_child(const node_ptr & p) + { return NodeTraits::get_right(NodeTraits::get_parent(p)) == p; } + + //Fix header and own's parent data when replacing x with own, providing own's old data with parent + static void replace_own_impl(const node_ptr & own, const node_ptr & x, const node_ptr & header, const node_ptr & own_parent, bool own_was_left) + { + if(NodeTraits::get_parent(header) == own) + NodeTraits::set_parent(header, x); + else if(own_was_left) + NodeTraits::set_left(own_parent, x); + else + NodeTraits::set_right(own_parent, x); + } + + //Fix header and own's parent data when replacing x with own, supposing own + //links with its parent are still ok + static void replace_own(const node_ptr & own, const node_ptr & x, const node_ptr & header) + { + node_ptr own_parent(NodeTraits::get_parent(own)); + bool own_is_left(NodeTraits::get_left(own_parent) == own); + replace_own_impl(own, x, header, own_parent, own_is_left); + } + + // rotate parent p to left (no header and p's parent fixup) + static node_ptr rotate_left(const node_ptr & p) + { + node_ptr x(NodeTraits::get_right(p)); + node_ptr x_left(NodeTraits::get_left(x)); + NodeTraits::set_right(p, x_left); + if(x_left){ + NodeTraits::set_parent(x_left, p); + } + NodeTraits::set_left(x, p); + NodeTraits::set_parent(p, x); + return x; + } + + // rotate parent p to left (with header and p's parent fixup) + static void rotate_left(const node_ptr & p, const node_ptr & header) + { + bool p_was_left(is_left_child(p)); + node_ptr p_old_parent(NodeTraits::get_parent(p)); + node_ptr x(rotate_left(p)); + NodeTraits::set_parent(x, p_old_parent); + replace_own_impl(p, x, header, p_old_parent, p_was_left); + } + + // rotate parent p to right (no header and p's parent fixup) + static node_ptr rotate_right(const node_ptr & p) + { + node_ptr x(NodeTraits::get_left(p)); + node_ptr x_right(NodeTraits::get_right(x)); + NodeTraits::set_left(p, x_right); + if(x_right){ + NodeTraits::set_parent(x_right, p); + } + NodeTraits::set_right(x, p); + NodeTraits::set_parent(p, x); + return x; + } + + // rotate parent p to right (with header and p's parent fixup) + static void rotate_right(const node_ptr & p, const node_ptr & header) + { + bool p_was_left(is_left_child(p)); + node_ptr p_old_parent(NodeTraits::get_parent(p)); + node_ptr x(rotate_right(p)); + NodeTraits::set_parent(x, p_old_parent); + replace_own_impl(p, x, header, p_old_parent, p_was_left); + } + + static void erase(const node_ptr & header, const node_ptr & z) + { + data_for_rebalance ignored; + erase_impl(header, z, ignored); + } + + struct data_for_rebalance + { + node_ptr x; + node_ptr x_parent; + node_ptr y; + }; + + template<class F> + static void erase(const node_ptr & header, const node_ptr & z, F z_and_successor_fixup, data_for_rebalance &info) + { + erase_impl(header, z, info); + if(info.y != z){ + z_and_successor_fixup(z, info.y); + } + } + + static void unlink(const node_ptr & node) + { + node_ptr x = NodeTraits::get_parent(node); + if(x){ + while(!is_header(x)) + x = NodeTraits::get_parent(x); + erase(x, node); + } + } + + static void tree_to_vine(const node_ptr & header) + { subtree_to_vine(NodeTraits::get_parent(header)); } + + static void vine_to_tree(const node_ptr & header, std::size_t count) + { vine_to_subtree(NodeTraits::get_parent(header), count); } + + static void rebalance(const node_ptr & header) + { + //Taken from: + //"Tree rebalancing in optimal time and space" + //Quentin F. Stout and Bette L. Warren + std::size_t len = 0; + subtree_to_vine(NodeTraits::get_parent(header), &len); + vine_to_subtree(NodeTraits::get_parent(header), len); + } + + static node_ptr rebalance_subtree(const node_ptr & old_root) + { + std::size_t len = 0; + node_ptr new_root = subtree_to_vine(old_root, &len); + return vine_to_subtree(new_root, len); + } + + static node_ptr subtree_to_vine(const node_ptr & old_root, std::size_t *plen = 0) + { + std::size_t len; + len = 0; + if(!old_root) return node_ptr(); + + //To avoid irregularities in the algorithm (old_root can be a + //left or right child or even the root of the tree) just put the + //root as the right child of its parent. Before doing this backup + //information to restore the original relationship after + //the algorithm is applied. + node_ptr super_root = NodeTraits::get_parent(old_root); + BOOST_INTRUSIVE_INVARIANT_ASSERT(super_root); + + //Get info + node_ptr super_root_right_backup = NodeTraits::get_right(super_root); + bool super_root_is_header = is_header(super_root); + bool old_root_is_right = is_right_child(old_root); + + node_ptr x(old_root); + node_ptr new_root(x); + node_ptr save; + bool moved_to_right = false; + for( ; x; x = save){ + save = NodeTraits::get_left(x); + if(save){ + // Right rotation + node_ptr save_right = NodeTraits::get_right(save); + node_ptr x_parent = NodeTraits::get_parent(x); + NodeTraits::set_parent(save, x_parent); + NodeTraits::set_right (x_parent, save); + NodeTraits::set_parent(x, save); + NodeTraits::set_right (save, x); + NodeTraits::set_left(x, save_right); + if(save_right) + NodeTraits::set_parent(save_right, x); + if(!moved_to_right) + new_root = save; + } + else{ + moved_to_right = true; + save = NodeTraits::get_right(x); + ++len; + } + } + + if(super_root_is_header){ + NodeTraits::set_right(super_root, super_root_right_backup); + NodeTraits::set_parent(super_root, new_root); + } + else if(old_root_is_right){ + NodeTraits::set_right(super_root, new_root); + } + else{ + NodeTraits::set_right(super_root, super_root_right_backup); + NodeTraits::set_left(super_root, new_root); + } + if(plen) *plen = len; + return new_root; + } + + static node_ptr vine_to_subtree(const node_ptr & old_root, std::size_t count) + { + std::size_t leaf_nodes = count + 1 - ((std::size_t) 1 << floor_log2 (count + 1)); + std::size_t vine_nodes = count - leaf_nodes; + + node_ptr new_root = compress_subtree(old_root, leaf_nodes); + while(vine_nodes > 1){ + vine_nodes /= 2; + new_root = compress_subtree(new_root, vine_nodes); + } + return new_root; + } + + static node_ptr compress_subtree(const node_ptr & old_root, std::size_t count) + { + if(!old_root) return old_root; + + //To avoid irregularities in the algorithm (old_root can be + //left or right child or even the root of the tree) just put the + //root as the right child of its parent. First obtain + //information to restore the original relationship after + //the algorithm is applied. + node_ptr super_root = NodeTraits::get_parent(old_root); + BOOST_INTRUSIVE_INVARIANT_ASSERT(super_root); + + //Get info + node_ptr super_root_right_backup = NodeTraits::get_right(super_root); + bool super_root_is_header = is_header(super_root); + bool old_root_is_right = is_right_child(old_root); + + //Put old_root as right child + NodeTraits::set_right(super_root, old_root); + + //Start the compression algorithm + node_ptr even_parent = super_root; + node_ptr new_root = old_root; + + while(count--){ + node_ptr even = NodeTraits::get_right(even_parent); + node_ptr odd = NodeTraits::get_right(even); + + if(new_root == old_root) + new_root = odd; + + node_ptr even_right = NodeTraits::get_left(odd); + NodeTraits::set_right(even, even_right); + if (even_right) + NodeTraits::set_parent(even_right, even); + + NodeTraits::set_right(even_parent, odd); + NodeTraits::set_parent(odd, even_parent); + NodeTraits::set_left(odd, even); + NodeTraits::set_parent(even, odd); + even_parent = odd; + } + + if(super_root_is_header){ + NodeTraits::set_parent(super_root, new_root); + NodeTraits::set_right(super_root, super_root_right_backup); + } + else if(old_root_is_right){ + NodeTraits::set_right(super_root, new_root); + } + else{ + NodeTraits::set_left(super_root, new_root); + NodeTraits::set_right(super_root, super_root_right_backup); + } + return new_root; + } + + //! <b>Requires</b>: "n" must be a node inserted in a tree. + //! + //! <b>Effects</b>: Returns a pointer to the header node of the tree. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_root(const node_ptr & node) + { + BOOST_INTRUSIVE_INVARIANT_ASSERT((!inited(node))); + node_ptr x = NodeTraits::get_parent(node); + if(x){ + while(!is_header(x)){ + x = NodeTraits::get_parent(x); + } + return x; + } + else{ + return node; + } + } + + private: + template<class NodePtrCompare> + static void insert_equal_check_impl + (bool upper, const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0) + { + std::size_t depth = 0; + node_ptr y(h); + node_ptr x(NodeTraits::get_parent(y)); + bool link_left; + + if(upper){ + while(x){ + ++depth; + y = x; + x = comp(new_node, x) ? + NodeTraits::get_left(x) : NodeTraits::get_right(x); + } + link_left = (y == h) || comp(new_node, y); + } + else{ + while(x){ + ++depth; + y = x; + x = !comp(x, new_node) ? + NodeTraits::get_left(x) : NodeTraits::get_right(x); + } + link_left = (y == h) || !comp(y, new_node); + } + + commit_data.link_left = link_left; + commit_data.node = y; + if(pdepth) *pdepth = depth; + } + + static void erase_impl(const node_ptr & header, const node_ptr & z, data_for_rebalance &info) + { + node_ptr y(z); + node_ptr x; + node_ptr x_parent = node_ptr(); + node_ptr z_left(NodeTraits::get_left(z)); + node_ptr z_right(NodeTraits::get_right(z)); + if(!z_left){ + x = z_right; // x might be null. + } + else if(!z_right){ // z has exactly one non-null child. y == z. + x = z_left; // x is not null. + } + else{ + // find z's successor + y = tree_algorithms::minimum (z_right); + x = NodeTraits::get_right(y); // x might be null. + } + + if(y != z){ + // relink y in place of z. y is z's successor + NodeTraits::set_parent(NodeTraits::get_left(z), y); + NodeTraits::set_left(y, NodeTraits::get_left(z)); + if(y != NodeTraits::get_right(z)){ + x_parent = NodeTraits::get_parent(y); + if(x) + NodeTraits::set_parent(x, x_parent); + NodeTraits::set_left(x_parent, x); // y must be a child of left_ + NodeTraits::set_right(y, NodeTraits::get_right(z)); + NodeTraits::set_parent(NodeTraits::get_right(z), y); + } + else + x_parent = y; + tree_algorithms::replace_own (z, y, header); + NodeTraits::set_parent(y, NodeTraits::get_parent(z)); + } + else { // y == z --> z has only one child, or none + x_parent = NodeTraits::get_parent(z); + if(x) + NodeTraits::set_parent(x, x_parent); + tree_algorithms::replace_own (z, x, header); + if(NodeTraits::get_left(header) == z){ + NodeTraits::set_left(header, !NodeTraits::get_right(z) ? // z->get_left() must be null also + NodeTraits::get_parent(z) : // makes leftmost == header if z == root + tree_algorithms::minimum (x)); + } + if(NodeTraits::get_right(header) == z){ + NodeTraits::set_right(header, !NodeTraits::get_left(z) ? // z->get_right() must be null also + NodeTraits::get_parent(z) : // makes rightmost == header if z == root + tree_algorithms::maximum(x)); + } + } + + info.x = x; + info.x_parent = x_parent; + info.y = y; + } +}; + +} //namespace detail { +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_TREE_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/tree_node.hpp b/src/third_party/boost/boost/intrusive/detail/tree_node.hpp new file mode 100644 index 00000000000..ccbe70caf1b --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/tree_node.hpp @@ -0,0 +1,190 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007. +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_TREE_NODE_HPP +#define BOOST_INTRUSIVE_TREE_NODE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <iterator> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/mpl.hpp> + +namespace boost { +namespace intrusive { + +template<class VoidPointer> +struct tree_node +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + <tree_node<VoidPointer> >::type node_ptr; + + node_ptr parent_, left_, right_; +}; + +template<class VoidPointer> +struct tree_node_traits +{ + typedef tree_node<VoidPointer> node; + + typedef typename pointer_traits<VoidPointer>::template + rebind_pointer<node>::type node_ptr; + typedef typename pointer_traits<VoidPointer>::template + rebind_pointer<const node>::type const_node_ptr; + + static const node_ptr & get_parent(const const_node_ptr & n) + { return n->parent_; } + + static void set_parent(const node_ptr & n, const node_ptr & p) + { n->parent_ = p; } + + static const node_ptr & get_left(const const_node_ptr & n) + { return n->left_; } + + static void set_left(const node_ptr & n, const node_ptr & l) + { n->left_ = l; } + + static const node_ptr & get_right(const const_node_ptr & n) + { return n->right_; } + + static void set_right(const node_ptr & n, const node_ptr & r) + { n->right_ = r; } +}; + +///////////////////////////////////////////////////////////////////////////// +// // +// Implementation of the tree iterator // +// // +///////////////////////////////////////////////////////////////////////////// + +// tree_iterator provides some basic functions for a +// node oriented bidirectional iterator: +template<class Container, bool IsConst> +class tree_iterator + : public std::iterator + < std::bidirectional_iterator_tag + , typename Container::value_type + , typename Container::difference_type + , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type + , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type + > +{ + protected: + typedef typename Container::real_value_traits real_value_traits; + typedef typename Container::node_algorithms node_algorithms; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename pointer_traits<node_ptr>::template + rebind_pointer<void>::type void_pointer; + static const bool store_container_ptr = + detail::store_cont_ptr_on_it<Container>::value; + + public: + typedef typename Container::value_type value_type; + typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer; + typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference; + + + tree_iterator() + : members_ (node_ptr(), (const void *)0) + {} + + explicit tree_iterator(const node_ptr & nodeptr, const Container *cont_ptr) + : members_ (nodeptr, cont_ptr) + {} + + tree_iterator(tree_iterator<Container, false> const& other) + : members_(other.pointed_node(), other.get_container()) + {} + + const node_ptr &pointed_node() const + { return members_.nodeptr_; } + + tree_iterator &operator=(const node_ptr &nodeptr) + { members_.nodeptr_ = nodeptr; return static_cast<tree_iterator&>(*this); } + + public: + tree_iterator& operator++() + { + members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_); + return static_cast<tree_iterator&> (*this); + } + + tree_iterator operator++(int) + { + tree_iterator result (*this); + members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_); + return result; + } + + tree_iterator& operator--() + { + members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_); + return static_cast<tree_iterator&> (*this); + } + + tree_iterator operator--(int) + { + tree_iterator result (*this); + members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_); + return result; + } + + friend bool operator== (const tree_iterator& l, const tree_iterator& r) + { return l.pointed_node() == r.pointed_node(); } + + friend bool operator!= (const tree_iterator& l, const tree_iterator& r) + { return !(l == r); } + + reference operator*() const + { return *operator->(); } + + pointer operator->() const + { return this->get_real_value_traits()->to_value_ptr(members_.nodeptr_); } + + const Container *get_container() const + { return static_cast<const Container*>(members_.get_ptr()); } + + const real_value_traits *get_real_value_traits() const + { return &this->get_container()->get_real_value_traits(); } + + tree_iterator end_iterator_from_it() const + { + return tree_iterator(node_algorithms::get_header(this->pointed_node()), this->get_container()); + } + + tree_iterator<Container, false> unconst() const + { return tree_iterator<Container, false>(this->pointed_node(), this->get_container()); } + + private: + struct members + : public detail::select_constptr + <void_pointer, store_container_ptr>::type + { + typedef typename detail::select_constptr + <void_pointer, store_container_ptr>::type Base; + + members(const node_ptr &n_ptr, const void *cont) + : Base(cont), nodeptr_(n_ptr) + {} + + node_ptr nodeptr_; + } members_; +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_TREE_NODE_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/utilities.hpp b/src/third_party/boost/boost/intrusive/detail/utilities.hpp new file mode 100644 index 00000000000..c0416203ffb --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/utilities.hpp @@ -0,0 +1,879 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP +#define BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/parent_from_member.hpp> +#include <boost/intrusive/detail/ebo_functor_holder.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/detail/is_stateful_value_traits.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/cstdint.hpp> +#include <cstddef> +#include <climits> +#include <iterator> +#include <boost/cstdint.hpp> +#include <boost/static_assert.hpp> + +namespace boost { +namespace intrusive { +namespace detail { + +template <class T> +struct internal_member_value_traits +{ + template <class U> static detail::one test(...); + template <class U> static detail::two test(typename U::member_value_traits* = 0); + static const bool value = sizeof(test<T>(0)) == sizeof(detail::two); +}; + +template <class T> +struct internal_base_hook_bool +{ + template<bool Add> + struct two_or_three {one _[2 + Add];}; + template <class U> static one test(...); + template <class U> static two_or_three<U::boost_intrusive_tags::is_base_hook> test (int); + static const std::size_t value = sizeof(test<T>(0)); +}; + +template <class T> +struct internal_base_hook_bool_is_true +{ + static const bool value = internal_base_hook_bool<T>::value > sizeof(one)*2; +}; + +template <class T> +struct internal_any_hook_bool +{ + template<bool Add> + struct two_or_three {one _[2 + Add];}; + template <class U> static one test(...); + template <class U> static two_or_three<U::is_any_hook> test (int); + static const std::size_t value = sizeof(test<T>(0)); +}; + +template <class T> +struct internal_any_hook_bool_is_true +{ + static const bool value = internal_any_hook_bool<T>::value > sizeof(one)*2; +}; + + +template <class T> +struct external_value_traits_bool +{ + template<bool Add> + struct two_or_three {one _[2 + Add];}; + template <class U> static one test(...); + template <class U> static two_or_three<U::external_value_traits> test (int); + static const std::size_t value = sizeof(test<T>(0)); +}; + +template <class T> +struct external_bucket_traits_bool +{ + template<bool Add> + struct two_or_three {one _[2 + Add];}; + template <class U> static one test(...); + template <class U> static two_or_three<U::external_bucket_traits> test (int); + static const std::size_t value = sizeof(test<T>(0)); +}; + +template <class T> +struct external_value_traits_is_true +{ + static const bool value = external_value_traits_bool<T>::value > sizeof(one)*2; +}; + +template<class Node, class Tag, link_mode_type LinkMode, int> +struct node_holder + : public Node +{}; + +template <class T> +inline T* to_raw_pointer(T* p) +{ return p; } + +template <class Pointer> +inline typename boost::intrusive::pointer_traits<Pointer>::element_type* +to_raw_pointer(const Pointer &p) +{ return boost::intrusive::detail::to_raw_pointer(p.operator->()); } + +//This functor compares a stored value +//and the one passed as an argument +template<class ConstReference> +class equal_to_value +{ + ConstReference t_; + + public: + equal_to_value(ConstReference t) + : t_(t) + {} + + bool operator()(ConstReference t)const + { return t_ == t; } +}; + +class null_disposer +{ + public: + template <class Pointer> + void operator()(Pointer) + {} +}; + +template<class NodeAlgorithms> +class init_disposer +{ + typedef typename NodeAlgorithms::node_ptr node_ptr; + + public: + void operator()(const node_ptr & p) + { NodeAlgorithms::init(p); } +}; + +template<bool ConstantSize, class SizeType> +struct size_holder +{ + static const bool constant_time_size = ConstantSize; + typedef SizeType size_type; + + SizeType get_size() const + { return size_; } + + void set_size(SizeType size) + { size_ = size; } + + void decrement() + { --size_; } + + void increment() + { ++size_; } + + SizeType size_; +}; + +template<class SizeType> +struct size_holder<false, SizeType> +{ + static const bool constant_time_size = false; + typedef SizeType size_type; + + size_type get_size() const + { return 0; } + + void set_size(size_type) + {} + + void decrement() + {} + + void increment() + {} +}; + +template<class KeyValueCompare, class Container> +struct key_nodeptr_comp + : private detail::ebo_functor_holder<KeyValueCompare> +{ + typedef typename Container::real_value_traits real_value_traits; + typedef typename Container::value_type value_type; + typedef typename real_value_traits::node_ptr node_ptr; + typedef typename real_value_traits::const_node_ptr const_node_ptr; + typedef detail::ebo_functor_holder<KeyValueCompare> base_t; + key_nodeptr_comp(KeyValueCompare kcomp, const Container *cont) + : base_t(kcomp), cont_(cont) + {} + + template<class T> + struct is_node_ptr + { + static const bool value = is_same<T, const_node_ptr>::value || is_same<T, node_ptr>::value; + }; + + template<class T> + const value_type & key_forward + (const T &node, typename enable_if_c<is_node_ptr<T>::value>::type * = 0) const + { return *cont_->get_real_value_traits().to_value_ptr(node); } + + template<class T> + const T & key_forward(const T &key, typename enable_if_c<!is_node_ptr<T>::value>::type* = 0) const + { return key; } + + + template<class KeyType, class KeyType2> + bool operator()(const KeyType &key1, const KeyType2 &key2) const + { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); } + + const Container *cont_; +}; + +template<class F, class Container> +struct node_cloner + : private detail::ebo_functor_holder<F> +{ + typedef typename Container::real_value_traits real_value_traits; + typedef typename Container::node_algorithms node_algorithms; + typedef typename real_value_traits::value_type value_type; + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::node_traits::node node; + typedef typename real_value_traits::node_ptr node_ptr; + typedef typename real_value_traits::const_node_ptr const_node_ptr; + typedef detail::ebo_functor_holder<F> base_t; + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + node_cloner(F f, const Container *cont) + : base_t(f), cont_(cont) + {} + + node_ptr operator()(const node_ptr & p) + { return this->operator()(*p); } + + node_ptr operator()(const node &to_clone) + { + const value_type &v = + *cont_->get_real_value_traits().to_value_ptr + (pointer_traits<const_node_ptr>::pointer_to(to_clone)); + node_ptr n = cont_->get_real_value_traits().to_node_ptr(*base_t::get()(v)); + //Cloned node must be in default mode if the linking mode requires it + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n)); + return n; + } + + const Container *cont_; +}; + +template<class F, class Container> +struct node_disposer + : private detail::ebo_functor_holder<F> +{ + typedef typename Container::real_value_traits real_value_traits; + typedef typename real_value_traits::node_ptr node_ptr; + typedef detail::ebo_functor_holder<F> base_t; + typedef typename Container::node_algorithms node_algorithms; + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + node_disposer(F f, const Container *cont) + : base_t(f), cont_(cont) + {} + + void operator()(const node_ptr & p) + { + if(safemode_or_autounlink) + node_algorithms::init(p); + base_t::get()(cont_->get_real_value_traits().to_value_ptr(p)); + } + const Container *cont_; +}; + +struct dummy_constptr +{ + dummy_constptr(const void *) + {} + + const void *get_ptr() const + { return 0; } +}; + +template<class VoidPointer> +struct constptr +{ + typedef typename boost::intrusive::pointer_traits<VoidPointer>:: + template rebind_pointer<const void>::type ConstVoidPtr; + + constptr(const void *ptr) + : const_void_ptr_(ptr) + {} + + const void *get_ptr() const + { return boost::intrusive::detail::to_raw_pointer(const_void_ptr_); } + + ConstVoidPtr const_void_ptr_; +}; + +template <class VoidPointer, bool store_ptr> +struct select_constptr +{ + typedef typename detail::if_c + < store_ptr + , constptr<VoidPointer> + , dummy_constptr + >::type type; +}; + +template<class T, bool Add> +struct add_const_if_c +{ + typedef typename detail::if_c + < Add + , typename detail::add_const<T>::type + , T + >::type type; +}; + +template <link_mode_type LinkMode> +struct link_dispatch +{}; + +template<class Hook> +void destructor_impl(Hook &hook, detail::link_dispatch<safe_link>) +{ //If this assertion raises, you might have destroyed an object + //while it was still inserted in a container that is alive. + //If so, remove the object from the container before destroying it. + (void)hook; BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT(!hook.is_linked()); +} + +template<class Hook> +void destructor_impl(Hook &hook, detail::link_dispatch<auto_unlink>) +{ hook.unlink(); } + +template<class Hook> +void destructor_impl(Hook &, detail::link_dispatch<normal_link>) +{} + +template<class T, class NodeTraits, link_mode_type LinkMode, class Tag, int HookType> +struct base_hook_traits +{ + public: + typedef detail::node_holder + <typename NodeTraits::node, Tag, LinkMode, HookType> node_holder; + typedef typename NodeTraits::node node; + typedef NodeTraits node_traits; + typedef T value_type; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef typename pointer_traits<node_ptr>:: + template rebind_pointer<T>::type pointer; + typedef typename pointer_traits<node_ptr>:: + template rebind_pointer<const T>::type const_pointer; + //typedef typename pointer_traits<pointer>::reference reference; + //typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef T & reference; + typedef const T & const_reference; + typedef node_holder & node_holder_reference; + typedef const node_holder & const_node_holder_reference; + typedef node& node_reference; + typedef const node & const_node_reference; + + static const link_mode_type link_mode = LinkMode; + + static pointer to_value_ptr(const node_ptr & n) + { + return pointer_traits<pointer>::pointer_to + (static_cast<reference>(static_cast<node_holder_reference>(*n))); + } + + static const_pointer to_value_ptr(const const_node_ptr & n) + { + return pointer_traits<const_pointer>::pointer_to + (static_cast<const_reference>(static_cast<const_node_holder_reference>(*n))); + } + + static node_ptr to_node_ptr(reference value) + { + return pointer_traits<node_ptr>::pointer_to + (static_cast<node_reference>(static_cast<node_holder_reference>(value))); + } + + static const_node_ptr to_node_ptr(const_reference value) + { + return pointer_traits<const_node_ptr>::pointer_to + (static_cast<const_node_reference>(static_cast<const_node_holder_reference>(value))); + } +}; + +template<class T, class Hook, Hook T::* P> +struct member_hook_traits +{ + public: + typedef Hook hook_type; + typedef typename hook_type::boost_intrusive_tags::node_traits node_traits; + typedef typename node_traits::node node; + typedef T value_type; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef typename pointer_traits<node_ptr>:: + template rebind_pointer<T>::type pointer; + typedef typename pointer_traits<node_ptr>:: + template rebind_pointer<const T>::type const_pointer; + typedef T & reference; + typedef const T & const_reference; + typedef node& node_reference; + typedef const node & const_node_reference; + typedef hook_type& hook_reference; + typedef const hook_type & const_hook_reference; + + static const link_mode_type link_mode = Hook::boost_intrusive_tags::link_mode; + + static node_ptr to_node_ptr(reference value) + { + return pointer_traits<node_ptr>::pointer_to + (static_cast<node_reference>(static_cast<hook_reference>(value.*P))); + } + + static const_node_ptr to_node_ptr(const_reference value) + { + return pointer_traits<const_node_ptr>::pointer_to + (static_cast<const_node_reference>(static_cast<const_hook_reference>(value.*P))); + } + + static pointer to_value_ptr(const node_ptr & n) + { + return pointer_traits<pointer>::pointer_to + (*detail::parent_from_member<T, Hook> + (static_cast<Hook*>(boost::intrusive::detail::to_raw_pointer(n)), P)); + } + + static const_pointer to_value_ptr(const const_node_ptr & n) + { + return pointer_traits<const_pointer>::pointer_to + (*detail::parent_from_member<T, Hook> + (static_cast<const Hook*>(boost::intrusive::detail::to_raw_pointer(n)), P)); + } +}; + +template<class Functor> +struct function_hook_traits +{ + public: + typedef typename Functor::hook_type hook_type; + typedef typename Functor::hook_ptr hook_ptr; + typedef typename Functor::const_hook_ptr const_hook_ptr; + typedef typename hook_type::boost_intrusive_tags::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename Functor::value_type value_type; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef typename pointer_traits<node_ptr>:: + template rebind_pointer<value_type>::type pointer; + typedef typename pointer_traits<node_ptr>:: + template rebind_pointer<const value_type>::type const_pointer; + typedef value_type & reference; + typedef const value_type & const_reference; + static const link_mode_type link_mode = hook_type::boost_intrusive_tags::link_mode; + + static node_ptr to_node_ptr(reference value) + { return static_cast<node*>(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); } + + static const_node_ptr to_node_ptr(const_reference value) + { return static_cast<const node*>(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); } + + static pointer to_value_ptr(const node_ptr & n) + { return Functor::to_value_ptr(to_hook_ptr(n)); } + + static const_pointer to_value_ptr(const const_node_ptr & n) + { return Functor::to_value_ptr(to_hook_ptr(n)); } + + private: + static hook_ptr to_hook_ptr(const node_ptr & n) + { return hook_ptr(&*static_cast<hook_type*>(&*n)); } + + static const_hook_ptr to_hook_ptr(const const_node_ptr & n) + { return const_hook_ptr(&*static_cast<const hook_type*>(&*n)); } +}; + + +//This function uses binary search to discover the +//highest set bit of the integer +inline std::size_t floor_log2 (std::size_t x) +{ + const std::size_t Bits = sizeof(std::size_t)*CHAR_BIT; + const bool Size_t_Bits_Power_2= !(Bits & (Bits-1)); + BOOST_STATIC_ASSERT(Size_t_Bits_Power_2); + + 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) + log2 += shift, n = tmp; + } + + return log2; +} + +inline float fast_log2 (float val) +{ + union caster_t + { + boost::uint32_t x; + float val; + } caster; + + caster.val = val; + boost::uint32_t x = caster.x; + const int log_2 = (int)(((x >> 23) & 255) - 128); + x &= ~(255 << 23); + x += 127 << 23; + caster.x = x; + val = caster.val; + val = ((-1.0f/3) * val + 2) * val - 2.0f/3; + + return (val + log_2); +} + +inline std::size_t ceil_log2 (std::size_t x) +{ + return ((x & (x-1))!= 0) + floor_log2(x); +} + +template<class SizeType, std::size_t N> +struct numbits_eq +{ + static const bool value = sizeof(SizeType)*CHAR_BIT == N; +}; + +template<class SizeType, class Enabler = void > +struct sqrt2_pow_max; + +template <class SizeType> +struct sqrt2_pow_max<SizeType, typename enable_if< numbits_eq<SizeType, 32> >::type> +{ + static const boost::uint32_t value = 0xb504f334; + static const std::size_t pow = 31; +}; + +template <class SizeType> +struct sqrt2_pow_max<SizeType, typename enable_if< numbits_eq<SizeType, 64> >::type> +{ + static const boost::uint64_t value = 0xb504f333f9de6484ull; + static const std::size_t pow = 63; +}; + +// Returns floor(pow(sqrt(2), x * 2 + 1)). +// Defined for X from 0 up to the number of bits in size_t minus 1. +inline std::size_t sqrt2_pow_2xplus1 (std::size_t x) +{ + const std::size_t value = (std::size_t)sqrt2_pow_max<std::size_t>::value; + const std::size_t pow = (std::size_t)sqrt2_pow_max<std::size_t>::pow; + return (value >> (pow - x)) + 1; +} + +template<class Container, class Disposer> +class exception_disposer +{ + Container *cont_; + Disposer &disp_; + + exception_disposer(const exception_disposer&); + exception_disposer &operator=(const exception_disposer&); + + public: + exception_disposer(Container &cont, Disposer &disp) + : cont_(&cont), disp_(disp) + {} + + void release() + { cont_ = 0; } + + ~exception_disposer() + { + if(cont_){ + cont_->clear_and_dispose(disp_); + } + } +}; + +template<class Container, class Disposer, class SizeType> +class exception_array_disposer +{ + Container *cont_; + Disposer &disp_; + SizeType &constructed_; + + exception_array_disposer(const exception_array_disposer&); + exception_array_disposer &operator=(const exception_array_disposer&); + + public: + + exception_array_disposer + (Container &cont, Disposer &disp, SizeType &constructed) + : cont_(&cont), disp_(disp), constructed_(constructed) + {} + + void release() + { cont_ = 0; } + + ~exception_array_disposer() + { + SizeType n = constructed_; + if(cont_){ + while(n--){ + cont_[n].clear_and_dispose(disp_); + } + } + } +}; + +template<class ValueTraits, bool ExternalValueTraits> +struct store_cont_ptr_on_it_impl +{ + static const bool value = is_stateful_value_traits<ValueTraits>::value; +}; + +template<class ValueTraits> +struct store_cont_ptr_on_it_impl<ValueTraits, true> +{ + static const bool value = true; +}; + +template <class Container> +struct store_cont_ptr_on_it +{ + typedef typename Container::value_traits value_traits; + static const bool value = store_cont_ptr_on_it_impl + <value_traits, external_value_traits_is_true<value_traits>::value>::value; +}; + +template<class Container, bool IsConst> +struct node_to_value + : public detail::select_constptr + < typename pointer_traits + <typename Container::pointer>::template rebind_pointer<void>::type + , detail::store_cont_ptr_on_it<Container>::value + >::type +{ + static const bool store_container_ptr = + detail::store_cont_ptr_on_it<Container>::value; + + typedef typename Container::real_value_traits real_value_traits; + typedef typename real_value_traits::value_type value_type; + typedef typename detail::select_constptr + < typename pointer_traits + <typename Container::pointer>::template rebind_pointer<void>::type + , store_container_ptr >::type Base; + typedef typename real_value_traits::node_traits::node node; + typedef typename detail::add_const_if_c + <value_type, IsConst>::type vtype; + typedef typename detail::add_const_if_c + <node, IsConst>::type ntype; + typedef typename pointer_traits + <typename Container::pointer>::template rebind_pointer<ntype>::type npointer; + + node_to_value(const Container *cont) + : Base(cont) + {} + + typedef vtype & result_type; + typedef ntype & first_argument_type; + + const Container *get_container() const + { + if(store_container_ptr) + return static_cast<const Container*>(Base::get_ptr()); + else + return 0; + } + + const real_value_traits *get_real_value_traits() const + { + if(store_container_ptr) + return &this->get_container()->get_real_value_traits(); + else + return 0; + } + + result_type operator()(first_argument_type arg) const + { + return *(this->get_real_value_traits()->to_value_ptr + (pointer_traits<npointer>::pointer_to(arg))); + } +}; + +//This is not standard, but should work with all compilers +union max_align +{ + char char_; + short short_; + int int_; + long long_; + #ifdef BOOST_HAS_LONG_LONG + long long long_long_; + #endif + float float_; + double double_; + long double long_double_; + void * void_ptr_; +}; + +template<class T, std::size_t N> +class array_initializer +{ + public: + template<class CommonInitializer> + array_initializer(const CommonInitializer &init) + { + char *init_buf = (char*)rawbuf; + std::size_t i = 0; + try{ + for(; i != N; ++i){ + new(init_buf)T(init); + init_buf += sizeof(T); + } + } + catch(...){ + while(i--){ + init_buf -= sizeof(T); + ((T*)init_buf)->~T(); + } + throw; + } + } + + operator T* () + { return (T*)(rawbuf); } + + operator const T*() const + { return (const T*)(rawbuf); } + + ~array_initializer() + { + char *init_buf = (char*)rawbuf + N*sizeof(T); + for(std::size_t i = 0; i != N; ++i){ + init_buf -= sizeof(T); + ((T*)init_buf)->~T(); + } + } + + private: + detail::max_align rawbuf[(N*sizeof(T)-1)/sizeof(detail::max_align)+1]; +}; + + + + +template<class It> +class reverse_iterator + : public std::iterator< + typename std::iterator_traits<It>::iterator_category, + typename std::iterator_traits<It>::value_type, + typename std::iterator_traits<It>::difference_type, + typename std::iterator_traits<It>::pointer, + typename std::iterator_traits<It>::reference> +{ + public: + typedef typename std::iterator_traits<It>::pointer pointer; + typedef typename std::iterator_traits<It>::reference reference; + typedef typename std::iterator_traits<It>::difference_type difference_type; + typedef It iterator_type; + + reverse_iterator(){} + + explicit reverse_iterator(It r) + : m_current(r) + {} + + template<class OtherIt> + reverse_iterator(const reverse_iterator<OtherIt>& r) + : m_current(r.base()) + {} + + It base() const + { return m_current; } + + reference operator*() const + { It temp(m_current); --temp; return *temp; } + + pointer operator->() const + { It temp(m_current); --temp; return temp.operator->(); } + + reference operator[](difference_type off) const + { return this->m_current[-off]; } + + reverse_iterator& operator++() + { --m_current; return *this; } + + reverse_iterator operator++(int) + { + reverse_iterator temp = *this; + --m_current; + return temp; + } + + reverse_iterator& operator--() + { + ++m_current; + return *this; + } + + reverse_iterator operator--(int) + { + reverse_iterator temp(*this); + ++m_current; + return temp; + } + + friend bool operator==(const reverse_iterator& l, const reverse_iterator& r) + { return l.m_current == r.m_current; } + + friend bool operator!=(const reverse_iterator& l, const reverse_iterator& r) + { return l.m_current != r.m_current; } + + friend bool operator<(const reverse_iterator& l, const reverse_iterator& r) + { return l.m_current < r.m_current; } + + friend bool operator<=(const reverse_iterator& l, const reverse_iterator& r) + { return l.m_current <= r.m_current; } + + friend bool operator>(const reverse_iterator& l, const reverse_iterator& r) + { return l.m_current > r.m_current; } + + friend bool operator>=(const reverse_iterator& l, const reverse_iterator& r) + { return l.m_current >= r.m_current; } + + reverse_iterator& operator+=(difference_type off) + { m_current -= off; return *this; } + + friend reverse_iterator operator+(const reverse_iterator & l, difference_type off) + { + reverse_iterator tmp(l.m_current); + tmp.m_current -= off; + return tmp; + } + + reverse_iterator& operator-=(difference_type off) + { m_current += off; return *this; } + + friend reverse_iterator operator-(const reverse_iterator & l, difference_type off) + { + reverse_iterator tmp(l.m_current); + tmp.m_current += off; + return tmp; + } + + friend difference_type operator-(const reverse_iterator& l, const reverse_iterator& r) + { return r.m_current - l.m_current; } + + private: + It m_current; // the wrapped iterator +}; + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP diff --git a/src/third_party/boost/boost/intrusive/detail/workaround.hpp b/src/third_party/boost/boost/intrusive/detail/workaround.hpp new file mode 100644 index 00000000000..5de529fb66c --- /dev/null +++ b/src/third_party/boost/boost/intrusive/detail/workaround.hpp @@ -0,0 +1,22 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-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) +// +// See http://www.boost.org/libs/interprocess for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_WRKRND_HPP +#define BOOST_INTRUSIVE_DETAIL_WRKRND_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES) + #define BOOST_INTRUSIVE_PERFECT_FORWARDING +#endif + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_WRKRND_HPP diff --git a/src/third_party/boost/boost/intrusive/hashtable.hpp b/src/third_party/boost/boost/intrusive/hashtable.hpp new file mode 100644 index 00000000000..bade5cb5071 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/hashtable.hpp @@ -0,0 +1,3188 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_HASHTABLE_HPP +#define BOOST_INTRUSIVE_HASHTABLE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +//std C++ +#include <functional> //std::equal_to +#include <utility> //std::pair +#include <algorithm> //std::swap, std::lower_bound, std::upper_bound +#include <cstddef> //std::size_t +//boost +#include <boost/intrusive/detail/assert.hpp> +#include <boost/static_assert.hpp> +#include <boost/functional/hash.hpp> +#include <boost/pointer_cast.hpp> +//General intrusive utilities +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/hashtable_node.hpp> +#include <boost/intrusive/detail/transform_iterator.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/detail/ebo_functor_holder.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/detail/utilities.hpp> +//Implementation utilities +#include <boost/intrusive/trivial_value_traits.hpp> +#include <boost/intrusive/unordered_set_hook.hpp> +#include <boost/intrusive/slist.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/type_traits.hpp> +#include <boost/move/move.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +namespace detail { + +struct hash_bool_flags +{ + static const std::size_t unique_keys_pos = 1u; + static const std::size_t constant_time_size_pos = 2u; + static const std::size_t power_2_buckets_pos = 4u; + static const std::size_t cache_begin_pos = 8u; + static const std::size_t compare_hash_pos = 16u; + static const std::size_t incremental_pos = 32u; +}; + +template + < class ValueTraits + , class Hash + , class Equal + , class SizeType + , class BucketTraits + , std::size_t BoolFlags + > +struct usetopt +{ + typedef ValueTraits value_traits; + typedef Hash hash; + typedef Equal equal; + typedef SizeType size_type; + typedef BucketTraits bucket_traits; + static const std::size_t bool_flags = BoolFlags; +}; + +template + < class UsetOpt + , std::size_t BoolMask + > +struct usetopt_mask +{ + typedef usetopt + <typename UsetOpt::value_traits + ,typename UsetOpt::hash + ,typename UsetOpt::equal + ,typename UsetOpt::size_type + ,typename UsetOpt::bucket_traits + ,UsetOpt::bool_flags & BoolMask + > type; +}; + +template <class NodeTraits> +struct hash_reduced_slist_node_traits +{ + template <class U> static detail::one test(...); + template <class U> static detail::two test(typename U::reduced_slist_node_traits* = 0); + static const bool value = sizeof(test<NodeTraits>(0)) == sizeof(detail::two); +}; + +template <class NodeTraits> +struct apply_reduced_slist_node_traits +{ + typedef typename NodeTraits::reduced_slist_node_traits type; +}; + +template <class NodeTraits> +struct reduced_slist_node_traits +{ + typedef typename detail::eval_if_c + < hash_reduced_slist_node_traits<NodeTraits>::value + , apply_reduced_slist_node_traits<NodeTraits> + , detail::identity<NodeTraits> + >::type type; +}; + +template<class NodeTraits> +struct get_slist_impl +{ + typedef trivial_value_traits<NodeTraits, normal_link> trivial_traits; + + //Reducing symbol length + struct type : make_slist + < typename NodeTraits::node + , boost::intrusive::value_traits<trivial_traits> + , boost::intrusive::constant_time_size<false> + , boost::intrusive::size_type<typename boost::make_unsigned + <typename pointer_traits<typename NodeTraits::node_ptr>::difference_type>::type > + >::type + {}; +}; + +template<class SupposedValueTraits> +struct real_from_supposed_value_traits +{ + typedef typename detail::eval_if_c + < detail::external_value_traits_is_true + <SupposedValueTraits>::value + , detail::eval_value_traits + <SupposedValueTraits> + , detail::identity + <SupposedValueTraits> + >::type type; +}; + +template<class SupposedValueTraits> +struct get_slist_impl_from_supposed_value_traits +{ + typedef typename + real_from_supposed_value_traits + < SupposedValueTraits>::type real_value_traits; + typedef typename detail::get_node_traits + <real_value_traits>::type node_traits; + typedef typename get_slist_impl + <typename reduced_slist_node_traits + <node_traits>::type + >::type type; +}; + +template<class SupposedValueTraits> +struct unordered_bucket_impl +{ + typedef typename + get_slist_impl_from_supposed_value_traits + <SupposedValueTraits>::type slist_impl; + typedef detail::bucket_impl<slist_impl> implementation_defined; + typedef implementation_defined type; +}; + +template<class SupposedValueTraits> +struct unordered_bucket_ptr_impl +{ + typedef typename detail::get_node_traits + <SupposedValueTraits>::type::node_ptr node_ptr; + typedef typename unordered_bucket_impl + <SupposedValueTraits>::type bucket_type; + + typedef typename pointer_traits + <node_ptr>::template rebind_pointer + < bucket_type >::type implementation_defined; + typedef implementation_defined type; +}; + +template <class T> +struct store_hash_bool +{ + template<bool Add> + struct two_or_three {one _[2 + Add];}; + template <class U> static one test(...); + template <class U> static two_or_three<U::store_hash> test (int); + static const std::size_t value = sizeof(test<T>(0)); +}; + +template <class T> +struct store_hash_is_true +{ + static const bool value = store_hash_bool<T>::value > sizeof(one)*2; +}; + +template <class T> +struct optimize_multikey_bool +{ + template<bool Add> + struct two_or_three {one _[2 + Add];}; + template <class U> static one test(...); + template <class U> static two_or_three<U::optimize_multikey> test (int); + static const std::size_t value = sizeof(test<T>(0)); +}; + +template <class T> +struct optimize_multikey_is_true +{ + static const bool value = optimize_multikey_bool<T>::value > sizeof(one)*2; +}; + +template<class Config> +struct bucket_plus_size + : public detail::size_holder //size_traits + < 0 != (Config::bool_flags & hash_bool_flags::constant_time_size_pos) + , typename Config::size_type> +{ + typedef detail::size_holder + < 0 != (Config::bool_flags & hash_bool_flags::constant_time_size_pos) + , typename Config::size_type> size_traits; + typedef typename Config::bucket_traits bucket_traits; + + template<class BucketTraits> + bucket_plus_size(BOOST_FWD_REF(BucketTraits) b_traits) + : bucket_traits_(::boost::forward<BucketTraits>(b_traits)) + {} + + bucket_plus_size & operator =(const bucket_plus_size &x) + { + this->size_traits::operator=(x); + bucket_traits_ = x.bucket_traits_; + return *this; + } + bucket_traits bucket_traits_; +}; + +template<class Config> +struct bucket_hash_t + : public detail::ebo_functor_holder<typename Config::hash> //hash +{ + typedef typename Config::hash hasher; + typedef detail::size_holder + < 0 != (Config::bool_flags & hash_bool_flags::constant_time_size_pos) + , typename Config::size_type> size_traits; + typedef typename Config::bucket_traits bucket_traits; + + template<class BucketTraits> + bucket_hash_t(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h) + : detail::ebo_functor_holder<hasher>(h), bucket_plus_size_(::boost::forward<BucketTraits>(b_traits)) + {} + + bucket_plus_size<Config> bucket_plus_size_; +}; + +template<class Config, bool> +struct bucket_hash_equal_t + : public detail::ebo_functor_holder<typename Config::equal> +{ + typedef typename Config::equal equal; + typedef typename Config::hash hasher; + typedef typename Config::bucket_traits bucket_traits; + + template<class BucketTraits> + bucket_hash_equal_t(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h, const equal &e) + : detail::ebo_functor_holder<typename Config::equal>(e)//equal() + , bucket_hash(::boost::forward<BucketTraits>(b_traits), h) + {} + + template<class T> + void set_cache(T) + {} + + bucket_hash_t<Config> bucket_hash; +}; + +template<class Config> //cache_begin == true version +struct bucket_hash_equal_t<Config, true> + : public detail::ebo_functor_holder<typename Config::equal> +{ + typedef typename Config::equal equal; + typedef typename Config::hash hasher; + typedef typename Config::bucket_traits bucket_traits; + typedef typename unordered_bucket_ptr_impl + <typename Config::value_traits>::type bucket_ptr; + + template<class BucketTraits> + bucket_hash_equal_t(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h, const equal &e) + : detail::ebo_functor_holder<typename Config::equal>(e) //equal() + , bucket_hash(::boost::forward<BucketTraits>(b_traits), h) + {} + + void set_cache(const bucket_ptr & c) + { cached_begin_ = c; } + + bucket_hash_t<Config> bucket_hash; + bucket_ptr cached_begin_; +}; + +template<class Config> +struct hashtable_data_t : public Config::value_traits +{ + static const std::size_t bool_flags = Config::bool_flags; + typedef typename Config::value_traits value_traits; + typedef typename Config::equal equal; + typedef typename Config::hash hasher; + typedef typename Config::bucket_traits bucket_traits; + + template<class BucketTraits> + hashtable_data_t( BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h + , const equal &e, const value_traits &val_traits) + : Config::value_traits(val_traits) //value_traits + , internal_(::boost::forward<BucketTraits>(b_traits), h, e) + {} + typedef typename detail::usetopt_mask + < Config + , detail::hash_bool_flags::constant_time_size_pos + | detail::hash_bool_flags::incremental_pos + >::type masked_config_t; + struct internal + : public detail::size_holder //split_traits + < 0 != (Config::bool_flags & hash_bool_flags::incremental_pos) + , typename Config::size_type> + { + template<class BucketTraits> + internal(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h, const equal &e) + : bucket_hash_equal_(::boost::forward<BucketTraits>(b_traits), h, e) + {} + + bucket_hash_equal_t + < masked_config_t + , 0 != (bool_flags & hash_bool_flags::cache_begin_pos) + > bucket_hash_equal_; + } internal_; +}; + +struct insert_commit_data_impl +{ + std::size_t hash; +}; + +template<class NodeTraits> +struct group_functions +{ + typedef NodeTraits node_traits; + typedef unordered_group_adapter<node_traits> group_traits; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::node node; + typedef typename reduced_slist_node_traits + <node_traits>::type reduced_node_traits; + typedef typename reduced_node_traits::node_ptr slist_node_ptr; + typedef typename reduced_node_traits::node slist_node; + typedef circular_slist_algorithms<group_traits> group_algorithms; + + static node_ptr dcast_bucket_ptr(const slist_node_ptr &p) + { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*p)); } + + static slist_node_ptr get_bucket_before_begin + (const slist_node_ptr &bucket_beg, const slist_node_ptr &bucket_end, const node_ptr &p) + { + //First find the last node of p's group. + //This requires checking the first node of the next group or + //the bucket node. + node_ptr prev_node = p; + node_ptr nxt(node_traits::get_next(p)); + while(!(bucket_beg <= nxt && nxt <= bucket_end) && + (group_traits::get_next(nxt) == prev_node)){ + prev_node = nxt; + nxt = node_traits::get_next(nxt); + } + + //If we've reached the bucket node just return it. + if(bucket_beg <= nxt && nxt <= bucket_end){ + return nxt; + } + + //Otherwise, iterate using group links until the bucket node + node_ptr first_node_of_group = nxt; + node_ptr last_node_group = group_traits::get_next(first_node_of_group); + slist_node_ptr possible_end = node_traits::get_next(last_node_group); + + while(!(bucket_beg <= possible_end && possible_end <= bucket_end)){ + first_node_of_group = dcast_bucket_ptr(possible_end); + last_node_group = group_traits::get_next(first_node_of_group); + possible_end = node_traits::get_next(last_node_group); + } + return possible_end; + } + + static node_ptr get_prev_to_first_in_group(const slist_node_ptr &bucket_node, const node_ptr &first_in_group) + { + //Just iterate using group links and obtain the node + //before "first_in_group)" + node_ptr prev_node = dcast_bucket_ptr(bucket_node); + node_ptr nxt(node_traits::get_next(prev_node)); + while(nxt != first_in_group){ + prev_node = group_traits::get_next(nxt); + nxt = node_traits::get_next(prev_node); + } + return prev_node; + } + + static node_ptr get_first_in_group_of_last_in_group(const node_ptr &last_in_group) + { + //Just iterate using group links and obtain the node + //before "last_in_group" + node_ptr possible_first = group_traits::get_next(last_in_group); + node_ptr possible_first_prev = group_traits::get_next(possible_first); + // The deleted node is at the end of the group, so the + // node in the group pointing to it is at the beginning + // of the group. Find that to change its pointer. + while(possible_first_prev != last_in_group){ + possible_first = possible_first_prev; + possible_first_prev = group_traits::get_next(possible_first); + } + return possible_first; + } + + static void erase_from_group(const slist_node_ptr &end_ptr, const node_ptr &to_erase_ptr, detail::true_) + { + node_ptr nxt_ptr(node_traits::get_next(to_erase_ptr)); + node_ptr prev_in_group_ptr(group_traits::get_next(to_erase_ptr)); + bool last_in_group = (end_ptr == nxt_ptr) || + (group_traits::get_next(nxt_ptr) != to_erase_ptr); + bool first_in_group = node_traits::get_next(prev_in_group_ptr) != to_erase_ptr; + + if(first_in_group && last_in_group){ + group_algorithms::init(to_erase_ptr); + } + else if(first_in_group){ + group_algorithms::unlink_after(nxt_ptr); + } + else if(last_in_group){ + node_ptr first_in_group = + get_first_in_group_of_last_in_group(to_erase_ptr); + group_algorithms::unlink_after(first_in_group); + } + else{ + group_algorithms::unlink_after(nxt_ptr); + } + } + + static void erase_from_group(const slist_node_ptr&, const node_ptr&, detail::false_) + {} + + static node_ptr get_last_in_group(const node_ptr &first_in_group, detail::true_) + { return group_traits::get_next(first_in_group); } + + static node_ptr get_last_in_group(const node_ptr &n, detail::false_) + { return n; } + + static void init_group(const node_ptr &n, true_) + { group_algorithms::init(n); } + + static void init_group(const node_ptr &, false_) + {} + + static void insert_in_group(const node_ptr &first_in_group, const node_ptr &n, true_) + { + if(first_in_group){ + if(group_algorithms::unique(first_in_group)) + group_algorithms::link_after(first_in_group, n); + else{ + group_algorithms::link_after(group_algorithms::node_traits::get_next(first_in_group), n); + } + } + else{ + group_algorithms::init_header(n); + } + } + + static slist_node_ptr get_previous_and_next_in_group + ( const slist_node_ptr &i, node_ptr &nxt_in_group + //If first_end_ptr == last_end_ptr, then first_end_ptr is the bucket of i + //Otherwise first_end_ptr is the first bucket and last_end_ptr the last one. + , const slist_node_ptr &first_end_ptr, const slist_node_ptr &last_end_ptr) + { + slist_node_ptr prev; + node_ptr elem(dcast_bucket_ptr(i)); + + //It's the last in group if the next_node is a bucket + slist_node_ptr nxt(node_traits::get_next(elem)); + bool last_in_group = (first_end_ptr <= nxt && nxt <= last_end_ptr)/* || + (group_traits::get_next(nxt) != elem)*/; + //It's the first in group if group_previous's next_node is not + //itself, as group list does not link bucket + node_ptr prev_in_group(group_traits::get_next(elem)); + bool first_in_group = node_traits::get_next(prev_in_group) != elem; + + if(first_in_group){ + node_ptr start_pos; + if(last_in_group){ + start_pos = elem; + nxt_in_group = node_ptr(); + } + else{ + start_pos = prev_in_group; + nxt_in_group = node_traits::get_next(elem); + } + slist_node_ptr bucket_node; + if(first_end_ptr != last_end_ptr){ + bucket_node = group_functions::get_bucket_before_begin + (first_end_ptr, last_end_ptr, start_pos); + } + else{ + bucket_node = first_end_ptr; + } + prev = group_functions::get_prev_to_first_in_group(bucket_node, elem); + } + else{ + if(last_in_group){ + nxt_in_group = group_functions::get_first_in_group_of_last_in_group(elem); + } + else{ + nxt_in_group = node_traits::get_next(elem); + } + prev = group_traits::get_next(elem); + } + return prev; + } + + static void insert_in_group(const node_ptr&, const node_ptr&, false_) + {} +}; + +template<class BucketType, class SplitTraits> +class incremental_rehash_rollback +{ + private: + typedef BucketType bucket_type; + typedef SplitTraits split_traits; + + incremental_rehash_rollback(); + incremental_rehash_rollback & operator=(const incremental_rehash_rollback &); + incremental_rehash_rollback (const incremental_rehash_rollback &); + + public: + incremental_rehash_rollback + (bucket_type &source_bucket, bucket_type &destiny_bucket, split_traits &split_traits) + : source_bucket_(source_bucket), destiny_bucket_(destiny_bucket) + , split_traits_(split_traits), released_(false) + {} + + void release() + { released_ = true; } + + ~incremental_rehash_rollback() + { + if(!released_){ + //If an exception is thrown, just put all moved nodes back in the old bucket + //and move back the split mark. + destiny_bucket_.splice_after(destiny_bucket_.before_begin(), source_bucket_); + split_traits_.decrement(); + } + } + + private: + bucket_type &source_bucket_; + bucket_type &destiny_bucket_; + split_traits &split_traits_; + bool released_; +}; + +template<class NodeTraits> +struct node_functions +{ + static void store_hash(typename NodeTraits::node_ptr p, std::size_t h, true_) + { return NodeTraits::set_hash(p, h); } + + static void store_hash(typename NodeTraits::node_ptr, std::size_t, false_) + {} +}; + +} //namespace detail { + +//!This metafunction will obtain the type of a bucket +//!from the value_traits or hook option to be used with +//!a hash container. +template<class ValueTraitsOrHookOption> +struct unordered_bucket + : public detail::unordered_bucket_impl + <typename ValueTraitsOrHookOption:: + template pack<none>::value_traits + > +{}; + +//!This metafunction will obtain the type of a bucket pointer +//!from the value_traits or hook option to be used with +//!a hash container. +template<class ValueTraitsOrHookOption> +struct unordered_bucket_ptr + : public detail::unordered_bucket_ptr_impl + <typename ValueTraitsOrHookOption:: + template pack<none>::value_traits + > +{}; + +//!This metafunction will obtain the type of the default bucket traits +//!(when the user does not specify the bucket_traits<> option) from the +//!value_traits or hook option to be used with +//!a hash container. +template<class ValueTraitsOrHookOption> +struct unordered_default_bucket_traits +{ + typedef typename ValueTraitsOrHookOption:: + template pack<none>::value_traits supposed_value_traits; + typedef typename detail:: + get_slist_impl_from_supposed_value_traits + <supposed_value_traits>::type slist_impl; + typedef detail::bucket_traits_impl + <slist_impl> implementation_defined; + typedef implementation_defined type; +}; + +struct default_bucket_traits; + +template <class T> +struct uset_defaults + : pack_options + < none + , base_hook<detail::default_uset_hook> + , constant_time_size<true> + , size_type<std::size_t> + , equal<std::equal_to<T> > + , hash<boost::hash<T> > + , bucket_traits<default_bucket_traits> + , power_2_buckets<false> + , cache_begin<false> + , compare_hash<false> + , incremental<false> + >::type +{}; + +/// @endcond + +//! The class template hashtable is an intrusive hash table container, that +//! is used to construct intrusive unordered_set and unordered_multiset containers. The +//! no-throw guarantee holds only, if the Equal object and Hasher don't throw. +//! +//! hashtable is a semi-intrusive container: each object to be stored in the +//! container must contain a proper hook, but the container also needs +//! additional auxiliary memory to work: hashtable needs a pointer to an array +//! of type `bucket_type` to be passed in the constructor. This bucket array must +//! have at least the same lifetime as the container. This makes the use of +//! hashtable more complicated than purely intrusive containers. +//! `bucket_type` is default-constructible, copyable and assignable +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<> +//! \c bucket_traits<>, power_2_buckets<>, cache_begin<> and incremental<>. +//! +//! hashtable only provides forward iterators but it provides 4 iterator types: +//! iterator and const_iterator to navigate through the whole container and +//! local_iterator and const_local_iterator to navigate through the values +//! stored in a single bucket. Local iterators are faster and smaller. +//! +//! It's not recommended to use non constant-time size hashtables because several +//! key functions, like "empty()", become non-constant time functions. Non +//! constant_time size hashtables are mainly provided to support auto-unlink hooks. +//! +//! hashtables, does not make automatic rehashings nor +//! offers functions related to a load factor. Rehashing can be explicitly requested +//! and the user must provide a new bucket array that will be used from that moment. +//! +//! Since no automatic rehashing is done, iterators are never invalidated when +//! inserting or erasing elements. Iterators are only invalidated when rehashing. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class hashtable_impl + : private detail::clear_on_destructor_base<hashtable_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + public: + typedef typename Config::value_traits value_traits; + + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + typedef typename Config::bucket_traits bucket_traits; + static const bool external_bucket_traits = + detail::external_bucket_traits_is_true<bucket_traits>::value; + typedef typename detail::eval_if_c + < external_bucket_traits + , detail::eval_bucket_traits<bucket_traits> + , detail::identity<bucket_traits> + >::type real_bucket_traits; + typedef typename detail::get_slist_impl + <typename detail::reduced_slist_node_traits + <typename real_value_traits::node_traits>::type + >::type slist_impl; + /// @endcond + + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + typedef typename real_value_traits::value_type value_type; + typedef typename pointer_traits<pointer>::reference reference; + typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef typename pointer_traits<pointer>::difference_type difference_type; + typedef typename Config::size_type size_type; + typedef value_type key_type; + typedef typename Config::equal key_equal; + typedef typename Config::hash hasher; + typedef detail::bucket_impl<slist_impl> bucket_type; + typedef typename pointer_traits + <pointer>::template rebind_pointer + < bucket_type >::type bucket_ptr; + typedef typename slist_impl::iterator siterator; + typedef typename slist_impl::const_iterator const_siterator; + typedef detail::hashtable_iterator<hashtable_impl, false> iterator; + typedef detail::hashtable_iterator<hashtable_impl, true> const_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename pointer_traits + <pointer>::template rebind_pointer + < node >::type node_ptr; + typedef typename pointer_traits + <pointer>::template rebind_pointer + < const node >::type const_node_ptr; + typedef typename slist_impl::node_algorithms node_algorithms; + + static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + static const bool store_hash = detail::store_hash_is_true<node_traits>::value; + + static const bool unique_keys = 0 != (Config::bool_flags & detail::hash_bool_flags::unique_keys_pos); + static const bool constant_time_size = 0 != (Config::bool_flags & detail::hash_bool_flags::constant_time_size_pos); + static const bool cache_begin = 0 != (Config::bool_flags & detail::hash_bool_flags::cache_begin_pos); + static const bool compare_hash = 0 != (Config::bool_flags & detail::hash_bool_flags::compare_hash_pos); + static const bool incremental = 0 != (Config::bool_flags & detail::hash_bool_flags::incremental_pos); + static const bool power_2_buckets = incremental || (0 != (Config::bool_flags & detail::hash_bool_flags::power_2_buckets_pos)); + + static const bool optimize_multikey + = detail::optimize_multikey_is_true<node_traits>::value && !unique_keys; + + /// @cond + private: + + //Configuration error: compare_hash<> can't be specified without store_hash<> + //See documentation for more explanations + BOOST_STATIC_ASSERT((!compare_hash || store_hash)); + + typedef typename slist_impl::node_ptr slist_node_ptr; + typedef typename pointer_traits + <slist_node_ptr>::template rebind_pointer + < void >::type void_pointer; + //We'll define group traits, but these won't be instantiated if + //optimize_multikey is not true + typedef unordered_group_adapter<node_traits> group_traits; + typedef circular_slist_algorithms<group_traits> group_algorithms; + typedef detail::bool_<store_hash> store_hash_t; + typedef detail::bool_<optimize_multikey> optimize_multikey_t; + typedef detail::bool_<cache_begin> cache_begin_t; + typedef detail::bool_<power_2_buckets> power_2_buckets_t; + typedef detail::size_holder<constant_time_size, size_type> size_traits; + typedef detail::size_holder<incremental, size_type> split_traits; + typedef detail::group_functions<node_traits> group_functions_t; + typedef detail::node_functions<node_traits> node_functions_t; + + static const std::size_t hashtable_data_bool_flags_mask = + ( detail::hash_bool_flags::cache_begin_pos + | detail::hash_bool_flags::constant_time_size_pos + | detail::hash_bool_flags::incremental_pos + ); + typedef typename detail::usetopt_mask + <Config, hashtable_data_bool_flags_mask>::type masked_config_t; + detail::hashtable_data_t<masked_config_t> data_; + + template<bool IsConst> + struct downcast_node_to_value + : public detail::node_to_value<hashtable_impl, IsConst> + { + typedef detail::node_to_value<hashtable_impl, IsConst> base_t; + typedef typename base_t::result_type result_type; + typedef typename detail::add_const_if_c + <typename slist_impl::node, IsConst>::type &first_argument_type; + typedef typename detail::add_const_if_c + <node, IsConst>::type &intermediate_argument_type; + + downcast_node_to_value(const hashtable_impl *cont) + : base_t(cont) + {} + + result_type operator()(first_argument_type arg) const + { return this->base_t::operator()(static_cast<intermediate_argument_type>(arg)); } + }; + + template<class F> + struct node_cast_adaptor + : private detail::ebo_functor_holder<F> + { + typedef detail::ebo_functor_holder<F> base_t; + + template<class ConvertibleToF> + node_cast_adaptor(const ConvertibleToF &c2f, const hashtable_impl *cont) + : base_t(base_t(c2f, cont)) + {} + + typename base_t::node_ptr operator()(const typename slist_impl::node &to_clone) + { return base_t::operator()(static_cast<const node &>(to_clone)); } + + void operator()(typename slist_impl::node_ptr to_clone) + { + base_t::operator()(pointer_traits<node_ptr>::pointer_to(static_cast<node &>(*to_clone))); + } + }; + + private: + //noncopyable, movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + //Constant-time size is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink))); + //Cache begin is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(cache_begin && ((int)real_value_traits::link_mode == (int)auto_unlink))); + + template<class Disposer> + node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> > + make_node_disposer(const Disposer &disposer) const + { return node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> >(disposer, this); } + + /// @endcond + + public: + typedef detail::insert_commit_data_impl insert_commit_data; + + typedef detail::transform_iterator + < typename slist_impl::iterator + , downcast_node_to_value<false> > local_iterator; + + typedef detail::transform_iterator + < typename slist_impl::iterator + , downcast_node_to_value<true> > const_local_iterator; + + /// @cond + + const real_value_traits &get_real_value_traits(detail::false_) const + { return this->data_; } + + const real_value_traits &get_real_value_traits(detail::true_) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::false_) + { return this->data_; } + + real_value_traits &get_real_value_traits(detail::true_) + { return data_.get_value_traits(*this); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + //! <b>Requires</b>: buckets must not be being used by any other resource. + //! + //! <b>Effects</b>: Constructs an empty unordered_set, storing a reference + //! to the bucket array and copies of the key_hasher and equal_func functors. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor or invocation of hash_func or equal_func throws. + //! + //! <b>Notes</b>: buckets array must be disposed only after + //! *this is disposed. + hashtable_impl ( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : data_(b_traits, hash_func, equal_func, v_traits) + { + priv_initialize_buckets(); + this->priv_size_traits().set_size(size_type(0)); + size_type bucket_size = this->priv_buckets_len(); + BOOST_INTRUSIVE_INVARIANT_ASSERT(bucket_size != 0); + //Check power of two bucket array if the option is activated + BOOST_INTRUSIVE_INVARIANT_ASSERT + (!power_2_buckets || (0 == (bucket_size & (bucket_size-1)))); + priv_split_traits().set_size(bucket_size>>1); + } + + //! <b>Effects</b>: to-do + //! + hashtable_impl(BOOST_RV_REF(hashtable_impl) x) + : data_( ::boost::move(x.priv_bucket_traits()) + , ::boost::move(x.priv_hasher()) + , ::boost::move(x.priv_equal()) + , ::boost::move(x.priv_value_traits()) + ) + { + priv_swap_cache(cache_begin_t(), x); + x.priv_initialize_cache(); + if(constant_time_size){ + this->priv_size_traits().set_size(size_type(0)); + this->priv_size_traits().set_size(x.priv_size_traits().get_size()); + x.priv_size_traits().set_size(size_type(0)); + } + if(incremental){ + this->priv_split_traits().set_size(x.priv_split_traits().get_size()); + x.priv_split_traits().set_size(size_type(0)); + } + } + + //! <b>Effects</b>: to-do + //! + hashtable_impl& operator=(BOOST_RV_REF(hashtable_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the unordered_set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements in the unordered_set, if + //! it's a safe-mode or auto-unlink value. Otherwise constant. + //! + //! <b>Throws</b>: Nothing. + ~hashtable_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the unordered_set. + //! + //! <b>Complexity</b>: Amortized constant time. + //! Worst case (empty unordered_set): O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return iterator(this->priv_begin(), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning + //! of the unordered_set. + //! + //! <b>Complexity</b>: Amortized constant time. + //! Worst case (empty unordered_set): O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return this->cbegin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning + //! of the unordered_set. + //! + //! <b>Complexity</b>: Amortized constant time. + //! Worst case (empty unordered_set): O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return const_iterator(this->priv_begin(), this); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return iterator(priv_invalid_local_it(), 0); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return this->cend(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return const_iterator(priv_invalid_local_it(), 0); } + + //! <b>Effects</b>: Returns the hasher object used by the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If hasher copy-constructor throws. + hasher hash_function() const + { return this->priv_hasher(); } + + //! <b>Effects</b>: Returns the key_equal object used by the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_equal copy-constructor throws. + key_equal key_eq() const + { return this->priv_equal(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: if constant-time size and cache_begin options are disabled, + //! average constant time (worst case, with empty() == true: O(this->bucket_count()). + //! Otherwise constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { + if(constant_time_size){ + return !this->size(); + } + else if(cache_begin){ + return this->begin() == this->end(); + } + else{ + size_type buckets_len = this->priv_buckets_len(); + const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_buckets()); + for (size_type n = 0; n < buckets_len; ++n, ++b){ + if(!b->empty()){ + return false; + } + } + return true; + } + } + + //! <b>Effects</b>: Returns the number of elements stored in the unordered_set. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if + //! constant_time_size is false. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { + if(constant_time_size) + return this->priv_size_traits().get_size(); + else{ + size_type len = 0; + size_type buckets_len = this->priv_buckets_len(); + const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_buckets()); + for (size_type n = 0; n < buckets_len; ++n, ++b){ + len += b->size(); + } + return len; + } + } + + //! <b>Requires</b>: the hasher and the equality function unqualified swap + //! call should not throw. + //! + //! <b>Effects</b>: Swaps the contents of two unordered_sets. + //! Swaps also the contained bucket array and equality and hasher functors. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison or hash functors + //! found using ADL throw. Basic guarantee. + void swap(hashtable_impl& other) + { + using std::swap; + //These can throw + swap(this->priv_equal(), other.priv_equal()); + swap(this->priv_hasher(), other.priv_hasher()); + //These can't throw + swap(this->priv_bucket_traits(), other.priv_bucket_traits()); + swap(this->priv_value_traits(), other.priv_value_traits()); + priv_swap_cache(cache_begin_t(), other); + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + if(incremental){ + size_type backup = this->priv_split_traits().get_size(); + this->priv_split_traits().set_size(other.priv_split_traits().get_size()); + other.priv_split_traits().set_size(backup); + } + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw + //! Cloner should yield to nodes that compare equal and produce the same + //! hash than the original node. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. The hash function and the equality + //! predicate are copied from the source. + //! + //! If store_hash option is true, this method does not use the hash function. + //! + //! If any operation throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner or hasher throw or hash or equality predicate copying + //! throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const hashtable_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + if(!constant_time_size || !src.empty()){ + const size_type src_bucket_count = src.bucket_count(); + const size_type dst_bucket_count = this->bucket_count(); + //Check power of two bucket array if the option is activated + BOOST_INTRUSIVE_INVARIANT_ASSERT + (!power_2_buckets || (0 == (src_bucket_count & (src_bucket_count-1)))); + BOOST_INTRUSIVE_INVARIANT_ASSERT + (!power_2_buckets || (0 == (dst_bucket_count & (dst_bucket_count-1)))); + + //If src bucket count is bigger or equal, structural copy is possible + if(!incremental && (src_bucket_count >= dst_bucket_count)){ + //First clone the first ones + const bucket_ptr src_buckets = src.priv_buckets(); + const bucket_ptr dst_buckets = this->priv_buckets(); + size_type constructed; + typedef node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> > NodeDisposer; + typedef node_cast_adaptor<detail::node_cloner<Cloner, hashtable_impl> > NodeCloner; + NodeDisposer node_disp(disposer, this); + + detail::exception_array_disposer<bucket_type, NodeDisposer, size_type> + rollback(dst_buckets[0], node_disp, constructed); + for( constructed = 0 + ; constructed < dst_bucket_count + ; ++constructed){ + dst_buckets[constructed].clone_from + ( src_buckets[constructed] + , NodeCloner(cloner, this), node_disp); + } + if(src_bucket_count != dst_bucket_count){ + //Now insert the remaining ones using the modulo trick + for(//"constructed" comes from the previous loop + ; constructed < src_bucket_count + ; ++constructed){ + bucket_type &dst_b = + dst_buckets[priv_hash_to_bucket(constructed, dst_bucket_count, dst_bucket_count)]; + bucket_type &src_b = src_buckets[constructed]; + for( siterator b(src_b.begin()), e(src_b.end()) + ; b != e + ; ++b){ + dst_b.push_front(*(NodeCloner(cloner, this)(*b.pointed_node()))); + } + } + } + this->priv_hasher() = src.priv_hasher(); + this->priv_equal() = src.priv_equal(); + rollback.release(); + this->priv_size_traits().set_size(src.priv_size_traits().get_size()); + this->priv_split_traits().set_size(dst_bucket_count); + priv_insertion_update_cache(0u); + priv_erasure_update_cache(); + } + else if(store_hash){ + //Unlike previous cloning algorithm, this can throw + //if cloner, hasher or comparison functor throw + const_iterator b(src.begin()), e(src.end()); + detail::exception_disposer<hashtable_impl, Disposer> + rollback(*this, disposer); + for(; b != e; ++b){ + std::size_t hash_value = this->priv_stored_or_compute_hash(*b, store_hash_t());; + this->priv_insert_equal_with_hash(*cloner(*b), hash_value); + } + rollback.release(); + } + else{ + //Unlike previous cloning algorithm, this can throw + //if cloner, hasher or comparison functor throw + const_iterator b(src.begin()), e(src.end()); + detail::exception_disposer<hashtable_impl, Disposer> + rollback(*this, disposer); + for(; b != e; ++b){ + this->insert_equal(*cloner(*b)); + } + rollback.release(); + } + } + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts the value into the unordered_set. + //! + //! <b>Returns</b>: An iterator to the inserted value. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(reference value) + { + size_type bucket_num; + std::size_t hash_value; + siterator prev; + siterator it = this->priv_find + (value, this->priv_hasher(), this->priv_equal(), bucket_num, hash_value, prev); + return priv_insert_equal_find(value, bucket_num, hash_value, it); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Equivalent to this->insert_equal(t) for each element in [b, e). + //! + //! <b>Complexity</b>: Average case O(N), where N is std::distance(b, e). + //! Worst case O(N*this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_equal(Iterator b, Iterator e) + { + for (; b != e; ++b) + this->insert_equal(*b); + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to inserts value into the unordered_set. + //! + //! <b>Returns</b>: If the value + //! is not already present inserts it and returns a pair containing the + //! iterator to the new value and true. If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert_unique(reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = this->insert_unique_check + (value, this->priv_hasher(), this->priv_equal(), commit_data); + if(!ret.second) + return ret; + return std::pair<iterator, bool> + (this->insert_unique_commit(value, commit_data), true); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Equivalent to this->insert_unique(t) for each element in [b, e). + //! + //! <b>Complexity</b>: Average case O(N), where N is std::distance(b, e). + //! Worst case O(N*this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_unique(Iterator b, Iterator e) + { + for (; b != e; ++b) + this->insert_unique(*b); + } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the unordered_set, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the hash or the equality is much cheaper to + //! construct than the value_type and this function offers the possibility to + //! use that the part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the unordered_set. + //! + //! After a successful rehashing insert_commit_data remains valid. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<iterator, bool> insert_unique_check + ( const KeyType &key + , KeyHasher hash_func + , KeyValueEqual equal_func + , insert_commit_data &commit_data) + { + size_type bucket_num; + siterator prev; + siterator prev_pos = + this->priv_find(key, hash_func, equal_func, bucket_num, commit_data.hash, prev); + bool success = prev_pos == priv_invalid_local_it(); + if(success){ + prev_pos = prev; + } + return std::pair<iterator, bool>(iterator(prev_pos, this),success); + } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the unordered_set between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the unordered_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + //! + //! After a successful rehashing insert_commit_data remains valid. + iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) + { + size_type bucket_num = priv_hash_to_bucket(commit_data.hash); + bucket_type &b = this->priv_buckets()[bucket_num]; + this->priv_size_traits().increment(); + node_ptr n = pointer_traits<node_ptr>::pointer_to(priv_value_to_node(value)); + node_functions_t::store_hash(n, commit_data.hash, store_hash_t()); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n)); + priv_insertion_update_cache(bucket_num); + group_functions_t::insert_in_group(node_ptr(), n, optimize_multikey_t()); + return iterator(b.insert_after(b.before_begin(), *n), this); + } + + //! <b>Effects</b>: Erases the element pointed to by i. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased element. No destructors are called. + void erase(const_iterator i) + { this->erase_and_dispose(i, detail::null_disposer()); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average case O(std::distance(b, e)), + //! worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void erase(const_iterator b, const_iterator e) + { this->erase_and_dispose(b, e, detail::null_disposer()); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + //! Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return this->erase(value, this->priv_hasher(), this->priv_equal()); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Erases all the elements that have the same hash and + //! compare equal with the given key. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyHasher, class KeyValueEqual> + size_type erase(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) + { return this->erase_and_dispose(key, hash_func, equal_func, detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by i. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + void erase_and_dispose(const_iterator i, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + priv_erase(i, disposer, optimize_multikey_t()); + this->priv_size_traits().decrement(); + priv_erasure_update_cache(); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average case O(std::distance(b, e)), + //! worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { + if(b != e){ + //Get the bucket number and local iterator for both iterators + siterator first_local_it(b.slist_it()); + size_type first_bucket_num = this->priv_get_bucket_num(first_local_it); + + siterator before_first_local_it + = priv_get_previous(priv_buckets()[first_bucket_num], first_local_it); + size_type last_bucket_num; + siterator last_local_it; + + //For the end iterator, we will assign the end iterator + //of the last bucket + if(e == this->end()){ + last_bucket_num = this->bucket_count() - 1; + last_local_it = priv_buckets()[last_bucket_num].end(); + } + else{ + last_local_it = e.slist_it(); + last_bucket_num = this->priv_get_bucket_num(last_local_it); + } + priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer); + priv_erasure_update_cache(first_bucket_num, last_bucket_num); + } + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + //! Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return this->erase_and_dispose(value, priv_hasher(), priv_equal(), disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "equal_func". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyHasher, class KeyValueEqual, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func + ,KeyValueEqual equal_func, Disposer disposer) + { + size_type bucket_num; + std::size_t h; + siterator prev; + siterator it = + this->priv_find(key, hash_func, equal_func, bucket_num, h, prev); + bool success = it != priv_invalid_local_it(); + size_type count(0); + if(!success){ + return 0; + } + else if(optimize_multikey){ + siterator last = bucket_type::s_iterator_to + (*node_traits::get_next(group_functions_t::get_last_in_group + (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); + this->priv_erase_range_impl(bucket_num, prev, last, disposer, count); + } + else{ + //If found erase all equal values + bucket_type &b = this->priv_buckets()[bucket_num]; + for(siterator end = b.end(); it != end; ++count, ++it){ + slist_node_ptr n(it.pointed_node()); + const value_type &v = priv_value_from_slist_node(n); + if(compare_hash){ + std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t()); + if(h != vh || !equal_func(key, v)){ + break; + } + } + else if(!equal_func(key, v)){ + break; + } + this->priv_size_traits().decrement(); + } + b.erase_after_and_dispose(prev, it, make_node_disposer(disposer)); + } + priv_erasure_update_cache(); + return count; + } + + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { + priv_clear_buckets(); + this->priv_size_traits().set_size(size_type(0)); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { + if(!constant_time_size || !this->empty()){ + size_type num_buckets = this->bucket_count(); + bucket_ptr b = this->priv_buckets(); + for(; num_buckets--; ++b){ + b->clear_and_dispose(make_node_disposer(disposer)); + } + this->priv_size_traits().set_size(size_type(0)); + } + priv_initialize_cache(); + } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + size_type count(const_reference value) const + { return this->count(value, this->priv_hasher(), this->priv_equal()); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal throw. + template<class KeyType, class KeyHasher, class KeyValueEqual> + size_type count(const KeyType &key, const KeyHasher &hash_func, const KeyValueEqual &equal_func) const + { + size_type bucket_n1, bucket_n2, count; + this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, count); + return count; + } + + //! <b>Effects</b>: Finds an iterator to the first element is equal to + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + iterator find(const_reference value) + { return this->find(value, this->priv_hasher(), this->priv_equal()); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the given hash and equality functor or end() if + //! that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + iterator find(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) + { + size_type bucket_n; + std::size_t hash; + siterator prev; + siterator local_it = this->priv_find(key, hash_func, equal_func, bucket_n, hash, prev); + return iterator(local_it, this); + } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + const_iterator find(const_reference value) const + { return this->find(value, this->priv_hasher(), this->priv_equal()); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the given hasher and equality functor or end() if + //! that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + const_iterator find + (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const + { + size_type bucket_n; + std::size_t hash_value; + siterator prev; + siterator sit = this->priv_find(key, hash_func, equal_func, bucket_n, hash_value, prev); + return const_iterator(sit, this); + } + + //! <b>Effects</b>: Returns a range containing all elements with values equivalent + //! to value. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return this->equal_range(value, this->priv_hasher(), this->priv_equal()); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns a range containing all elements with equivalent + //! keys. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or the equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<iterator,iterator> equal_range + (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) + { + size_type bucket_n1, bucket_n2, count; + std::pair<siterator, siterator> ret = this->priv_equal_range + (key, hash_func, equal_func, bucket_n1, bucket_n2, count); + return std::pair<iterator, iterator> + (iterator(ret.first, this), iterator(ret.second, this)); + } + + //! <b>Effects</b>: Returns a range containing all elements with values equivalent + //! to value. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return this->equal_range(value, this->priv_hasher(), this->priv_equal()); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns a range containing all elements with equivalent + //! keys. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the hasher or equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<const_iterator,const_iterator> equal_range + (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const + { + size_type bucket_n1, bucket_n2, count; + std::pair<siterator, siterator> ret = + this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, count); + return std::pair<const_iterator, const_iterator> + (const_iterator(ret.first, this), const_iterator(ret.second, this)); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the internal hash function throws. + iterator iterator_to(reference value) + { + return iterator(bucket_type::s_iterator_to(priv_value_to_node(value)), this); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator belonging to the + //! unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the internal hash function throws. + const_iterator iterator_to(const_reference value) const + { + siterator sit = bucket_type::s_iterator_to(const_cast<node &>(this->priv_value_to_node(value))); + return const_iterator(sit, this); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static local_iterator s_local_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + siterator sit = bucket_type::s_iterator_to(((hashtable_impl*)0)->priv_value_to_node(value)); + return local_iterator(sit, (hashtable_impl*)0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to + //! the unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_local_iterator s_local_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + siterator sit = bucket_type::s_iterator_to(((hashtable_impl*)0)->priv_value_to_node(const_cast<value_type&>(value))); + return const_local_iterator(sit, (hashtable_impl*)0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + local_iterator local_iterator_to(reference value) + { + siterator sit = bucket_type::s_iterator_to(this->priv_value_to_node(value)); + return local_iterator(sit, this); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to + //! the unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_local_iterator local_iterator_to(const_reference value) const + { + siterator sit = bucket_type::s_iterator_to + (const_cast<node &>(this->priv_value_to_node(value))); + return const_local_iterator(sit, this); + } + + //! <b>Effects</b>: Returns the number of buckets passed in the constructor + //! or the last rehash function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + size_type bucket_count() const + { return this->priv_buckets_len(); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns the number of elements in the nth bucket. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + size_type bucket_size(size_type n) const + { return this->priv_buckets()[n].size(); } + + //! <b>Effects</b>: Returns the index of the bucket in which elements + //! with keys equivalent to k would be found, if any such element existed. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the hash functor throws. + //! + //! <b>Note</b>: the return value is in the range [0, this->bucket_count()). + size_type bucket(const key_type& k) const + { return this->bucket(k, this->priv_hasher()); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! <b>Effects</b>: Returns the index of the bucket in which elements + //! with keys equivalent to k would be found, if any such element existed. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If hash_func throws. + //! + //! <b>Note</b>: the return value is in the range [0, this->bucket_count()). + template<class KeyType, class KeyHasher> + size_type bucket(const KeyType& k, const KeyHasher &hash_func) const + { return priv_hash_to_bucket(hash_func(k)); } + + //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor + //! or the last rehash function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bucket_ptr bucket_pointer() const + { return this->priv_buckets(); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + local_iterator begin(size_type n) + { return local_iterator(this->priv_buckets()[n].begin(), this); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator begin(size_type n) const + { return this->cbegin(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator cbegin(size_type n) const + { + siterator sit = const_cast<bucket_type&>(this->priv_buckets()[n]).begin(); + return const_local_iterator(sit, this); + } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + local_iterator end(size_type n) + { return local_iterator(this->priv_buckets()[n].end(), this); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator end(size_type n) const + { return this->cend(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator cend(size_type n) const + { return const_local_iterator(const_cast<bucket_type&>(this->priv_buckets()[n]).end(), this); } + + //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array + //! or the same as the old bucket array. new_size is the length of the + //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer() + //! n can be bigger or smaller than this->bucket_count(). + //! 'new_bucket_traits' copy constructor should not throw. + //! + //! <b>Effects</b>: Updates the internal reference with the new bucket erases + //! the values from the old bucket and inserts then in the new one. + //! Bucket traits hold by *this is assigned from new_bucket_traits. + //! If the container is configured as incremental<>, the split bucket is set + //! to the new bucket_len(). + //! + //! If store_hash option is true, this method does not use the hash function. + //! + //! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic. + //! + //! <b>Throws</b>: If the hasher functor throws. Basic guarantee. + void rehash(const bucket_traits &new_bucket_traits) + { + bucket_ptr new_buckets = new_bucket_traits.bucket_begin(); + size_type new_buckets_len = new_bucket_traits.bucket_count(); + bucket_ptr old_buckets = this->priv_buckets(); + size_type old_buckets_len = this->priv_buckets_len(); + + //Check power of two bucket array if the option is activated + BOOST_INTRUSIVE_INVARIANT_ASSERT + (!power_2_buckets || (0 == (new_buckets_len & (new_buckets_len-1u)))); + + size_type n = priv_get_cache_bucket_num(); + const bool same_buffer = old_buckets == new_buckets; + //If the new bucket length is a common factor + //of the old one we can avoid hash calculations. + const bool fast_shrink = (!incremental) && (old_buckets_len > new_buckets_len) && + (power_2_buckets ||(old_buckets_len % new_buckets_len) == 0); + //If we are shrinking the same bucket array and it's + //is a fast shrink, just rehash the last nodes + size_type new_first_bucket_num = new_buckets_len; + if(same_buffer && fast_shrink && (n < new_buckets_len)){ + n = new_buckets_len; + new_first_bucket_num = priv_get_cache_bucket_num(); + } + + //Anti-exception stuff: they destroy the elements if something goes wrong. + //If the source and destination buckets are the same, the second rollback function + //is harmless, because all elements have been already unlinked and destroyed + typedef detail::init_disposer<node_algorithms> NodeDisposer; + NodeDisposer node_disp; + bucket_type & newbuck = new_buckets[0]; + bucket_type & oldbuck = old_buckets[0]; + detail::exception_array_disposer<bucket_type, NodeDisposer, size_type> + rollback1(newbuck, node_disp, new_buckets_len); + detail::exception_array_disposer<bucket_type, NodeDisposer, size_type> + rollback2(oldbuck, node_disp, old_buckets_len); + + //Put size in a safe value for rollback exception + size_type size_backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(0); + //Put cache to safe position + priv_initialize_cache(); + priv_insertion_update_cache(size_type(0u)); + + //Iterate through nodes + for(; n < old_buckets_len; ++n){ + bucket_type &old_bucket = old_buckets[n]; + + if(!fast_shrink){ + siterator before_i(old_bucket.before_begin()); + siterator end(old_bucket.end()); + siterator i(old_bucket.begin()); + for(;i != end; ++i){ + const value_type &v = priv_value_from_slist_node(i.pointed_node()); + const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t()); + const size_type new_n = priv_hash_to_bucket(hash_value, new_buckets_len, new_buckets_len); + if(cache_begin && new_n < new_first_bucket_num) + new_first_bucket_num = new_n; + siterator last = bucket_type::s_iterator_to + (*group_functions_t::get_last_in_group + (dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); + if(same_buffer && new_n == n){ + before_i = last; + } + else{ + bucket_type &new_b = new_buckets[new_n]; + new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last); + } + i = before_i; + } + } + else{ + const size_type new_n = priv_hash_to_bucket(n, new_buckets_len, new_buckets_len); + if(cache_begin && new_n < new_first_bucket_num) + new_first_bucket_num = new_n; + bucket_type &new_b = new_buckets[new_n]; + if(!old_bucket.empty()){ + new_b.splice_after( new_b.before_begin() + , old_bucket + , old_bucket.before_begin() + , priv_get_last(old_bucket)); + } + } + } + + this->priv_size_traits().set_size(size_backup); + this->priv_split_traits().set_size(new_buckets_len); + this->priv_real_bucket_traits() = new_bucket_traits; + priv_initialize_cache(); + priv_insertion_update_cache(new_first_bucket_num); + rollback1.release(); + rollback2.release(); + } + + //! <b>Requires</b>: + //! + //! <b>Effects</b>: + //! + //! <b>Complexity</b>: + //! + //! <b>Throws</b>: + //! + //! <b>Note</b>: this method is only available if incremental<true> option is activated. + bool incremental_rehash(bool grow = true) + { + //This function is only available for containers with incremental hashing + BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); + size_type split_idx = priv_split_traits().get_size(); + size_type bucket_len = priv_buckets_len(); + + if(grow){ + //Test if the split variable can be changed + if(split_idx >= bucket_len) + return false; + + size_type bucket_len = priv_buckets_len(); + size_type bucket_to_rehash = split_idx - bucket_len/2; + bucket_type &old_bucket = this->priv_buckets()[bucket_to_rehash]; + siterator before_i(old_bucket.before_begin()); + siterator end(old_bucket.end()); + siterator i(old_bucket.begin()); + priv_split_traits().increment(); + + //Anti-exception stuff: if an exception is thrown while + //moving elements from old_bucket to the target bucket, all moved + //elements are moved back to the original one. + detail::incremental_rehash_rollback<bucket_type, split_traits> rollback + ( this->priv_buckets()[split_idx], old_bucket, priv_split_traits()); + for(;i != end; ++i){ + const value_type &v = priv_value_from_slist_node(i.pointed_node()); + const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t()); + const size_type new_n = priv_hash_to_bucket(hash_value); + siterator last = bucket_type::s_iterator_to + (*group_functions_t::get_last_in_group + (dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); + if(new_n == bucket_to_rehash){ + before_i = last; + } + else{ + bucket_type &new_b = this->priv_buckets()[new_n]; + new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last); + } + i = before_i; + } + rollback.release(); + priv_erasure_update_cache(); + return true; + } + else{ + //Test if the split variable can be changed + if(split_idx <= bucket_len/2) + return false; + const size_type target_bucket_num = split_idx - 1 - bucket_len/2; + bucket_type &target_bucket = this->priv_buckets()[target_bucket_num]; + bucket_type &source_bucket = this->priv_buckets()[split_idx-1]; + target_bucket.splice_after(target_bucket.cbefore_begin(), source_bucket); + priv_split_traits().decrement(); + priv_insertion_update_cache(target_bucket_num); + return true; + } + } + + //! <b>Effects</b>: If new_bucket_traits.bucket_count() is not + //! this->bucket_count()/2 or this->bucket_count()*2, or + //! this->split_bucket() != new_bucket_traits.bucket_count() returns false + //! and does nothing. + //! + //! Otherwise, copy assigns new_bucket_traits to the internal bucket_traits + //! and transfers all the objects from old buckets to the new ones. + //! + //! <b>Complexity</b>: Linear to size(). + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Note</b>: this method is only available if incremental<true> option is activated. + bool incremental_rehash(const bucket_traits &new_bucket_traits) + { + //This function is only available for containers with incremental hashing + BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); + size_type new_bucket_traits_size = new_bucket_traits.bucket_count(); + size_type cur_bucket_traits = this->priv_buckets_len(); + if(new_bucket_traits_size/2 != cur_bucket_traits && new_bucket_traits_size != cur_bucket_traits/2){ + return false; + } + + const size_type split_idx = this->split_count(); + + if(new_bucket_traits_size/2 == cur_bucket_traits){ + //Test if the split variable can be changed + if(!(split_idx >= cur_bucket_traits)) + return false; + } + else{ + //Test if the split variable can be changed + if(!(split_idx <= cur_bucket_traits/2)) + return false; + } + + const size_type ini_n = priv_get_cache_bucket_num(); + const bucket_ptr old_buckets = this->priv_buckets(); + this->priv_real_bucket_traits() = new_bucket_traits; + if(new_bucket_traits.bucket_begin() != old_buckets){ + for(size_type n = ini_n; n < split_idx; ++n){ + bucket_type &new_bucket = new_bucket_traits.bucket_begin()[n]; + bucket_type &old_bucket = old_buckets[n]; + new_bucket.splice_after(new_bucket.cbefore_begin(), old_bucket); + } + //Put cache to safe position + priv_initialize_cache(); + priv_insertion_update_cache(ini_n); + } + return true; + } + + //! <b>Requires</b>: + //! + //! <b>Effects</b>: + //! + //! <b>Complexity</b>: + //! + //! <b>Throws</b>: + size_type split_count() const + { + //This function is only available if incremental hashing is activated + BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); + return this->priv_split_traits().get_size(); + } + + //! <b>Effects</b>: Returns the nearest new bucket count optimized for + //! the container that is bigger or equal than n. This suggestion can be + //! used to create bucket arrays with a size that will usually improve + //! container's performance. If such value does not exist, the + //! higher possible value is returned. + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static size_type suggested_upper_bucket_count(size_type n) + { + const std::size_t *primes = &detail::prime_list_holder<0>::prime_list[0]; + const std::size_t *primes_end = primes + detail::prime_list_holder<0>::prime_list_size; + std::size_t const* bound = std::lower_bound(primes, primes_end, n); + if(bound == primes_end) + --bound; + return size_type(*bound); + } + + //! <b>Effects</b>: Returns the nearest new bucket count optimized for + //! the container that is smaller or equal than n. This suggestion can be + //! used to create bucket arrays with a size that will usually improve + //! container's performance. If such value does not exist, the + //! lowest possible value is returned. + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static size_type suggested_lower_bucket_count(size_type n) + { + const std::size_t *primes = &detail::prime_list_holder<0>::prime_list[0]; + const std::size_t *primes_end = primes + detail::prime_list_holder<0>::prime_list_size; + size_type const* bound = std::upper_bound(primes, primes_end, n); + if(bound != primes) + --bound; + return size_type(*bound); + } + + /// @cond + private: + + std::size_t priv_hash_to_bucket(std::size_t hash_value) const + { return priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), priv_split_traits().get_size()); } + + std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_len, std::size_t split) const + { + std::size_t bucket_number = priv_hash_to_bucket_impl(hash_value, bucket_len, power_2_buckets_t()); + if(incremental) + if(bucket_number >= split) + bucket_number -= bucket_len/2; + return bucket_number; + } + + std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_len, detail::false_) const + { return hash_value % bucket_len; } + + std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_len, detail::true_) const + { return hash_value & (bucket_len - 1); } + + const key_equal &priv_equal() const + { return static_cast<const key_equal&>(this->data_.internal_.bucket_hash_equal_.get()); } + + key_equal &priv_equal() + { return static_cast<key_equal&>(this->data_.internal_.bucket_hash_equal_.get()); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + value_type &priv_value_from_slist_node(slist_node_ptr n) + { return *this->get_real_value_traits().to_value_ptr(dcast_bucket_ptr(n)); } + + const value_type &priv_value_from_slist_node(slist_node_ptr n) const + { return *this->get_real_value_traits().to_value_ptr(dcast_bucket_ptr(n)); } + + const real_bucket_traits &priv_real_bucket_traits(detail::false_) const + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; } + + const real_bucket_traits &priv_real_bucket_traits(detail::true_) const + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_.get_bucket_traits(*this); } + + real_bucket_traits &priv_real_bucket_traits(detail::false_) + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; } + + real_bucket_traits &priv_real_bucket_traits(detail::true_) + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_.get_bucket_traits(*this); } + + const real_bucket_traits &priv_real_bucket_traits() const + { return this->priv_real_bucket_traits(detail::bool_<external_bucket_traits>()); } + + real_bucket_traits &priv_real_bucket_traits() + { return this->priv_real_bucket_traits(detail::bool_<external_bucket_traits>()); } + + const bucket_traits &priv_bucket_traits() const + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; } + + bucket_traits &priv_bucket_traits() + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; } + + const hasher &priv_hasher() const + { return static_cast<const hasher&>(this->data_.internal_.bucket_hash_equal_.bucket_hash.get()); } + + hasher &priv_hasher() + { return static_cast<hasher&>(this->data_.internal_.bucket_hash_equal_.bucket_hash.get()); } + + bucket_ptr priv_buckets() const + { return this->priv_real_bucket_traits().bucket_begin(); } + + size_type priv_buckets_len() const + { return this->priv_real_bucket_traits().bucket_count(); } + + static node_ptr uncast(const const_node_ptr & ptr) + { return node_ptr(const_cast<node*>(boost::intrusive::detail::to_raw_pointer(ptr))); } + + node &priv_value_to_node(value_type &v) + { return *this->get_real_value_traits().to_node_ptr(v); } + + const node &priv_value_to_node(const value_type &v) const + { return *this->get_real_value_traits().to_node_ptr(v); } + + size_traits &priv_size_traits() + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_; } + + const size_traits &priv_size_traits() const + { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_; } + + split_traits &priv_split_traits() + { return this->data_.internal_; } + + const split_traits &priv_split_traits() const + { return this->data_.internal_; } + + template<class Disposer> + void priv_erase_range_impl + (size_type bucket_num, siterator before_first_it, siterator end, Disposer disposer, size_type &num_erased) + { + const bucket_ptr buckets = priv_buckets(); + bucket_type &b = buckets[bucket_num]; + + if(before_first_it == b.before_begin() && end == b.end()){ + priv_erase_range_impl(bucket_num, 1, disposer, num_erased); + } + else{ + num_erased = 0; + siterator to_erase(before_first_it); + ++to_erase; + slist_node_ptr end_ptr = end.pointed_node(); + while(to_erase != end){ + group_functions_t::erase_from_group(end_ptr, dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t()); + to_erase = b.erase_after_and_dispose(before_first_it, make_node_disposer(disposer)); + ++num_erased; + } + this->priv_size_traits().set_size(this->priv_size_traits().get_size()-num_erased); + } + } + + template<class Disposer> + void priv_erase_range_impl + (size_type first_bucket_num, size_type num_buckets, Disposer disposer, size_type &num_erased) + { + //Now fully clear the intermediate buckets + const bucket_ptr buckets = priv_buckets(); + num_erased = 0; + for(size_type i = first_bucket_num; i < (num_buckets + first_bucket_num); ++i){ + bucket_type &b = buckets[i]; + siterator b_begin(b.before_begin()); + siterator nxt(b_begin); + ++nxt; + siterator end(b.end()); + while(nxt != end){ + group_functions_t::init_group(dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t()); + nxt = b.erase_after_and_dispose + (b_begin, make_node_disposer(disposer)); + this->priv_size_traits().decrement(); + ++num_erased; + } + } + } + + template<class Disposer> + void priv_erase_range( siterator before_first_it, size_type first_bucket + , siterator last_it, size_type last_bucket + , Disposer disposer) + { + size_type num_erased; + if (first_bucket == last_bucket){ + priv_erase_range_impl(first_bucket, before_first_it, last_it, disposer, num_erased); + } + else { + bucket_type *b = (&this->priv_buckets()[0]); + priv_erase_range_impl(first_bucket, before_first_it, b[first_bucket].end(), disposer, num_erased); + if(size_type n = (last_bucket - first_bucket - 1)) + priv_erase_range_impl(first_bucket + 1, n, disposer, num_erased); + priv_erase_range_impl(last_bucket, b[last_bucket].before_begin(), last_it, disposer, num_erased); + } + } + + static node_ptr dcast_bucket_ptr(typename slist_impl::node_ptr p) + { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*p)); } + + std::size_t priv_stored_or_compute_hash(const value_type &v, detail::true_) const + { return node_traits::get_hash(this->get_real_value_traits().to_node_ptr(v)); } + + std::size_t priv_stored_or_compute_hash(const value_type &v, detail::false_) const + { return priv_hasher()(v); } + + std::size_t priv_stored_hash(slist_node_ptr n, detail::true_) const + { return node_traits::get_hash(dcast_bucket_ptr(n)); } + + std::size_t priv_stored_hash(slist_node_ptr, detail::false_) const + { + //This code should never be reached! + BOOST_INTRUSIVE_INVARIANT_ASSERT(0); + return 0; + } + + static void priv_clear_group_nodes(bucket_type &b, detail::true_) + { + siterator it(b.begin()), itend(b.end()); + while(it != itend){ + node_ptr to_erase(dcast_bucket_ptr(it.pointed_node())); + ++it; + group_algorithms::init(to_erase); + } + } + + static void priv_clear_group_nodes(bucket_type &, detail::false_) + {} + + std::size_t priv_get_bucket_num(siterator it) + { return priv_get_bucket_num_hash_dispatch(it, store_hash_t()); } + + std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::true_) + { + return this->priv_hash_to_bucket + (this->priv_stored_hash(it.pointed_node(), store_hash_t())); + } + + std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::false_) + { return priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); } + + std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::true_) + { + bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1); + slist_node_ptr bb = group_functions_t::get_bucket_before_begin + ( f->end().pointed_node() + , l->end().pointed_node() + , dcast_bucket_ptr(it.pointed_node())); + //Now get the bucket_impl from the iterator + const bucket_type &b = static_cast<const bucket_type&> + (bucket_type::slist_type::container_from_end_iterator(bucket_type::s_iterator_to(*bb))); + //Now just calculate the index b has in the bucket array + return static_cast<size_type>(&b - &*f); + } + + std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::false_) + { + bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1); + slist_node_ptr first_ptr(f->cend().pointed_node()) + , last_ptr(l->cend().pointed_node()); + + //The end node is embedded in the singly linked list: + //iterate until we reach it. + while(!(first_ptr <= it.pointed_node() && it.pointed_node() <= last_ptr)){ + ++it; + } + //Now get the bucket_impl from the iterator + const bucket_type &b = static_cast<const bucket_type&> + (bucket_type::container_from_end_iterator(it)); + + //Now just calculate the index b has in the bucket array + return static_cast<std::size_t>(&b - &*f); + } + + siterator priv_get_previous + (bucket_type &b, siterator i) + { return priv_get_previous(b, i, optimize_multikey_t()); } + + siterator priv_get_previous + (bucket_type &b, siterator i, detail::true_) + { + node_ptr elem(dcast_bucket_ptr(i.pointed_node())); + node_ptr prev_in_group(group_traits::get_next(elem)); + bool first_in_group = node_traits::get_next(prev_in_group) != elem; + typename bucket_type::node &n = first_in_group + ? *group_functions_t::get_prev_to_first_in_group(b.end().pointed_node(), elem) + : *group_traits::get_next(elem) + ; + return bucket_type::s_iterator_to(n); + } + + siterator priv_get_previous + (bucket_type &b, siterator i, detail::false_) + { return b.previous(i); } + + static siterator priv_get_last(bucket_type &b) + { return priv_get_last(b, optimize_multikey_t()); } + + static siterator priv_get_last(bucket_type &b, detail::true_) + { + //First find the last node of p's group. + //This requires checking the first node of the next group or + //the bucket node. + slist_node_ptr end_ptr(b.end().pointed_node()); + node_ptr possible_end(node_traits::get_next( dcast_bucket_ptr(end_ptr))); + node_ptr last_node_group(possible_end); + + while(end_ptr != possible_end){ + last_node_group = group_traits::get_next(dcast_bucket_ptr(possible_end)); + possible_end = node_traits::get_next(last_node_group); + } + return bucket_type::s_iterator_to(*last_node_group); + } + + static siterator priv_get_last(bucket_type &b, detail::false_) + { return b.previous(b.end()); } +/* + siterator priv_get_previous_and_next_in_group + (siterator i, node_ptr &nxt_in_group) + { + siterator prev; + node_ptr elem(dcast_bucket_ptr(i.pointed_node())); + bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1); + + slist_node_ptr first_end_ptr(f->cend().pointed_node()); + slist_node_ptr last_end_ptr (l->cend().pointed_node()); + + node_ptr nxt(node_traits::get_next(elem)); + node_ptr prev_in_group(group_traits::get_next(elem)); + bool last_in_group = (first_end_ptr <= nxt && nxt <= last_end_ptr) || + (group_traits::get_next(nxt) != elem); + bool first_in_group = node_traits::get_next(prev_in_group) != elem; + + if(first_in_group){ + node_ptr start_pos; + if(last_in_group){ + start_pos = elem; + nxt_in_group = node_ptr(); + } + else{ + start_pos = prev_in_group; + nxt_in_group = node_traits::get_next(elem); + } + slist_node_ptr bucket_node; + if(store_hash){ + bucket_node = this->priv_buckets() + [this->priv_hash_to_bucket + (this->priv_stored_hash(elem, store_hash_t())) + ].before_begin().pointed_node(); + } + else{ + bucket_node = group_functions_t::get_bucket_before_begin + (first_end_ptr, last_end_ptr, start_pos); + } + prev = bucket_type::s_iterator_to + (*group_functions_t::get_prev_to_first_in_group(bucket_node, elem)); + } + else{ + if(last_in_group){ + nxt_in_group = group_functions_t::get_first_in_group_of_last_in_group(elem); + } + else{ + nxt_in_group = node_traits::get_next(elem); + } + prev = bucket_type::s_iterator_to(*group_traits::get_next(elem)); + } + return prev; + } +*/ + +/* + template<class Disposer> + void priv_erase(const_iterator i, Disposer disposer, detail::true_) + { + siterator elem(i.slist_it()); + node_ptr nxt_in_group; + siterator prev = priv_get_previous_and_next_in_group(elem, nxt_in_group); + bucket_type::s_erase_after_and_dispose(prev, make_node_disposer(disposer)); + if(nxt_in_group) + group_algorithms::unlink_after(nxt_in_group); + if(safemode_or_autounlink) + group_algorithms::init(dcast_bucket_ptr(elem.pointed_node())); + } +*/ + +/* + if(store_hash){ + bucket_node = this->priv_buckets() + [this->priv_hash_to_bucket + (this->priv_stored_hash(elem, store_hash_t())) + ].before_begin().pointed_node(); + } + else{ + bucket_node = group_functions_t::get_bucket_before_begin + (first_end_ptr, last_end_ptr, start_pos); + } +*/ + template<class Disposer> + void priv_erase(const_iterator i, Disposer disposer, detail::true_) + { + slist_node_ptr elem(i.slist_it().pointed_node()); + slist_node_ptr f_bucket_end, l_bucket_end; + if(store_hash){ + f_bucket_end = l_bucket_end = + (this->priv_buckets() + [this->priv_hash_to_bucket + (this->priv_stored_hash(elem, store_hash_t())) + ]).before_begin().pointed_node(); + } + else{ + f_bucket_end = this->priv_buckets()->cend().pointed_node(); + l_bucket_end = f_bucket_end + priv_buckets_len() - 1; + } + node_ptr nxt_in_group; + siterator prev = bucket_type::s_iterator_to + (*group_functions_t::get_previous_and_next_in_group + ( elem, nxt_in_group, f_bucket_end, l_bucket_end) + ); + bucket_type::s_erase_after_and_dispose(prev, make_node_disposer(disposer)); + if(nxt_in_group) + group_algorithms::unlink_after(nxt_in_group); + if(safemode_or_autounlink) + group_algorithms::init(dcast_bucket_ptr(elem)); + } + + template <class Disposer> + void priv_erase(const_iterator i, Disposer disposer, detail::false_) + { + siterator to_erase(i.slist_it()); + bucket_type &b = this->priv_buckets()[this->priv_get_bucket_num(to_erase)]; + siterator prev(priv_get_previous(b, to_erase)); + b.erase_after_and_dispose(prev, make_node_disposer(disposer)); + } + + bucket_ptr priv_invalid_bucket() const + { + const real_bucket_traits &rbt = this->priv_real_bucket_traits(); + return rbt.bucket_begin() + rbt.bucket_count(); + } + + siterator priv_invalid_local_it() const + { return priv_invalid_bucket()->end(); } + + siterator priv_begin() const + { return priv_begin(cache_begin_t()); } + + siterator priv_begin(detail::false_) const + { + size_type n = 0; + size_type buckets_len = this->priv_buckets_len(); + for (n = 0; n < buckets_len; ++n){ + bucket_type &b = this->priv_buckets()[n]; + if(!b.empty()){ + return b.begin(); + } + } + return priv_invalid_local_it(); + } + + siterator priv_begin(detail::true_) const + { + if(this->data_.internal_.bucket_hash_equal_.cached_begin_ == priv_invalid_bucket()){ + return priv_invalid_local_it(); + } + else{ + return this->data_.internal_.bucket_hash_equal_.cached_begin_->begin(); + } + } + + void priv_initialize_cache() + { priv_initialize_cache(cache_begin_t()); } + + void priv_initialize_cache(detail::true_) + { this->data_.internal_.bucket_hash_equal_.cached_begin_ = priv_invalid_bucket(); } + + void priv_initialize_cache(detail::false_) + {} + + void priv_insertion_update_cache(size_type insertion_bucket) + { priv_insertion_update_cache(insertion_bucket, cache_begin_t()); } + + void priv_insertion_update_cache(size_type insertion_bucket, detail::true_) + { + bucket_ptr p = priv_buckets() + insertion_bucket; + if(p < this->data_.internal_.bucket_hash_equal_.cached_begin_){ + this->data_.internal_.bucket_hash_equal_.cached_begin_ = p; + } + } + + void priv_insertion_update_cache(size_type, detail::false_) + {} + + void priv_erasure_update_cache(size_type first_bucket, size_type last_bucket) + { priv_erasure_update_cache(first_bucket, last_bucket, cache_begin_t()); } + + void priv_erasure_update_cache(size_type first_bucket_num, size_type last_bucket_num, detail::true_) + { + //If the last bucket is the end, the cache must be updated + //to the last position if all + if(priv_get_cache_bucket_num() == first_bucket_num && + priv_buckets()[first_bucket_num].empty() ){ + priv_set_cache(priv_buckets() + last_bucket_num); + priv_erasure_update_cache(); + } + } + + void priv_erasure_update_cache(size_type, size_type, detail::false_) + {} + + void priv_erasure_update_cache() + { priv_erasure_update_cache(cache_begin_t()); } + + void priv_erasure_update_cache(detail::true_) + { + if(constant_time_size && !size()){ + priv_initialize_cache(); + } + else{ + size_type current_n = this->data_.internal_.bucket_hash_equal_.cached_begin_ - priv_buckets(); + for( const size_type num_buckets = this->priv_buckets_len() + ; current_n < num_buckets + ; ++current_n, ++this->data_.internal_.bucket_hash_equal_.cached_begin_){ + if(!this->data_.internal_.bucket_hash_equal_.cached_begin_->empty()){ + return; + } + } + priv_initialize_cache(); + } + } + + void priv_erasure_update_cache(detail::false_) + {} + + void priv_swap_cache(detail::true_, hashtable_impl &other) + { + std::swap( this->data_.internal_.bucket_hash_equal_.cached_begin_ + , other.data_.internal_.bucket_hash_equal_.cached_begin_); + } + + void priv_swap_cache(detail::false_, hashtable_impl &) + {} + + bucket_ptr priv_get_cache() + { return priv_get_cache(cache_begin_t()); } + + bucket_ptr priv_get_cache(detail::true_) + { return this->data_.internal_.bucket_hash_equal_.cached_begin_; } + + bucket_ptr priv_get_cache(detail::false_) + { return this->priv_buckets(); } + + void priv_set_cache(const bucket_ptr &p) + { this->data_.internal_.bucket_hash_equal_.set_cache(p); } + + size_type priv_get_cache_bucket_num() + { return priv_get_cache_bucket_num(cache_begin_t()); } + + size_type priv_get_cache_bucket_num(detail::true_) + { return this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_buckets(); } + + size_type priv_get_cache_bucket_num(detail::false_) + { return 0u; } + + void priv_clear_buckets() + { + this->priv_clear_buckets + ( priv_get_cache() + , this->priv_buckets_len() - (priv_get_cache() - priv_buckets())); + } + + void priv_initialize_buckets() + { this->priv_clear_buckets(priv_buckets(), this->priv_buckets_len()); } + + void priv_clear_buckets(bucket_ptr buckets_ptr, size_type buckets_len) + { + for(; buckets_len--; ++buckets_ptr){ + if(safemode_or_autounlink){ + priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t()); + buckets_ptr->clear_and_dispose(detail::init_disposer<node_algorithms>()); + } + else{ + buckets_ptr->clear(); + } + } + priv_initialize_cache(); + } + + template<class KeyType, class KeyHasher, class KeyValueEqual> + siterator priv_find + ( const KeyType &key, KeyHasher hash_func + , KeyValueEqual equal_func, size_type &bucket_number, std::size_t &h, siterator &previt) const + { + h = hash_func(key); + return priv_find_with_hash(key, equal_func, bucket_number, h, previt); + } + + template<class KeyType, class KeyValueEqual> + siterator priv_find_with_hash + ( const KeyType &key, KeyValueEqual equal_func, size_type &bucket_number, const std::size_t h, siterator &previt) const + { + bucket_number = priv_hash_to_bucket(h); + bucket_type &b = this->priv_buckets()[bucket_number]; + previt = b.before_begin(); + if(constant_time_size && this->empty()){ + return priv_invalid_local_it(); + } + + siterator it = previt; + ++it; + + while(it != b.end()){ + const value_type &v = priv_value_from_slist_node(it.pointed_node()); + if(compare_hash){ + std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t()); + if(h == vh && equal_func(key, v)){ + return it; + } + } + else if(equal_func(key, v)){ + return it; + } + if(optimize_multikey){ + previt = bucket_type::s_iterator_to + (*group_functions_t::get_last_in_group + (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())); + it = previt; + } + else{ + previt = it; + } + ++it; + } + previt = b.before_begin(); + return priv_invalid_local_it(); + } + + iterator priv_insert_equal_with_hash(reference value, std::size_t hash_value) + { + size_type bucket_num; + siterator prev; + siterator it = this->priv_find_with_hash + (value, this->priv_equal(), bucket_num, hash_value, prev); + return priv_insert_equal_find(value, bucket_num, hash_value, it); + } + + iterator priv_insert_equal_find(reference value, size_type bucket_num, std::size_t hash_value, siterator it) + { + bucket_type &b = this->priv_buckets()[bucket_num]; + bool found_equal = it != priv_invalid_local_it(); + if(!found_equal){ + it = b.before_begin(); + } + //Now store hash if needed + node_ptr n = pointer_traits<node_ptr>::pointer_to(priv_value_to_node(value)); + node_functions_t::store_hash(n, hash_value, store_hash_t()); + //Checks for some modes + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n)); + //Shorcut for optimize_multikey cases + if(optimize_multikey){ + node_ptr first_in_group = found_equal ? + dcast_bucket_ptr(it.pointed_node()) : node_ptr(); + group_functions_t::insert_in_group(first_in_group, n, optimize_multikey_t()); + } + //Update cache and increment size if needed + priv_insertion_update_cache(bucket_num); + this->priv_size_traits().increment(); + //Insert the element in the bucket after it + return iterator(b.insert_after(it, *n), this); + } + + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<siterator, siterator> priv_equal_range + ( const KeyType &key + , KeyHasher hash_func + , KeyValueEqual equal_func + , size_type &bucket_number_first + , size_type &bucket_number_second + , size_type &count) const + { + std::size_t h; + count = 0; + siterator prev; + //Let's see if the element is present + std::pair<siterator, siterator> to_return + ( priv_find(key, hash_func, equal_func, bucket_number_first, h, prev) + , priv_invalid_local_it()); + if(to_return.first == to_return.second){ + bucket_number_second = bucket_number_first; + return to_return; + } + //If it's present, find the first that it's not equal in + //the same bucket + bucket_type &b = this->priv_buckets()[bucket_number_first]; + siterator it = to_return.first; + if(optimize_multikey){ + to_return.second = bucket_type::s_iterator_to + (*node_traits::get_next(group_functions_t::get_last_in_group + (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); + count = std::distance(it, to_return.second); + if(to_return.second != b.end()){ + bucket_number_second = bucket_number_first; + return to_return; + } + } + else{ + ++count; + ++it; + while(it != b.end()){ + const value_type &v = priv_value_from_slist_node(it.pointed_node()); + if(compare_hash){ + std::size_t hv = this->priv_stored_or_compute_hash(v, store_hash_t()); + if(hv != h || !equal_func(key, v)){ + to_return.second = it; + bucket_number_second = bucket_number_first; + return to_return; + } + } + else if(!equal_func(key, v)){ + to_return.second = it; + bucket_number_second = bucket_number_first; + return to_return; + } + ++it; + ++count; + } + } + + //If we reached the end, find the first, non-empty bucket + for(bucket_number_second = bucket_number_first+1 + ; bucket_number_second != this->priv_buckets_len() + ; ++bucket_number_second){ + bucket_type &b = this->priv_buckets()[bucket_number_second]; + if(!b.empty()){ + to_return.second = b.begin(); + return to_return; + } + } + + //Otherwise, return the end node + to_return.second = priv_invalid_local_it(); + return to_return; + } + /// @endcond +}; + +/// @cond +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template < class T + , bool UniqueKeys + , class O1 = none, class O2 = none + , class O3 = none, class O4 = none + , class O5 = none, class O6 = none + , class O7 = none, class O8 = none + , class O9 = none, class O10= none + > +#else +template <class T, bool UniqueKeys, class ...Options> +#endif +struct make_hashtable_opt +{ + typedef typename pack_options + < uset_defaults<T>, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type packed_options; + + //Real value traits must be calculated from options + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + typedef typename packed_options::bucket_traits specified_bucket_traits; + + //Real bucket traits must be calculated from options and calculated value_traits + typedef typename detail::get_slist_impl + <typename detail::reduced_slist_node_traits + <typename real_value_traits::node_traits>::type + >::type slist_impl; + + typedef typename + detail::if_c< detail::is_same + < specified_bucket_traits + , default_bucket_traits + >::value + , detail::bucket_traits_impl<slist_impl> + , specified_bucket_traits + >::type real_bucket_traits; + + typedef detail::usetopt + < value_traits + , typename packed_options::hash + , typename packed_options::equal + , typename packed_options::size_type + , real_bucket_traits + , (std::size_t(UniqueKeys)*detail::hash_bool_flags::unique_keys_pos) + | (std::size_t(packed_options::constant_time_size)*detail::hash_bool_flags::constant_time_size_pos) + | (std::size_t(packed_options::power_2_buckets)*detail::hash_bool_flags::power_2_buckets_pos) + | (std::size_t(packed_options::cache_begin)*detail::hash_bool_flags::cache_begin_pos) + | (std::size_t(packed_options::compare_hash)*detail::hash_bool_flags::compare_hash_pos) + | (std::size_t(packed_options::incremental)*detail::hash_bool_flags::incremental_pos) + > type; +}; +/// @endcond + +//! Helper metafunction to define a \c hashtable that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none + , class O5 = none, class O6 = none + , class O7 = none, class O8 = none + , class O9 = none, class O10= none + > +#endif +struct make_hashtable +{ + /// @cond + typedef hashtable_impl + < typename make_hashtable_opt + <T, false, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type + > implementation_defined; + + /// @endcond + typedef implementation_defined type; +}; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + +#if defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10> +#endif +class hashtable + : public make_hashtable<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type +{ + typedef typename make_hashtable<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable) + + public: + typedef typename Base::value_traits value_traits; + typedef typename Base::real_value_traits real_value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + typedef typename Base::bucket_ptr bucket_ptr; + typedef typename Base::size_type size_type; + typedef typename Base::hasher hasher; + typedef typename Base::bucket_traits bucket_traits; + typedef typename Base::key_equal key_equal; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + + hashtable ( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : Base(b_traits, hash_func, equal_func, v_traits) + {} + + hashtable(BOOST_RV_REF(hashtable) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + hashtable& operator=(BOOST_RV_REF(hashtable) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_HASHTABLE_HPP diff --git a/src/third_party/boost/boost/intrusive/intrusive_fwd.hpp b/src/third_party/boost/boost/intrusive/intrusive_fwd.hpp new file mode 100644 index 00000000000..dc185667e0a --- /dev/null +++ b/src/third_party/boost/boost/intrusive/intrusive_fwd.hpp @@ -0,0 +1,542 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_FWD_HPP +#define BOOST_INTRUSIVE_FWD_HPP + +#include <cstddef> +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/detail/workaround.hpp> + +/// @cond + +namespace boost { + +namespace intrusive { + +struct none; + +} //namespace intrusive{ +} //namespace boost{ + +namespace boost { +namespace intrusive { + +//////////////////////////// +// Node algorithms +//////////////////////////// + +//Algorithms predeclarations +template<class NodeTraits> +class circular_list_algorithms; + +template<class NodeTraits> +class circular_slist_algorithms; + +template<class NodeTraits> +class rbtree_algorithms; + +//////////////////////////// +// Containers +//////////////////////////// + +//slist +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + , class O5 = none + > +#else +template<class T, class ...Options> +#endif +class slist; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class slist_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class slist_member_hook; + +//list +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class T, class ...Options> +#endif +class list; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class list_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class list_member_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class list_hook; + +//rbtree/set/multiset +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class rbtree; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class set; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class multiset; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class ...Options> +#endif +class set_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class ...Options> +#endif +class set_member_hook; + +//splaytree/splay_set/splay_multiset +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class splaytree; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class splay_set; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class splay_multiset; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class splay_set_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class splay_set_member_hook; + +//avltree/avl_set/avl_multiset +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class avltree; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class avl_set; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class avl_multiset; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class ...Options> +#endif +class avl_set_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class ...Options> +#endif +class avl_set_member_hook; + + +//treap/treap_set/treap_multiset +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class treap; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class treap_set; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class treap_multiset; + +//Default priority comparison functor +template <class T> +struct priority_compare; + +//sgtree/sg_set/sg_multiset +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class sgtree; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class sg_set; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class T, class ...Options> +#endif +class sg_multiset; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class bs_set_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class bs_set_member_hook; + +//hashtable/unordered_set/unordered_multiset + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + , class O5 = none + , class O6 = none + , class O7 = none + , class O8 = none + , class O9 = none + , class O10 = none + > +#else +template<class T, class ...Options> +#endif +class hashtable; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + , class O5 = none + , class O6 = none + , class O7 = none + , class O8 = none + , class O9 = none + , class O10 = none + > +#else +template<class T, class ...Options> +#endif +class unordered_set; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class T + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + , class O5 = none + , class O6 = none + , class O7 = none + , class O8 = none + , class O9 = none + , class O10 = none + > +#else +template<class T, class ...Options> +#endif +class unordered_multiset; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class ...Options> +#endif +class unordered_set_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + > +#else +template<class ...Options> +#endif +class unordered_set_member_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class any_base_hook; + +#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template + < class O1 = none + , class O2 = none + , class O3 = none + > +#else +template<class ...Options> +#endif +class any_member_hook; + +} //namespace intrusive { +} //namespace boost { + +/// @endcond + +#endif //#ifndef BOOST_INTRUSIVE_FWD_HPP diff --git a/src/third_party/boost/boost/intrusive/linear_slist_algorithms.hpp b/src/third_party/boost/boost/intrusive/linear_slist_algorithms.hpp new file mode 100644 index 00000000000..f33565528e1 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/linear_slist_algorithms.hpp @@ -0,0 +1,327 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_LINEAR_SLIST_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_LINEAR_SLIST_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/common_slist_algorithms.hpp> +#include <cstddef> +#include <utility> + +namespace boost { +namespace intrusive { + +//! linear_slist_algorithms provides basic algorithms to manipulate nodes +//! forming a linear singly linked list. +//! +//! linear_slist_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the linear list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_next(const_node_ptr n);</tt> +//! +//! <tt>static void set_next(node_ptr n, node_ptr next);</tt> +template<class NodeTraits> +class linear_slist_algorithms + /// @cond + : public detail::common_slist_algorithms<NodeTraits> + /// @endcond +{ + /// @cond + typedef detail::common_slist_algorithms<NodeTraits> base_t; + /// @endcond + public: + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + typedef NodeTraits node_traits; + + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + + //! <b>Effects</b>: Constructs an non-used list element, putting the next + //! pointer to null: + //! <tt>NodeTraits::get_next(this_node) == node_ptr()</tt> + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void init(const node_ptr & this_node); + + //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Returns true is "this_node" is the only node of a circular list: + //! or it's a not inserted node: + //! <tt>return node_ptr() == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node</tt> + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static bool unique(const_node_ptr this_node); + + //! <b>Effects</b>: Returns true is "this_node" has the same state as if + //! it was inited using "init(node_ptr)" + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static bool inited(const_node_ptr this_node); + + //! <b>Requires</b>: prev_node must be in a circular list or be an empty circular list. + //! + //! <b>Effects</b>: Unlinks the next node of prev_node from the circular list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void unlink_after(const node_ptr & prev_node); + + //! <b>Requires</b>: prev_node and last_node must be in a circular list + //! or be an empty circular list. + //! + //! <b>Effects</b>: Unlinks the range (prev_node, last_node) from the linear list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void unlink_after(const node_ptr & prev_node, const node_ptr & last_node); + + //! <b>Requires</b>: prev_node must be a node of a linear list. + //! + //! <b>Effects</b>: Links this_node after prev_node in the linear list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void link_after(const node_ptr & prev_node, const node_ptr & this_node); + + //! <b>Requires</b>: b and e must be nodes of the same linear list or an empty range. + //! and p must be a node of a different linear list. + //! + //! <b>Effects</b>: Removes the nodes from (b, e] range from their linear list and inserts + //! them after p in p's linear list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void transfer_after(const node_ptr & p, const node_ptr & b, const node_ptr & e); + + #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + + //! <b>Effects</b>: Constructs an empty list, making this_node the only + //! node of the circular list: + //! <tt>NodeTraits::get_next(this_node) == this_node</tt>. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void init_header(const node_ptr & this_node) + { NodeTraits::set_next(this_node, node_ptr ()); } + + //! <b>Requires</b>: this_node and prev_init_node must be in the same linear list. + //! + //! <b>Effects</b>: Returns the previous node of this_node in the linear list starting. + //! the search from prev_init_node. The first node checked for equality + //! is NodeTraits::get_next(prev_init_node). + //! + //! <b>Complexity</b>: Linear to the number of elements between prev_init_node and this_node. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_previous_node(const node_ptr & prev_init_node, const node_ptr & this_node) + { return base_t::get_previous_node(prev_init_node, this_node); } + + //! <b>Requires</b>: this_node must be in a linear list or be an empty linear list. + //! + //! <b>Effects</b>: Returns the number of nodes in a linear list. If the linear list + //! is empty, returns 1. + //! + //! <b>Complexity</b>: Linear + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & this_node) + { + std::size_t result = 0; + const_node_ptr p = this_node; + do{ + p = NodeTraits::get_next(p); + ++result; + } while (p); + return result; + } + + //! <b>Requires</b>: this_node and other_node must be nodes inserted + //! in linear lists or be empty linear lists. + //! + //! <b>Effects</b>: Moves all the nodes previously chained after this_node after other_node + //! and vice-versa. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + static void swap_trailing_nodes(const node_ptr & this_node, const node_ptr & other_node) + { + node_ptr this_nxt = NodeTraits::get_next(this_node); + node_ptr other_nxt = NodeTraits::get_next(other_node); + NodeTraits::set_next(this_node, other_nxt); + NodeTraits::set_next(other_node, this_nxt); + } + + //! <b>Effects</b>: Reverses the order of elements in the list. + //! + //! <b>Returns</b>: The new first node of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: This function is linear to the contained elements. + static node_ptr reverse(const node_ptr & p) + { + if(!p) return node_ptr(); + node_ptr i = NodeTraits::get_next(p); + node_ptr first(p); + while(i){ + node_ptr nxti(NodeTraits::get_next(i)); + base_t::unlink_after(p); + NodeTraits::set_next(i, first); + first = i; + i = nxti; + } + return first; + } + + //! <b>Effects</b>: Moves the first n nodes starting at p to the end of the list. + //! + //! <b>Returns</b>: A pair containing the new first and last node of the list or + //! if there has been any movement, a null pair if n leads to no movement. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements plus the number moved positions. + static std::pair<node_ptr, node_ptr> move_first_n_backwards(const node_ptr & p, std::size_t n) + { + std::pair<node_ptr, node_ptr> ret; + //Null shift, or count() == 0 or 1, nothing to do + if(!n || !p || !NodeTraits::get_next(p)){ + return ret; + } + + node_ptr first = p; + bool end_found = false; + node_ptr new_last = node_ptr(); + node_ptr old_last = node_ptr(); + + //Now find the new last node according to the shift count. + //If we find 0 before finding the new last node + //unlink p, shortcut the search now that we know the size of the list + //and continue. + for(std::size_t i = 1; i <= n; ++i){ + new_last = first; + first = NodeTraits::get_next(first); + if(first == node_ptr()){ + //Shortcut the shift with the modulo of the size of the list + n %= i; + if(!n) return ret; + old_last = new_last; + i = 0; + //Unlink p and continue the new first node search + first = p; + //unlink_after(new_last); + end_found = true; + } + } + + //If the p has not been found in the previous loop, find it + //starting in the new first node and unlink it + if(!end_found){ + old_last = base_t::get_previous_node(first, node_ptr()); + } + + //Now link p after the new last node + NodeTraits::set_next(old_last, p); + NodeTraits::set_next(new_last, node_ptr()); + ret.first = first; + ret.second = new_last; + return ret; + } + + //! <b>Effects</b>: Moves the first n nodes starting at p to the beginning of the list. + //! + //! <b>Returns</b>: A pair containing the new first and last node of the list or + //! if there has been any movement, a null pair if n leads to no movement. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements plus the number moved positions. + static std::pair<node_ptr, node_ptr> move_first_n_forward(const node_ptr & p, std::size_t n) + { + std::pair<node_ptr, node_ptr> ret; + //Null shift, or count() == 0 or 1, nothing to do + if(!n || !p || !NodeTraits::get_next(p)) + return ret; + + node_ptr first = p; + + //Iterate until p is found to know where the current last node is. + //If the shift count is less than the size of the list, we can also obtain + //the position of the new last node after the shift. + node_ptr old_last(first), next_to_it, new_last(p); + std::size_t distance = 1; + while(!!(next_to_it = node_traits::get_next(old_last))){ + if(distance++ > n) + new_last = node_traits::get_next(new_last); + old_last = next_to_it; + } + //If the shift was bigger or equal than the size, obtain the equivalent + //forward shifts and find the new last node. + if(distance <= n){ + //Now find the equivalent forward shifts. + //Shortcut the shift with the modulo of the size of the list + std::size_t new_before_last_pos = (distance - (n % distance))% distance; + //If the shift is a multiple of the size there is nothing to do + if(!new_before_last_pos) + return ret; + + for( new_last = p + ; --new_before_last_pos + ; new_last = node_traits::get_next(new_last)){ + //empty + } + } + + //Get the first new node + node_ptr new_first(node_traits::get_next(new_last)); + //Now put the old beginning after the old end + NodeTraits::set_next(old_last, p); + NodeTraits::set_next(new_last, node_ptr()); + ret.first = new_first; + ret.second = new_last; + return ret; + } +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_LINEAR_SLIST_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/link_mode.hpp b/src/third_party/boost/boost/intrusive/link_mode.hpp new file mode 100644 index 00000000000..17012c93cb0 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/link_mode.hpp @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_VALUE_LINK_TYPE_HPP +#define BOOST_INTRUSIVE_VALUE_LINK_TYPE_HPP + +namespace boost { +namespace intrusive { + +//!This enumeration defines the type of value_traits that can be defined +//!for Boost.Intrusive containers +enum link_mode_type{ + //!If this linking policy is specified in a value_traits class + //!as the link_mode, containers + //!configured with such value_traits won't set the hooks + //!of the erased values to a default state. Containers also won't + //!check that the hooks of the new values are default initialized. + normal_link, + + //!If this linking policy is specified in a value_traits class + //!as the link_mode, containers + //!configured with such value_traits will set the hooks + //!of the erased values to a default state. Containers also will + //!check that the hooks of the new values are default initialized. + safe_link, + + //!Same as "safe_link" but the user type is an auto-unlink + //!type, so the containers with constant-time size features won't be + //!compatible with value_traits configured with this policy. + //!Containers also know that the a value can be silently erased from + //!the container without using any function provided by the containers. + auto_unlink +}; +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_VALUE_LINK_TYPE_HPP diff --git a/src/third_party/boost/boost/intrusive/list.hpp b/src/third_party/boost/boost/intrusive/list.hpp new file mode 100644 index 00000000000..dbbf7c93f57 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/list.hpp @@ -0,0 +1,1525 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_LIST_HPP +#define BOOST_INTRUSIVE_LIST_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/list_hook.hpp> +#include <boost/intrusive/circular_list_algorithms.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/static_assert.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <iterator> +#include <algorithm> +#include <functional> +#include <cstddef> +#include <boost/move/move.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +template <class ValueTraits, class SizeType, bool ConstantTimeSize> +struct listopt +{ + typedef ValueTraits value_traits; + typedef SizeType size_type; + static const bool constant_time_size = ConstantTimeSize; +}; + + +template <class T> +struct list_defaults + : pack_options + < none + , base_hook<detail::default_list_hook> + , constant_time_size<true> + , size_type<std::size_t> + >::type +{}; + +/// @endcond + +//! The class template list is an intrusive container that mimics most of the +//! interface of std::list as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<> and \c size_type<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class list_impl + : private detail::clear_on_destructor_base< list_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + //Public typedefs + public: + typedef typename Config::value_traits value_traits; + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + /// @endcond + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + typedef typename pointer_traits<pointer>::element_type value_type; + typedef typename pointer_traits<pointer>::reference reference; + typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef typename pointer_traits<pointer>::difference_type difference_type; + typedef typename Config::size_type size_type; + typedef list_iterator<list_impl, false> iterator; + typedef list_iterator<list_impl, true> const_iterator; + typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator; + typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef circular_list_algorithms<node_traits> node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + + /// @cond + + private: + typedef detail::size_holder<constant_time_size, size_type> size_traits; + + //noncopyable + BOOST_MOVABLE_BUT_NOT_COPYABLE(list_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + //Constant-time size is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(constant_time_size && + ((int)real_value_traits::link_mode == (int)auto_unlink) + )); + + //Const cast emulation for smart pointers + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + node_ptr get_root_node() + { return pointer_traits<node_ptr>::pointer_to(data_.root_plus_size_.root_); } + + const_node_ptr get_root_node() const + { return pointer_traits<const_node_ptr>::pointer_to(data_.root_plus_size_.root_); } + + struct root_plus_size : public size_traits + { + node root_; + }; + + struct data_t : public value_traits + { + typedef typename list_impl::value_traits value_traits; + data_t(const value_traits &val_traits) + : value_traits(val_traits) + {} + + root_plus_size root_plus_size_; + } data_; + + size_traits &priv_size_traits() + { return data_.root_plus_size_; } + + const size_traits &priv_size_traits() const + { return data_.root_plus_size_; } + + const real_value_traits &get_real_value_traits(detail::bool_<false>) const + { return data_; } + + const real_value_traits &get_real_value_traits(detail::bool_<true>) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::bool_<false>) + { return data_; } + + real_value_traits &get_real_value_traits(detail::bool_<true>) + { return data_.get_value_traits(*this); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + protected: + node &prot_root_node() + { return data_.root_plus_size_.root_; } + + node const &prot_root_node() const + { return data_.root_plus_size_.root_; } + + void prot_set_size(size_type s) + { data_.root_plus_size_.set_size(s); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + //! <b>Effects</b>: constructs an empty list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: If real_value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). + list_impl(const value_traits &v_traits = value_traits()) + : data_(v_traits) + { + this->priv_size_traits().set_size(size_type(0)); + node_algorithms::init_header(this->get_root_node()); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! + //! <b>Effects</b>: Constructs a list equal to the range [first,last). + //! + //! <b>Complexity</b>: Linear in std::distance(b, e). No copy constructors are called. + //! + //! <b>Throws</b>: If real_value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). + template<class Iterator> + list_impl(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) + : data_(v_traits) + { + this->priv_size_traits().set_size(size_type(0)); + node_algorithms::init_header(this->get_root_node()); + this->insert(this->cend(), b, e); + } + + //! <b>Effects</b>: to-do + //! + list_impl(BOOST_RV_REF(list_impl) x) + : data_(::boost::move(x.priv_value_traits())) + { + this->priv_size_traits().set_size(size_type(0)); + node_algorithms::init_header(this->get_root_node()); + this->swap(x); + } + + //! <b>Effects</b>: to-do + //! + list_impl& operator=(BOOST_RV_REF(list_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: If it's not a safe-mode or an auto-unlink value_type + //! the destructor does nothing + //! (ie. no code is generated). Otherwise it detaches all elements from this. + //! In this case the objects in the list are not deleted (i.e. no destructors + //! are called), but the hooks according to the ValueTraits template parameter + //! are set to their default value. + //! + //! <b>Complexity</b>: Linear to the number of elements in the list, if + //! it's a safe-mode or auto-unlink value . Otherwise constant. + ~list_impl() + {} + + //! <b>Requires</b>: value must be an lvalue. + //! + //! <b>Effects</b>: Inserts the value in the back of the list. + //! No copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void push_back(reference value) + { + node_ptr to_insert = get_real_value_traits().to_node_ptr(value); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); + node_algorithms::link_before(this->get_root_node(), to_insert); + this->priv_size_traits().increment(); + } + + //! <b>Requires</b>: value must be an lvalue. + //! + //! <b>Effects</b>: Inserts the value in the front of the list. + //! No copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void push_front(reference value) + { + node_ptr to_insert = get_real_value_traits().to_node_ptr(value); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); + node_algorithms::link_before(node_traits::get_next(this->get_root_node()), to_insert); + this->priv_size_traits().increment(); + } + + //! <b>Effects</b>: Erases the last element of the list. + //! No destructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element. + void pop_back() + { return this->pop_back_and_dispose(detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the last element of the list. + //! No destructors are called. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators to the erased element. + template<class Disposer> + void pop_back_and_dispose(Disposer disposer) + { + node_ptr to_erase = node_traits::get_previous(this->get_root_node()); + node_algorithms::unlink(to_erase); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + } + + //! <b>Effects</b>: Erases the first element of the list. + //! No destructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element. + void pop_front() + { return this->pop_front_and_dispose(detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the first element of the list. + //! No destructors are called. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators to the erased element. + template<class Disposer> + void pop_front_and_dispose(Disposer disposer) + { + node_ptr to_erase = node_traits::get_next(this->get_root_node()); + node_algorithms::unlink(to_erase); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + } + + //! <b>Effects</b>: Returns a reference to the first element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reference front() + { return *get_real_value_traits().to_value_ptr(node_traits::get_next(this->get_root_node())); } + + //! <b>Effects</b>: Returns a const_reference to the first element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_reference front() const + { return *get_real_value_traits().to_value_ptr(uncast(node_traits::get_next(this->get_root_node()))); } + + //! <b>Effects</b>: Returns a reference to the last element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reference back() + { return *get_real_value_traits().to_value_ptr(node_traits::get_previous(this->get_root_node())); } + + //! <b>Effects</b>: Returns a const_reference to the last element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_reference back() const + { return *get_real_value_traits().to_value_ptr(uncast(node_traits::get_previous(this->get_root_node()))); } + + //! <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(node_traits::get_next(this->get_root_node()), this); } + + //! <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 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(node_traits::get_next(this->get_root_node()), this); } + + //! <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->get_root_node(), this); } + + //! <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 constant iterator to the end of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_iterator cend() const + { return const_iterator(uncast(this->get_root_node()), this); } + + //! <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(this->end()); } + + //! <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 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(end()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! 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. + //! + //! <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 list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_reverse_iterator crend() const + { return const_reverse_iterator(this->begin()); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of list. + //! + //! <b>Effects</b>: Returns a const reference to the list associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static list_impl &container_from_end_iterator(iterator end_iterator) + { return list_impl::priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of list. + //! + //! <b>Effects</b>: Returns a const reference to the list associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const list_impl &container_from_end_iterator(const_iterator end_iterator) + { return list_impl::priv_container_from_end_iterator(end_iterator); } + + //! <b>Effects</b>: Returns the number of the elements contained in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements contained in the list. + //! if constant-time size option is disabled. Constant time otherwise. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + size_type size() const + { + if(constant_time_size) + return this->priv_size_traits().get_size(); + else + return node_algorithms::count(this->get_root_node()) - 1; + } + + //! <b>Effects</b>: Returns true if the list contains no elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + bool empty() const + { return node_algorithms::unique(this->get_root_node()); } + + //! <b>Effects</b>: Swaps the elements of x and *this. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void swap(list_impl& other) + { + node_algorithms::swap_nodes(this->get_root_node(), other.get_root_node()); + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + } + + //! <b>Effects</b>: Moves backwards all the elements, so that the first + //! element becomes the second, the second becomes the third... + //! the last element becomes the first one. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of shifts. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void shift_backwards(size_type n = 1) + { node_algorithms::move_forward(this->get_root_node(), n); } + + //! <b>Effects</b>: Moves forward all the elements, so that the second + //! element becomes the first, the third becomes the second... + //! the first element becomes the last one. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of shifts. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void shift_forward(size_type n = 1) + { node_algorithms::move_backwards(this->get_root_node(), n); } + + //! <b>Effects</b>: Erases the element pointed by i of the list. + //! No destructors are called. + //! + //! <b>Returns</b>: the first element remaining beyond the removed element, + //! or end() if no such element exists. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased element. + iterator erase(const_iterator i) + { return this->erase_and_dispose(i, detail::null_disposer()); } + + //! <b>Requires</b>: b and e must be valid iterators to elements in *this. + //! + //! <b>Effects</b>: Erases the element range pointed by b and e + //! No destructors are called. + //! + //! <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 if it's a safe-mode + //! or auto-unlink value, or constant-time size is enabled. Constant-time otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased elements. + iterator erase(const_iterator b, const_iterator e) + { + if(safemode_or_autounlink || constant_time_size){ + return this->erase_and_dispose(b, e, detail::null_disposer()); + } + else{ + node_algorithms::unlink(b.pointed_node(), e.pointed_node()); + return e.unconst(); + } + } + + //! <b>Requires</b>: b and e must be valid iterators to elements in *this. + //! n must be std::distance(b, e). + //! + //! <b>Effects</b>: Erases the element range pointed by b and e + //! No destructors are called. + //! + //! <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 if it's a safe-mode + //! or auto-unlink value is enabled. Constant-time otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased elements. + iterator erase(const_iterator b, const_iterator e, difference_type n) + { + BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(b, e) == difference_type(n)); + if(safemode_or_autounlink || constant_time_size){ + return this->erase_and_dispose(b, e, detail::null_disposer()); + } + else{ + if(constant_time_size){ + this->priv_size_traits().set_size(this->priv_size_traits().get_size() - n); + } + node_algorithms::unlink(b.pointed_node(), e.pointed_node()); + return e.unconst(); + } + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed by i of the list. + //! No destructors are called. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Returns</b>: the first element remaining beyond the removed element, + //! or end() if no such element exists. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators to the erased element. + template <class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { + node_ptr to_erase(i.pointed_node()); + ++i; + node_algorithms::unlink(to_erase); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(this->get_real_value_traits().to_value_ptr(to_erase)); + return i.unconst(); + } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element range pointed by b and e + //! No destructors are called. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <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 elements erased. + //! + //! <b>Note</b>: Invalidates the iterators to the erased elements. + template <class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { + node_ptr bp(b.pointed_node()), ep(e.pointed_node()); + node_algorithms::unlink(bp, ep); + while(bp != ep){ + node_ptr to_erase(bp); + bp = node_traits::get_next(bp); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + this->priv_size_traits().decrement(); + } + return e.unconst(); + } + + //! <b>Effects</b>: Erases all the elements of the container. + //! No destructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements of the list. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased elements. + void clear() + { + if(safemode_or_autounlink){ + this->clear_and_dispose(detail::null_disposer()); + } + else{ + node_algorithms::init_header(this->get_root_node()); + this->priv_size_traits().set_size(size_type(0)); + } + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! No destructors are called. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements of the list. + //! + //! <b>Note</b>: Invalidates the iterators to the erased elements. + template <class Disposer> + void clear_and_dispose(Disposer disposer) + { + const_iterator it(this->begin()), itend(this->end()); + while(it != itend){ + node_ptr to_erase(it.pointed_node()); + ++it; + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + } + node_algorithms::init_header(this->get_root_node()); + this->priv_size_traits().set_size(0); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const list_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + detail::exception_disposer<list_impl, Disposer> + rollback(*this, disposer); + const_iterator b(src.begin()), e(src.end()); + for(; b != e; ++b){ + this->push_back(*cloner(*b)); + } + rollback.release(); + } + + //! <b>Requires</b>: value must be an lvalue and p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts the value before the position pointed by p. + //! + //! <b>Returns</b>: An iterator to the inserted element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. No copy constructors are called. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + iterator insert(const_iterator p, reference value) + { + node_ptr to_insert = this->get_real_value_traits().to_node_ptr(value); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); + node_algorithms::link_before(p.pointed_node(), to_insert); + this->priv_size_traits().increment(); + return iterator(to_insert, this); + } + + //! <b>Requires</b>: Dereferencing iterator must yield + //! an lvalue of type value_type and p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Inserts the range pointed by b and e before the position p. + //! No copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements inserted. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + template<class Iterator> + void insert(const_iterator p, Iterator b, Iterator e) + { + for (; b != e; ++b) + this->insert(p, *b); + } + + //! <b>Requires</b>: Dereferencing iterator must yield + //! an lvalue of type value_type. + //! + //! <b>Effects</b>: Clears the list and inserts the range pointed by b and e. + //! No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements inserted plus + //! linear to the elements contained in the list if it's a safe-mode + //! or auto-unlink value. + //! Linear to the number of elements inserted in the list otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. + template<class Iterator> + void assign(Iterator b, Iterator e) + { + this->clear(); + this->insert(this->cend(), b, e); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Requires</b>: Dereferencing iterator must yield + //! an lvalue of type value_type. + //! + //! <b>Effects</b>: Clears the list and inserts the range pointed by b and e. + //! No destructors or copy constructors are called. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements inserted plus + //! linear to the elements contained in the list. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. + template<class Iterator, class Disposer> + void dispose_and_assign(Disposer disposer, Iterator b, Iterator e) + { + this->clear_and_dispose(disposer); + this->insert(this->cend(), b, e); + } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! + //! <b>Effects</b>: Transfers all the elements of list x to this list, before the + //! the element pointed by p. No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <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, list_impl& x) + { + if(!x.empty()){ + size_traits &thist = this->priv_size_traits(); + size_traits &xt = x.priv_size_traits(); + node_algorithms::transfer + (p.pointed_node(), x.begin().pointed_node(), x.end().pointed_node()); + thist.set_size(thist.get_size() + xt.get_size()); + xt.set_size(size_type(0)); + } + } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! new_ele must point to an element contained in list x. + //! + //! <b>Effects</b>: Transfers the value pointed by new_ele, from list x to this list, + //! before the the element pointed by p. No destructors or copy constructors are called. + //! If p == new_ele or p == ++new_ele, this function is a null operation. + //! + //! <b>Throws</b>: Nothing. + //! + //! <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, list_impl&x, const_iterator new_ele) + { + node_algorithms::transfer(p.pointed_node(), new_ele.pointed_node()); + x.priv_size_traits().decrement(); + this->priv_size_traits().increment(); + } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! start and end must point to elements contained in list x. + //! + //! <b>Effects</b>: Transfers the range pointed by start and end from list x to this list, + //! before the the element pointed by p. No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements transferred + //! if constant-time size option is enabled. Constant-time otherwise. + //! + //! <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, list_impl&x, const_iterator start, const_iterator end) + { + if(constant_time_size) + this->splice(p, x, start, end, std::distance(start, end)); + else + this->splice(p, x, start, end, 1);//distance is a dummy value + } + + //! <b>Requires</b>: p must be a valid iterator of *this. + //! start and end must point to elements contained in list x. + //! n == std::distance(start, end) + //! + //! <b>Effects</b>: Transfers the range pointed by start and end from list x to this list, + //! before the the element pointed by p. No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <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, list_impl&x, const_iterator start, const_iterator end, difference_type n) + { + if(n){ + if(constant_time_size){ + size_traits &thist = this->priv_size_traits(); + size_traits &xt = x.priv_size_traits(); + BOOST_INTRUSIVE_INVARIANT_ASSERT(n == std::distance(start, end)); + node_algorithms::transfer(p.pointed_node(), start.pointed_node(), end.pointed_node()); + thist.set_size(thist.get_size() + n); + xt.set_size(xt.get_size() - n); + } + else{ + node_algorithms::transfer(p.pointed_node(), start.pointed_node(), end.pointed_node()); + } + } + } + + //! <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>: If real_value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or std::less<value_type> throws. Basic guarantee. + //! + //! <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(std::less<value_type>()); } + + //! <b>Requires</b>: p must be a comparison function that induces a strict weak ordering + //! + //! <b>Effects</b>: This function sorts the list *this according to p. The sort is + //! stable, that is, the relative order of equivalent elements is preserved. + //! + //! <b>Throws</b>: If real_value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the predicate throws. Basic guarantee. + //! + //! <b>Notes</b>: This won't throw if list_base_hook<> or + //! list_member_hook are used. + //! 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 Predicate> + void sort(Predicate p) + { + if(node_traits::get_next(this->get_root_node()) + != node_traits::get_previous(this->get_root_node())){ + list_impl carry(this->priv_value_traits()); + detail::array_initializer<list_impl, 64> counter(this->priv_value_traits()); + int fill = 0; + while(!this->empty()){ + carry.splice(carry.cbegin(), *this, this->cbegin()); + int i = 0; + while(i < fill && !counter[i].empty()) { + counter[i].merge(carry, p); + carry.swap(counter[i++]); + } + carry.swap(counter[i]); + if(i == fill) + ++fill; + } + for (int i = 1; i < fill; ++i) + counter[i].merge(counter[i-1], p); + this->swap(counter[fill-1]); + } + } + + //! <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. + //! + //! <b>Throws</b>: If std::less<value_type> throws. Basic guarantee. + //! + //! <b>Complexity</b>: This function is linear time: it performs at most + //! size() + x.size() - 1 comparisons. + //! + //! <b>Note</b>: Iterators and references are not invalidated + void merge(list_impl& x) + { this->merge(x, std::less<value_type>()); } + + //! <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. + //! + //! <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. + //! + //! <b>Throws</b>: If the predicate throws. Basic guarantee. + //! + //! <b>Complexity</b>: This function is linear time: it performs at most + //! size() + x.size() - 1 comparisons. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + template<class Predicate> + void merge(list_impl& x, Predicate p) + { + const_iterator e(this->cend()), ex(x.cend()); + const_iterator b(this->cbegin()); + while(!x.empty()){ + const_iterator ix(x.cbegin()); + while (b != e && !p(*ix, *b)){ + ++b; + } + if(b == e){ + //Now transfer the rest to the end of the container + this->splice(e, x); + break; + } + else{ + size_type n(0); + do{ + ++ix; ++n; + } while(ix != ex && p(*ix, *b)); + this->splice(b, x, x.begin(), ix, n); + } + } + } + + //! <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() + { node_algorithms::reverse(this->get_root_node()); } + + //! <b>Effects</b>: Removes all the elements that compare equal to value. + //! No destructors are called. + //! + //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee. + //! + //! <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_reference value) + { this->remove_if(detail::equal_to_value<const_reference>(value)); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes all the elements that compare equal to value. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee. + //! + //! <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. + template<class Disposer> + void remove_and_dispose(const_reference value, Disposer disposer) + { this->remove_and_dispose_if(detail::equal_to_value<const_reference>(value), disposer); } + + //! <b>Effects</b>: Removes all the elements for which a specified + //! predicate is satisfied. No destructors are called. + //! + //! <b>Throws</b>: If pred throws. Basic guarantee. + //! + //! <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> + void remove_if(Pred pred) + { this->remove_and_dispose_if(pred, detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes all the elements for which a specified + //! predicate is satisfied. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If pred throws. Basic guarantee. + //! + //! <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. + template<class Pred, class Disposer> + void remove_and_dispose_if(Pred pred, Disposer disposer) + { + const_iterator cur(this->cbegin()); + const_iterator last(this->cend()); + while(cur != last) { + if(pred(*cur)){ + cur = this->erase_and_dispose(cur, disposer); + } + else{ + ++cur; + } + } + } + + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that are equal from the list. No destructors are called. + //! + //! <b>Throws</b>: If std::equal_to<value_type throws. Basic guarantee. + //! + //! <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_and_dispose(std::equal_to<value_type>(), detail::null_disposer()); } + + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that satisfy some binary predicate from the list. + //! No destructors are called. + //! + //! <b>Throws</b>: If pred throws. Basic guarantee. + //! + //! <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> + void unique(BinaryPredicate pred) + { this->unique_and_dispose(pred, detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that are equal from the list. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If std::equal_to<value_type throws. Basic guarantee. + //! + //! <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 Disposer> + void unique_and_dispose(Disposer disposer) + { this->unique_and_dispose(std::equal_to<value_type>(), disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that satisfy some binary predicate from the list. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If pred throws. Basic guarantee. + //! + //! <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, class Disposer> + void unique_and_dispose(BinaryPredicate pred, Disposer disposer) + { + const_iterator itend(this->cend()); + const_iterator cur(this->cbegin()); + + if(cur != itend){ + const_iterator after(cur); + ++after; + while(after != itend){ + if(pred(*cur, *after)){ + after = this->erase_and_dispose(after, disposer); + } + else{ + cur = after; + ++after; + } + } + } + } + + //! <b>Requires</b>: value must be a reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns a const_iterator pointing to the element + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + //! This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(value))); + return iterator(real_value_traits::to_node_ptr(value), 0); + } + + //! <b>Requires</b>: value must be a const reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns an iterator pointing to the element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + //! This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(const_cast<reference> (value)))); + return const_iterator(real_value_traits::to_node_ptr(const_cast<reference> (value)), 0); + } + + //! <b>Requires</b>: value must be a reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns a const_iterator pointing to the element + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + iterator iterator_to(reference value) + { + BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(value))); + return iterator(real_value_traits::to_node_ptr(value), this); + } + + //! <b>Requires</b>: value must be a const reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns an iterator pointing to the element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + const_iterator iterator_to(const_reference value) const + { + BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(const_cast<reference> (value)))); + return const_iterator(real_value_traits::to_node_ptr(const_cast<reference> (value)), this); + } + + /// @cond + + private: + static list_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) + { + root_plus_size *r = detail::parent_from_member<root_plus_size, node> + ( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), &root_plus_size::root_); + data_t *d = detail::parent_from_member<data_t, root_plus_size> + ( r, &data_t::root_plus_size_); + list_impl *s = detail::parent_from_member<list_impl, data_t>(d, &list_impl::data_); + return *s; + } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator< +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y) +#else +(const list_impl<Config> &x, const list_impl<Config> &y) +#endif +{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +bool operator== +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y) +#else +(const list_impl<Config> &x, const list_impl<Config> &y) +#endif +{ + typedef list_impl<Config> list_type; + typedef typename list_type::const_iterator const_iterator; + const bool C = list_type::constant_time_size; + if(C && x.size() != y.size()){ + return false; + } + const_iterator end1 = x.end(); + + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + if(C){ + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; + } + else{ + const_iterator end2 = y.end(); + while (i1 != end1 && i2 != end2 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1 && i2 == end2; + } +} + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y) +#else +(const list_impl<Config> &x, const list_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y) +#else +(const list_impl<Config> &x, const list_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y) +#else +(const list_impl<Config> &x, const list_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const list_impl<T, Options...> &x, const list_impl<T, Options...> &y) +#else +(const list_impl<Config> &x, const list_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(list_impl<T, Options...> &x, list_impl<T, Options...> &y) +#else +(list_impl<Config> &x, list_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c list that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_list +{ + /// @cond + typedef typename pack_options + < list_defaults<T>, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + + typedef list_impl + < + listopt + < value_traits + , typename packed_options::size_type + , packed_options::constant_time_size + > + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3> +#else +template<class T, class ...Options> +#endif +class list + : public make_list<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type +{ + typedef typename make_list + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type Base; + typedef typename Base::real_value_traits real_value_traits; + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + BOOST_MOVABLE_BUT_NOT_COPYABLE(list) + + public: + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + list(const value_traits &v_traits = value_traits()) + : Base(v_traits) + {} + + template<class Iterator> + list(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) + : Base(b, e, v_traits) + {} + + list(BOOST_RV_REF(list) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + list& operator=(BOOST_RV_REF(list) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static list &container_from_end_iterator(iterator end_iterator) + { return static_cast<list &>(Base::container_from_end_iterator(end_iterator)); } + + static const list &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const list &>(Base::container_from_end_iterator(end_iterator)); } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_LIST_HPP diff --git a/src/third_party/boost/boost/intrusive/list_hook.hpp b/src/third_party/boost/boost/intrusive/list_hook.hpp new file mode 100644 index 00000000000..ed93434a3fe --- /dev/null +++ b/src/third_party/boost/boost/intrusive/list_hook.hpp @@ -0,0 +1,290 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_LIST_HOOK_HPP +#define BOOST_INTRUSIVE_LIST_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/list_node.hpp> +#include <boost/intrusive/circular_list_algorithms.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +template<class VoidPointer> +struct get_list_node_algo +{ + typedef circular_list_algorithms<list_node_traits<VoidPointer> > type; +}; +/// @endcond + +//! Helper metafunction to define a \c \c list_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_list_base_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_list_node_algo<typename packed_options::void_pointer> + , typename packed_options::tag + , packed_options::link_mode + , detail::ListBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from this hook in order to store objects of that class +//! in an list. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<> and +//! \c link_mode<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its +//! unique tag. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class list_base_hook + : public make_list_base_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3> + #else + <Options...> + #endif + ::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + list_base_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + list_base_hook(const list_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + list_base_hook& operator=(const list_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in an list an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~list_base_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(list_base_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c list::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +//! Helper metafunction to define a \c \c list_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_list_member_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_list_node_algo<typename packed_options::void_pointer> + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Store this hook in a class to be inserted +//! in an list. +//! +//! The hook admits the following options: \c void_pointer<> and +//! \c link_mode<>. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class list_member_hook + : public make_list_member_hook + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + <O1, O2, O3> + #else + <Options...> + #endif + ::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + list_member_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + list_member_hook(const list_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + list_member_hook& operator=(const list_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in an list an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~list_member_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(list_member_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c list::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_LIST_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/member_value_traits.hpp b/src/third_party/boost/boost/intrusive/member_value_traits.hpp new file mode 100644 index 00000000000..378c4e05b82 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/member_value_traits.hpp @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_MEMBER_VALUE_TRAITS_HPP +#define BOOST_INTRUSIVE_MEMBER_VALUE_TRAITS_HPP + +#include <boost/intrusive/link_mode.hpp> +#include <iterator> +#include <boost/intrusive/detail/parent_from_member.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace intrusive { + +//!This value traits template is used to create value traits +//!from user defined node traits where value_traits::value_type will +//!store a node_traits::node +template< class T, class NodeTraits + , typename NodeTraits::node T::* PtrToMember + , link_mode_type LinkMode = safe_link> +struct member_value_traits +{ + public: + typedef NodeTraits node_traits; + typedef T value_type; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef typename pointer_traits<node_ptr>::template + rebind_pointer<T>::type pointer; + typedef typename pointer_traits<node_ptr>::template + rebind_pointer<const T>::type const_pointer; + //typedef typename pointer_traits<pointer>::reference reference; + //typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef value_type & reference; + typedef const value_type & const_reference; + static const link_mode_type link_mode = LinkMode; + + static node_ptr to_node_ptr(reference value) + { return node_ptr(&(value.*PtrToMember)); } + + static const_node_ptr to_node_ptr(const_reference value) + { return node_ptr(&(value.*PtrToMember)); } + + static pointer to_value_ptr(const node_ptr &n) + { + return pointer(detail::parent_from_member<value_type, node> + (boost::intrusive::detail::to_raw_pointer(n), PtrToMember)); + } + + static const_pointer to_value_ptr(const const_node_ptr &n) + { + return pointer(detail::parent_from_member<value_type, node> + (boost::intrusive::detail::to_raw_pointer(n), PtrToMember)); + } +}; + +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_MEMBER_VALUE_TRAITS_HPP diff --git a/src/third_party/boost/boost/intrusive/options.hpp b/src/third_party/boost/boost/intrusive/options.hpp new file mode 100644 index 00000000000..4cdeccdeaa7 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/options.hpp @@ -0,0 +1,812 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_OPTIONS_HPP +#define BOOST_INTRUSIVE_OPTIONS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/static_assert.hpp> + + +namespace boost { +namespace intrusive { + +/// @cond + +struct default_tag; +struct member_tag; + +namespace detail{ + +struct default_hook_tag{}; + +#define BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER) \ +struct BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER : public default_hook_tag\ +{\ + template <class T>\ + struct apply\ + { typedef typename T::BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER type; };\ +}\ + +BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_list_hook); +BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_slist_hook); +BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_set_hook); +BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_uset_hook); +BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_avl_set_hook); +BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_splay_set_hook); +BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_bs_set_hook); + +#undef BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION + +template <class ValueTraits> +struct eval_value_traits +{ + typedef typename ValueTraits::value_traits type; +}; + +template <class T> +struct external_bucket_traits_is_true +{ + static const bool value = external_bucket_traits_bool<T>::value == 3; +}; + +template <class BucketTraits> +struct eval_bucket_traits +{ + typedef typename BucketTraits::bucket_traits type; +}; + +template <class T, class BaseHook> +struct concrete_hook_base_value_traits +{ + typedef typename BaseHook::boost_intrusive_tags tags; + typedef detail::base_hook_traits + < T + , typename tags::node_traits + , tags::link_mode + , typename tags::tag + , tags::hook_type> type; +}; + +template <class BaseHook> +struct concrete_hook_base_node_traits +{ typedef typename BaseHook::boost_intrusive_tags::node_traits type; }; + +template <class T, class BaseHook> +struct any_hook_base_value_traits +{ + typedef typename BaseHook::boost_intrusive_tags tags; + typedef detail::base_hook_traits + < T + , typename BaseHook::node_traits + , tags::link_mode + , typename tags::tag + , tags::hook_type> type; +}; + +template <class BaseHook> +struct any_hook_base_node_traits +{ typedef typename BaseHook::node_traits type; }; + +template<class T, class BaseHook> +struct get_base_value_traits +{ + typedef typename detail::eval_if_c + < internal_any_hook_bool_is_true<BaseHook>::value + , any_hook_base_value_traits<T, BaseHook> + , concrete_hook_base_value_traits<T, BaseHook> + >::type type; +}; + +template<class BaseHook> +struct get_base_node_traits +{ + typedef typename detail::eval_if_c + < internal_any_hook_bool_is_true<BaseHook>::value + , any_hook_base_node_traits<BaseHook> + , concrete_hook_base_node_traits<BaseHook> + >::type type; +}; + +template<class T, class MemberHook> +struct get_member_value_traits +{ + typedef typename MemberHook::member_value_traits type; +}; + +template<class MemberHook> +struct get_member_node_traits +{ + typedef typename MemberHook::member_value_traits::node_traits type; +}; + +template<class T, class SupposedValueTraits> +struct get_value_traits +{ + typedef typename detail::eval_if_c + <detail::is_convertible<SupposedValueTraits*, detail::default_hook_tag*>::value + ,detail::apply<SupposedValueTraits, T> + ,detail::identity<SupposedValueTraits> + >::type supposed_value_traits; + //...if it's a default hook + typedef typename detail::eval_if_c + < internal_base_hook_bool_is_true<supposed_value_traits>::value + //...get it's internal value traits using + //the provided T value type. + , get_base_value_traits<T, supposed_value_traits> + //...else use it's internal value traits tag + //(member hooks and custom value traits are in this group) + , detail::eval_if_c + < internal_member_value_traits<supposed_value_traits>::value + , get_member_value_traits<T, supposed_value_traits> + , detail::identity<supposed_value_traits> + > + >::type type; +}; + +template<class ValueTraits> +struct get_explicit_node_traits +{ + typedef typename ValueTraits::node_traits type; +}; + +template<class SupposedValueTraits> +struct get_node_traits +{ + typedef SupposedValueTraits supposed_value_traits; + //...if it's a base hook + typedef typename detail::eval_if_c + < internal_base_hook_bool_is_true<supposed_value_traits>::value + //...get it's internal value traits using + //the provided T value type. + , get_base_node_traits<supposed_value_traits> + //...else use it's internal value traits tag + //(member hooks and custom value traits are in this group) + , detail::eval_if_c + < internal_member_value_traits<supposed_value_traits>::value + , get_member_node_traits<supposed_value_traits> + , get_explicit_node_traits<supposed_value_traits> + > + >::type type; +}; + +} //namespace detail{ + + +//!This type indicates that no option is being used +//!and that the default options should be used +struct none +{ + template<class Base> + struct pack : Base + { }; +}; + +/// @endcond + +//!This option setter specifies if the intrusive +//!container stores its size as a member to +//!obtain constant-time size() member. +template<bool Enabled> +struct constant_time_size +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool constant_time_size = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies the type that +//!the container will use to store its size. +template<class SizeType> +struct size_type +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef SizeType size_type; + }; +/// @endcond +}; + +//!This option setter specifies the strict weak ordering +//!comparison functor for the value type +template<class Compare> +struct compare +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef Compare compare; + }; +/// @endcond +}; + +//!This option setter for scapegoat containers specifies if +//!the intrusive scapegoat container should use a non-variable +//!alpha value that does not need floating-point operations. +//! +//!If activated, the fixed alpha value is 1/sqrt(2). This +//!option also saves some space in the container since +//!the alpha value and some additional data does not need +//!to be stored in the container. +//! +//!If the user only needs an alpha value near 1/sqrt(2), this +//!option also improves performance since avoids logarithm +//!and division operations when rebalancing the tree. +template<bool Enabled> +struct floating_point +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool floating_point = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies the equality +//!functor for the value type +template<class Equal> +struct equal +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef Equal equal; + }; +/// @endcond +}; + +//!This option setter specifies the equality +//!functor for the value type +template<class Priority> +struct priority +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef Priority priority; + }; +/// @endcond +}; + +//!This option setter specifies the hash +//!functor for the value type +template<class Hash> +struct hash +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef Hash hash; + }; +/// @endcond +}; + +//!This option setter specifies the relationship between the type +//!to be managed by the container (the value type) and the node to be +//!used in the node algorithms. It also specifies the linking policy. +template<typename ValueTraits> +struct value_traits +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef ValueTraits value_traits; + }; +/// @endcond +}; + +//!This option setter specifies the member hook the +//!container must use. +template< typename Parent + , typename MemberHook + , MemberHook Parent::* PtrToMember> +struct member_hook +{ +/// @cond + typedef detail::member_hook_traits + < Parent + , MemberHook + , PtrToMember + > member_value_traits; + template<class Base> + struct pack : Base + { + typedef member_value_traits value_traits; + }; +/// @endcond +}; + + +//!This option setter specifies the function object that will +//!be used to convert between values to be inserted in a container +//!and the hook to be used for that purpose. +template< typename Functor> +struct function_hook +{ +/// @cond + typedef detail::function_hook_traits + <Functor> function_value_traits; + template<class Base> + struct pack : Base + { + typedef function_value_traits value_traits; + }; +/// @endcond +}; + + +//!This option setter specifies that the container +//!must use the specified base hook +template<typename BaseHook> +struct base_hook +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef BaseHook value_traits; + }; +/// @endcond +}; + +//!This option setter specifies the type of +//!a void pointer. This will instruct the hook +//!to use this type of pointer instead of the +//!default one +template<class VoidPointer> +struct void_pointer +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef VoidPointer void_pointer; + }; +/// @endcond +}; + +//!This option setter specifies the type of +//!the tag of a base hook. A type cannot have two +//!base hooks of the same type, so a tag can be used +//!to differentiate two base hooks with otherwise same type +template<class Tag> +struct tag +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef Tag tag; + }; +/// @endcond +}; + +//!This option setter specifies the link mode +//!(normal_link, safe_link or auto_unlink) +template<link_mode_type LinkType> +struct link_mode +{ +/// @cond + template<class Base> + struct pack : Base + { + static const link_mode_type link_mode = LinkType; + }; +/// @endcond +}; + +//!This option setter specifies if the hook +//!should be optimized for size instead of for speed. +template<bool Enabled> +struct optimize_size +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool optimize_size = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies if the list container should +//!use a linear implementation instead of a circular one. +template<bool Enabled> +struct linear +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool linear = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies if the list container should +//!use a linear implementation instead of a circular one. +template<bool Enabled> +struct cache_last +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool cache_last = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies the bucket traits +//!class for unordered associative containers. When this option is specified, +//!instead of using the default bucket traits, a user defined holder will be defined +template<class BucketTraits> +struct bucket_traits +{ +/// @cond + template<class Base> + struct pack : Base + { + typedef BucketTraits bucket_traits; + }; +/// @endcond +}; + +//!This option setter specifies if the unordered hook +//!should offer room to store the hash value. +//!Storing the hash in the hook will speed up rehashing +//!processes in applications where rehashing is frequent, +//!rehashing might throw or the value is heavy to hash. +template<bool Enabled> +struct store_hash +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool store_hash = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies if the unordered hook +//!should offer room to store another link to another node +//!with the same key. +//!Storing this link will speed up lookups and insertions on +//!unordered_multiset containers with a great number of elements +//!with the same key. +template<bool Enabled> +struct optimize_multikey +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool optimize_multikey = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies if the bucket array will be always power of two. +//!This allows using masks instead of the default modulo operation to determine +//!the bucket number from the hash value, leading to better performance. +//!In debug mode, if power of two buckets mode is activated, the bucket length +//!will be checked to through assertions to assure the bucket length is power of two. +template<bool Enabled> +struct power_2_buckets +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool power_2_buckets = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies if the container will cache a pointer to the first +//!non-empty bucket so that begin() is always constant-time. +//!This is specially helpful when we can have containers with a few elements +//!but with big bucket arrays (that is, hashtables with low load factors). +template<bool Enabled> +struct cache_begin +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool cache_begin = Enabled; + }; +/// @endcond +}; + + +//!This option setter specifies if the container will compare the hash value +//!before comparing objects. This option can't be specified if store_hash<> +//!is not true. +//!This is specially helpful when we have containers with a high load factor. +//!and the comparison function is much more expensive that comparing already +//!stored hash values. +template<bool Enabled> +struct compare_hash +{ +/// @cond + template<class Base> + struct pack : Base + { + static const bool compare_hash = Enabled; + }; +/// @endcond +}; + +//!This option setter specifies if the hash container will use incremental +//!hashing. With incremental hashing the cost of hash table expansion is spread +//!out across each hash table insertion operation, as opposed to be incurred all at once. +//!Therefore linear hashing is well suited for interactive applications or real-time +//!appplications where the worst-case insertion time of non-incremental hash containers +//!(rehashing the whole bucket array) is not admisible. +template<bool Enabled> +struct incremental +{ + /// @cond + template<class Base> + struct pack : Base + { + static const bool incremental = Enabled; + }; + /// @endcond +}; + +/// @cond + +//To-do: pass to variadic templates +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + +template<class Prev, class Next> +struct do_pack +{ + //Use "pack" member template to pack options + typedef typename Next::template pack<Prev> type; +}; + +template<class Prev> +struct do_pack<Prev, none> +{ + //Avoid packing "none" to shorten template names + typedef Prev type; +}; + +template + < class DefaultOptions + , class O1 = none + , class O2 = none + , class O3 = none + , class O4 = none + , class O5 = none + , class O6 = none + , class O7 = none + , class O8 = none + , class O9 = none + , class O10 = none + , class O11 = none + > +struct pack_options +{ + // join options + typedef + typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < typename do_pack + < DefaultOptions + , O1 + >::type + , O2 + >::type + , O3 + >::type + , O4 + >::type + , O5 + >::type + , O6 + >::type + , O7 + >::type + , O8 + >::type + , O9 + >::type + , O10 + >::type + , O11 + >::type + type; +}; +#else + +//index_tuple +template<int... Indexes> +struct index_tuple{}; + +//build_number_seq +template<std::size_t Num, typename Tuple = index_tuple<> > +struct build_number_seq; + +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)> > +{}; + +template<int... Indexes> +struct build_number_seq<0, index_tuple<Indexes...> > +{ typedef index_tuple<Indexes...> type; }; + +template<class ...Types> +struct typelist +{}; + +//invert_typelist +template<class T> +struct invert_typelist; + +template<int I, typename Tuple> +struct typelist_element; + +template<int I, typename Head, typename... Tail> +struct typelist_element<I, typelist<Head, Tail...> > +{ + typedef typename typelist_element<I-1, typelist<Tail...> >::type type; +}; + +template<typename Head, typename... Tail> +struct typelist_element<0, typelist<Head, Tail...> > +{ + typedef Head type; +}; + +template<int ...Ints, class ...Types> +typelist<typename typelist_element<(sizeof...(Types) - 1) - Ints, typelist<Types...> >::type...> + inverted_typelist(index_tuple<Ints...>, typelist<Types...>) +{ + return typelist<typename typelist_element<(sizeof...(Types) - 1) - Ints, typelist<Types...> >::type...>(); +} + +//sizeof_typelist +template<class Typelist> +struct sizeof_typelist; + +template<class ...Types> +struct sizeof_typelist< typelist<Types...> > +{ + static const std::size_t value = sizeof...(Types); +}; + +//invert_typelist_impl +template<class Typelist, class Indexes> +struct invert_typelist_impl; + + +template<class Typelist, int ...Ints> +struct invert_typelist_impl< Typelist, index_tuple<Ints...> > +{ + static const std::size_t last_idx = sizeof_typelist<Typelist>::value - 1; + typedef typelist + <typename typelist_element<last_idx - Ints, Typelist>::type...> type; +}; + +template<class Typelist, int Int> +struct invert_typelist_impl< Typelist, index_tuple<Int> > +{ + typedef Typelist type; +}; + +template<class Typelist> +struct invert_typelist_impl< Typelist, index_tuple<> > +{ + typedef Typelist type; +}; + +//invert_typelist +template<class Typelist> +struct invert_typelist; + +template<class ...Types> +struct invert_typelist< typelist<Types...> > +{ + typedef typelist<Types...> typelist_t; + typedef typename build_number_seq<sizeof...(Types)>::type indexes_t; + typedef typename invert_typelist_impl<typelist_t, indexes_t>::type type; +}; + +//Do pack +template<class Typelist> +struct do_pack; + +template<> +struct do_pack<typelist<> >; + +template<class Prev> +struct do_pack<typelist<Prev> > +{ + typedef Prev type; +}; + +template<class Prev, class Last> +struct do_pack<typelist<Prev, Last> > +{ + typedef typename Prev::template pack<Last> type; +}; + +template<class Prev, class ...Others> +struct do_pack<typelist<Prev, Others...> > +{ + typedef typename Prev::template pack + <typename do_pack<typelist<Others...> >::type> type; +}; + + +template<class ...Options> +struct pack_options +{ + typedef typelist<Options...> typelist_t; + typedef typename invert_typelist<typelist_t>::type inverted_typelist; + typedef typename do_pack<inverted_typelist>::type type; +}; + +#endif + +struct hook_defaults + : public pack_options + < none + , void_pointer<void*> + , link_mode<safe_link> + , tag<default_tag> + , optimize_size<false> + , store_hash<false> + , linear<false> + , optimize_multikey<false> + >::type +{}; + +/// @endcond + +} //namespace intrusive { +} //namespace boost { + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //#ifndef BOOST_INTRUSIVE_OPTIONS_HPP diff --git a/src/third_party/boost/boost/intrusive/parent_from_member.hpp b/src/third_party/boost/boost/intrusive/parent_from_member.hpp new file mode 100644 index 00000000000..882c0735319 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/parent_from_member.hpp @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2010-2010 +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_GET_PARENT_FROM_MEMBER_HPP +#define BOOST_INTRUSIVE_GET_PARENT_FROM_MEMBER_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/parent_from_member.hpp> + +namespace boost { +namespace intrusive { + +//! Given a pointer to a member and its corresponding pointer to data member, +//! this function returns the pointer of the parent containing that member. +//! Note: this function does not work with pointer to members that rely on +//! virtual inheritance. +template<class Parent, class Member> +inline Parent *get_parent_from_member(Member *member, const Member Parent::* ptr_to_member) +{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); } + +//! Given a const pointer to a member and its corresponding const pointer to data member, +//! this function returns the const pointer of the parent containing that member. +//! Note: this function does not work with pointer to members that rely on +//! virtual inheritance. +template<class Parent, class Member> +inline const Parent *get_parent_from_member(const Member *member, const Member Parent::* ptr_to_member) +{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); } + +} //namespace intrusive { +} //namespace boost { + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //#ifndef BOOST_INTRUSIVE_GET_PARENT_FROM_MEMBER_HPP diff --git a/src/third_party/boost/boost/intrusive/pointer_plus_bits.hpp b/src/third_party/boost/boost/intrusive/pointer_plus_bits.hpp new file mode 100644 index 00000000000..10b2fe0eb93 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/pointer_plus_bits.hpp @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_POINTER_PLUS_BITS_HPP +#define BOOST_INTRUSIVE_POINTER_PLUS_BITS_HPP + +#include <boost/intrusive/detail/mpl.hpp> //ls_zeros +#include <boost/intrusive/detail/assert.hpp> //BOOST_INTRUSIVE_INVARIANT_ASSERT + +namespace boost { +namespace intrusive { + +//!This trait class is used to know if a pointer +//!can embed extra bits of information if +//!it's going to be used to point to objects +//!with an alignment of "Alignment" bytes. +template<class VoidPointer, std::size_t Alignment> +struct max_pointer_plus_bits +{ + static const std::size_t value = 0; +}; + +//!This is a specialization for raw pointers. +//!Raw pointers can embed extra bits in the lower bits +//!if the alignment is multiple of 2pow(NumBits). +template<std::size_t Alignment> +struct max_pointer_plus_bits<void*, Alignment> +{ + static const std::size_t value = detail::ls_zeros<Alignment>::value; +}; + +//!This is class that is supposed to have static methods +//!to embed extra bits of information in a pointer. +//!This is a declaration and there is no default implementation, +//!because operations to embed the bits change with every pointer type. +//! +//!An implementation that detects that a pointer type whose +//!has_pointer_plus_bits<>::value is non-zero can make use of these +//!operations to embed the bits in the pointer. +template<class Pointer, std::size_t NumBits> +struct pointer_plus_bits; + +//!This is the specialization to embed extra bits of information +//!in a raw pointer. The extra bits are stored in the lower bits of the pointer. +template<class T, std::size_t NumBits> +struct pointer_plus_bits<T*, NumBits> +{ + static const std::size_t Mask = ((std::size_t(1u) << NumBits) - 1); + typedef T* pointer; + + static pointer get_pointer(pointer n) + { return pointer(std::size_t(n) & ~Mask); } + + static void set_pointer(pointer &n, pointer p) + { + BOOST_INTRUSIVE_INVARIANT_ASSERT(0 == (std::size_t(p) & Mask)); + n = pointer(std::size_t(p) | (std::size_t(n) & Mask)); + } + + static std::size_t get_bits(pointer n) + { return (std::size_t(n) & Mask); } + + static void set_bits(pointer &n, std::size_t c) + { + BOOST_INTRUSIVE_INVARIANT_ASSERT(c <= Mask); + n = pointer(std::size_t(get_pointer(n)) | c); + } +}; + +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_POINTER_PLUS_BITS_HPP diff --git a/src/third_party/boost/boost/intrusive/pointer_traits.hpp b/src/third_party/boost/boost/intrusive/pointer_traits.hpp new file mode 100644 index 00000000000..9f7d2fa4438 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/pointer_traits.hpp @@ -0,0 +1,265 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (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/intrusive for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_POINTER_TRAITS_HPP +#define BOOST_INTRUSIVE_POINTER_TRAITS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/workaround.hpp> +#include <boost/intrusive/detail/memory_util.hpp> +#include <boost/type_traits/integral_constant.hpp> +#include <cstddef> + +namespace boost { +namespace intrusive { + +//! pointer_traits is the implementation of C++11 std::pointer_traits class with some +//! extensions like castings. +//! +//! pointer_traits supplies a uniform interface to certain attributes of pointer-like types. +template <typename Ptr> +struct pointer_traits +{ + #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED + //!The pointer type + //!queried by this pointer_traits instantiation + typedef Ptr pointer; + + //!Ptr::element_type if such a type exists; otherwise, T if Ptr is a class + //!template instantiation of the form SomePointer<T, Args>, where Args is zero or + //!more type arguments ; otherwise , the specialization is ill-formed. + typedef unspecified_type element_type; + + //!Ptr::difference_type if such a type exists; otherwise, + //!std::ptrdiff_t. + typedef unspecified_type difference_type; + + //!Ptr::rebind<U> if such a type exists; otherwise, SomePointer<U, Args> if Ptr is + //!a class template instantiation of the form SomePointer<T, Args>, where Args is zero or + //!more type arguments ; otherwise, the instantiation of rebind is ill-formed. + //! + //!For portable code for C++03 and C++11, <pre>typename rebind_pointer<U>::type</pre> + //!shall be used instead of rebind<U> to obtain a pointer to U. + template <class U> using rebind = unspecified; + + //!Ptr::rebind<U> if such a type exists; otherwise, SomePointer<U, Args> if Ptr is + //!a class template instantiation of the form SomePointer<T, Args>, where Args is zero or + //!more type arguments ; otherwise, the instantiation of rebind is ill-formed. + //! + typedef element_type &reference; + #else + typedef Ptr pointer; + // + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT + ( boost::intrusive::detail::, Ptr, element_type + , boost::intrusive::detail::first_param<Ptr>) element_type; + // + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT + (boost::intrusive::detail::, Ptr, difference_type, std::ptrdiff_t) difference_type; + // + typedef typename boost::intrusive::detail::unvoid<element_type>::type& reference; + // + template <class U> struct rebind_pointer + { + typedef typename boost::intrusive::detail::type_rebinder<Ptr, U>::type type; + }; + + #if !defined(BOOST_NO_TEMPLATE_ALIASES) + template <class U> using rebind = typename boost::intrusive::detail::type_rebinder<Ptr, U>::type; + #endif + #endif //#if !defined(BOOST_NO_TEMPLATE_ALIASES) + + //! <b>Remark</b>: If element_type is (possibly cv-qualified) void, r type is unspecified; otherwise, + //! it is element_type &. + //! + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::pointer_to(r). + //! Non-standard extension: If such function does not exist, returns pointer(addressof(r)); + static pointer pointer_to(reference r) + { + //Non-standard extension, it does not require Ptr::pointer_to. If not present + //tries to converts &r to pointer. + const bool value = boost::intrusive::detail:: + has_member_function_callable_with_pointer_to + <Ptr, typename boost::intrusive::detail::unvoid<element_type &>::type>::value; + ::boost::integral_constant<bool, value> flag; + return pointer_traits::priv_pointer_to(flag, r); + } + + //! <b>Remark</b>: Non-standard extension. + //! + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::static_cast_from(r). + //! If such function does not exist, returns pointer_to(static_cast<element_type&>(*uptr)) + template<class UPtr> + static pointer static_cast_from(const UPtr &uptr) + { + const bool value = boost::intrusive::detail:: + has_member_function_callable_with_static_cast_from + <Ptr, const UPtr>::value; + ::boost::integral_constant<bool, value> flag; + return pointer_traits::priv_static_cast_from(flag, uptr); + } + + //! <b>Remark</b>: Non-standard extension. + //! + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::const_cast_from(r). + //! If such function does not exist, returns pointer_to(const_cast<element_type&>(*uptr)) + template<class UPtr> + static pointer const_cast_from(const UPtr &uptr) + { + const bool value = boost::intrusive::detail:: + has_member_function_callable_with_const_cast_from + <Ptr, const UPtr>::value; + ::boost::integral_constant<bool, value> flag; + return pointer_traits::priv_const_cast_from(flag, uptr); + } + + //! <b>Remark</b>: Non-standard extension. + //! + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::dynamic_cast_from(r). + //! If such function does not exist, returns pointer_to(*dynamic_cast<element_type*>(&*uptr)) + template<class UPtr> + static pointer dynamic_cast_from(const UPtr &uptr) + { + const bool value = boost::intrusive::detail:: + has_member_function_callable_with_dynamic_cast_from + <Ptr, const UPtr>::value; + ::boost::integral_constant<bool, value> flag; + return pointer_traits::priv_dynamic_cast_from(flag, uptr); + } + + ///@cond + private: + //priv_to_raw_pointer + template <class T> + static T* to_raw_pointer(T* p) + { return p; } + + template <class Pointer> + static typename pointer_traits<Pointer>::element_type* + to_raw_pointer(const Pointer &p) + { return pointer_traits::to_raw_pointer(p.operator->()); } + + //priv_pointer_to + static pointer priv_pointer_to(boost::true_type, typename boost::intrusive::detail::unvoid<element_type>::type& r) + { return Ptr::pointer_to(r); } + + static pointer priv_pointer_to(boost::false_type, typename boost::intrusive::detail::unvoid<element_type>::type& r) + { return pointer(boost::intrusive::detail::addressof(r)); } + + //priv_static_cast_from + template<class UPtr> + static pointer priv_static_cast_from(boost::true_type, const UPtr &uptr) + { return Ptr::static_cast_from(uptr); } + + template<class UPtr> + static pointer priv_static_cast_from(boost::false_type, const UPtr &uptr) + { return pointer_to(static_cast<element_type&>(*uptr)); } + + //priv_const_cast_from + template<class UPtr> + static pointer priv_const_cast_from(boost::true_type, const UPtr &uptr) + { return Ptr::const_cast_from(uptr); } + + template<class UPtr> + static pointer priv_const_cast_from(boost::false_type, const UPtr &uptr) + { return pointer_to(const_cast<element_type&>(*uptr)); } + + //priv_dynamic_cast_from + template<class UPtr> + static pointer priv_dynamic_cast_from(boost::true_type, const UPtr &uptr) + { return Ptr::dynamic_cast_from(uptr); } + + template<class UPtr> + static pointer priv_dynamic_cast_from(boost::false_type, const UPtr &uptr) + { return pointer_to(*dynamic_cast<element_type*>(&*uptr)); } + ///@endcond +}; + +///@cond + +// Remove cv qualification from Ptr parameter to pointer_traits: +template <typename Ptr> +struct pointer_traits<const Ptr> : pointer_traits<Ptr> {}; +template <typename Ptr> +struct pointer_traits<volatile Ptr> : pointer_traits<Ptr> { }; +template <typename Ptr> +struct pointer_traits<const volatile Ptr> : pointer_traits<Ptr> { }; +// Remove reference from Ptr parameter to pointer_traits: +template <typename Ptr> +struct pointer_traits<Ptr&> : pointer_traits<Ptr> { }; + +///@endcond + +//! Specialization of pointer_traits for raw pointers +//! +template <typename T> +struct pointer_traits<T*> +{ + typedef T element_type; + typedef T* pointer; + typedef std::ptrdiff_t difference_type; + + #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED + typedef T & reference; + //!typedef for <pre>U *</pre> + //! + //!For portable code for C++03 and C++11, <pre>typename rebind_pointer<U>::type</pre> + //!shall be used instead of rebind<U> to obtain a pointer to U. + template <class U> using rebind = U*; + #else + typedef typename boost::intrusive::detail::unvoid<element_type>::type& reference; + #if !defined(BOOST_NO_TEMPLATE_ALIASES) + template <class U> using rebind = U*; + #endif + #endif + + template <class U> struct rebind_pointer + { typedef U* type; }; + + //! <b>Returns</b>: addressof(r) + //! + static pointer pointer_to(reference r) + { return boost::intrusive::detail::addressof(r); } + + //! <b>Returns</b>: static_cast<pointer>(uptr) + //! + template<class U> + static pointer static_cast_from(U *uptr) + { return static_cast<pointer>(uptr); } + + //! <b>Returns</b>: const_cast<pointer>(uptr) + //! + template<class U> + static pointer const_cast_from(U *uptr) + { return const_cast<pointer>(uptr); } + + //! <b>Returns</b>: dynamic_cast<pointer>(uptr) + //! + template<class U> + static pointer dynamic_cast_from(U *uptr) + { return dynamic_cast<pointer>(uptr); } +}; + +} //namespace container { +} //namespace boost { + +#include <boost/intrusive/detail/config_end.hpp> + +#endif // ! defined(BOOST_INTRUSIVE_POINTER_TRAITS_HPP) diff --git a/src/third_party/boost/boost/intrusive/priority_compare.hpp b/src/third_party/boost/boost/intrusive/priority_compare.hpp new file mode 100644 index 00000000000..abde27ac0dd --- /dev/null +++ b/src/third_party/boost/boost/intrusive/priority_compare.hpp @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008 +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_PRIORITY_COMPARE_HPP +#define BOOST_INTRUSIVE_PRIORITY_COMPARE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> + +#include <functional> + +namespace boost { +namespace intrusive { + +template <class T> +struct priority_compare + : public std::binary_function<T, T, bool> +{ + bool operator()(const T &val, const T &val2) const + { + return priority_order(val, val2); + } +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_PRIORITY_COMPARE_HPP diff --git a/src/third_party/boost/boost/intrusive/rbtree.hpp b/src/third_party/boost/boost/intrusive/rbtree.hpp new file mode 100644 index 00000000000..26dfb4d8900 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/rbtree.hpp @@ -0,0 +1,1687 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_RBTREE_HPP +#define BOOST_INTRUSIVE_RBTREE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <algorithm> +#include <cstddef> +#include <functional> +#include <iterator> +#include <utility> + +#include <boost/intrusive/detail/assert.hpp> +#include <boost/static_assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/set_hook.hpp> +#include <boost/intrusive/detail/rbtree_node.hpp> +#include <boost/intrusive/detail/tree_node.hpp> +#include <boost/intrusive/detail/ebo_functor_holder.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/detail/function_detector.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/rbtree_algorithms.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/move/move.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +template <class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize> +struct setopt +{ + typedef ValueTraits value_traits; + typedef Compare compare; + typedef SizeType size_type; + static const bool constant_time_size = ConstantTimeSize; +}; + +template <class T> +struct set_defaults + : pack_options + < none + , base_hook<detail::default_set_hook> + , constant_time_size<true> + , size_type<std::size_t> + , compare<std::less<T> > + >::type +{}; + +/// @endcond + +//! The class template rbtree is an intrusive red-black tree container, that +//! is used to construct intrusive set and multiset containers. The no-throw +//! guarantee holds only, if the value_compare object +//! doesn't throw. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class rbtree_impl + : private detail::clear_on_destructor_base<rbtree_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + public: + typedef typename Config::value_traits value_traits; + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + /// @endcond + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + + typedef typename pointer_traits<pointer>::element_type value_type; + typedef value_type key_type; + typedef typename pointer_traits<pointer>::reference reference; + typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef typename pointer_traits<const_pointer>::difference_type difference_type; + typedef typename Config::size_type size_type; + typedef typename Config::compare value_compare; + typedef value_compare key_compare; + typedef tree_iterator<rbtree_impl, false> iterator; + typedef tree_iterator<rbtree_impl, true> const_iterator; + typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator; + typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef rbtree_algorithms<node_traits> node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + /// @cond + private: + typedef detail::size_holder<constant_time_size, size_type> size_traits; + + //noncopyable + BOOST_MOVABLE_BUT_NOT_COPYABLE(rbtree_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + //Constant-time size is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink))); + + struct header_plus_size : public size_traits + { node header_; }; + + struct node_plus_pred_t : public detail::ebo_functor_holder<value_compare> + { + node_plus_pred_t(const value_compare &comp) + : detail::ebo_functor_holder<value_compare>(comp) + {} + header_plus_size header_plus_size_; + }; + + struct data_t : public rbtree_impl::value_traits + { + typedef typename rbtree_impl::value_traits value_traits; + data_t(const value_compare & comp, const value_traits &val_traits) + : value_traits(val_traits), node_plus_pred_(comp) + {} + node_plus_pred_t node_plus_pred_; + } data_; + + const value_compare &priv_comp() const + { return data_.node_plus_pred_.get(); } + + value_compare &priv_comp() + { return data_.node_plus_pred_.get(); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + node_ptr priv_header_ptr() + { return pointer_traits<node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); } + + const_node_ptr priv_header_ptr() const + { return pointer_traits<const_node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); } + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + size_traits &priv_size_traits() + { return data_.node_plus_pred_.header_plus_size_; } + + const size_traits &priv_size_traits() const + { return data_.node_plus_pred_.header_plus_size_; } + + const real_value_traits &get_real_value_traits(detail::bool_<false>) const + { return data_; } + + const real_value_traits &get_real_value_traits(detail::bool_<true>) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::bool_<false>) + { return data_; } + + real_value_traits &get_real_value_traits(detail::bool_<true>) + { return data_.get_value_traits(*this); } + + protected: + value_compare &prot_comp() + { return priv_comp(); } + + const node &prot_header_node() const + { return data_.node_plus_pred_.header_plus_size_.header_; } + + node &prot_header_node() + { return data_.node_plus_pred_.header_plus_size_.header_; } + + void prot_set_size(size_type s) + { this->priv_size_traits().set_size(s); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + typedef typename node_algorithms::insert_commit_data insert_commit_data; + + //! <b>Effects</b>: Constructs an empty tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructorof the value_compare object throws. Basic guarantee. + rbtree_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty tree and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. Basic guarantee. + template<class Iterator> + rbtree_impl( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + if(unique) + this->insert_unique(b, e); + else + this->insert_equal(b, e); + } + + //! <b>Effects</b>: to-do + //! + rbtree_impl(BOOST_RV_REF(rbtree_impl) x) + : data_(::boost::move(x.priv_comp()), ::boost::move(x.priv_value_traits())) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + this->swap(x); + } + + //! <b>Effects</b>: to-do + //! + rbtree_impl& operator=(BOOST_RV_REF(rbtree_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called), but the nodes according to + //! the value_traits template parameter are reinitialized and thus can be reused. + //! + //! <b>Complexity</b>: Linear to elements contained in *this. + //! + //! <b>Throws</b>: Nothing. + ~rbtree_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return cbegin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return const_iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return iterator (this->priv_header_ptr(), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return cend(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return const_iterator (uncast(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return const_reverse_iterator(begin()); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the rbtree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static rbtree_impl &container_from_end_iterator(iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the rbtree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const rbtree_impl &container_from_end_iterator(const_iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: it must be a valid iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static rbtree_impl &container_from_iterator(iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Precondition</b>: it must be a valid end const_iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const rbtree_impl &container_from_iterator(const_iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Effects</b>: Returns the value_compare object used by the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return priv_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return node_algorithms::unique(this->priv_header_ptr()); } + + //! <b>Effects</b>: Returns the number of elements stored in the tree. + //! + //! <b>Complexity</b>: Linear to elements contained in *this + //! if constant-time size option is disabled. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { + if(constant_time_size) + return this->priv_size_traits().get_size(); + else{ + return (size_type)node_algorithms::size(this->priv_header_ptr()); + } + } + + //! <b>Effects</b>: Swaps the contents of two rbtrees. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the comparison functor's swap call throws. + void swap(rbtree_impl& other) + { + //This can throw + using std::swap; + swap(priv_comp(), priv_comp()); + //These can't throw + node_algorithms::swap_tree(this->priv_header_ptr(), node_ptr(other.priv_header_ptr())); + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree before the upper bound. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(reference value) + { + detail::key_nodeptr_comp<value_compare, rbtree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret(node_algorithms::insert_equal_upper_bound + (this->priv_header_ptr(), to_insert, key_node_comp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator. + //! + //! <b>Effects</b>: Inserts x into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case) + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(const_iterator hint, reference value) + { + detail::key_nodeptr_comp<value_compare, rbtree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret(node_algorithms::insert_equal + (this->priv_header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a each element of a range into the tree + //! before the upper bound of the key of each element. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_equal(Iterator b, Iterator e) + { + iterator iend(this->end()); + for (; b != e; ++b) + this->insert_equal(iend, *b); + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree if the value + //! is not already present. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert_unique(reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(value, priv_comp(), commit_data); + if(!ret.second) + return ret; + return std::pair<iterator, bool> (insert_unique_commit(value, commit_data), true); + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator + //! + //! <b>Effects</b>: Tries to insert x into the tree, using "hint" as a hint + //! to where it will be inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time (two comparisons in the worst case) + //! if t is inserted immediately before hint. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_unique(const_iterator hint, reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(hint, value, priv_comp(), commit_data); + if(!ret.second) + return ret.first; + return insert_unique_commit(value, commit_data); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Tries to insert each element of a range into the tree. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_unique(Iterator b, Iterator e) + { + if(this->empty()){ + iterator iend(this->end()); + for (; b != e; ++b) + this->insert_unique(iend, *b); + } + else{ + for (; b != e; ++b) + this->insert_unique(*b); + } + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), key, comp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), hint.pointed_node(), key, comp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the container between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + node_algorithms::insert_unique_commit + (this->priv_header_ptr(), to_insert, commit_data); + this->priv_size_traits().increment(); + return iterator(to_insert, this); + } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" tree ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + this->priv_size_traits().increment(); + return iterator(node_algorithms::insert_before + (this->priv_header_ptr(), pos.pointed_node(), to_insert), this); + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no less + //! than the greatest inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + this->priv_size_traits().increment(); + node_algorithms::push_back(this->priv_header_ptr(), to_insert); + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no greater + //! than the minimum inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + this->priv_size_traits().increment(); + node_algorithms::push_front(this->priv_header_ptr(), to_insert); + } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { + const_iterator ret(i); + ++ret; + node_ptr to_erase(i.pointed_node()); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); + node_algorithms::erase(this->priv_header_ptr(), to_erase); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + return ret.unconst(); + } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { size_type n; return private_erase(b, e, n); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return this->erase(value, priv_comp()); } + + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { + node_ptr to_erase(i.pointed_node()); + iterator ret(this->erase(i)); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + return ret; + } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { + std::pair<iterator,iterator> p = this->equal_range(value); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { size_type n; return private_erase(b, e, n, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { + if(safemode_or_autounlink){ + this->clear_and_dispose(detail::null_disposer()); + } + else{ + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + } + + //! <b>Effects</b>: Erases all of the elements calling disposer(p) for + //! each node to be erased. + //! <b>Complexity</b>: Average complexity for is at most O(log(size() + N)), + //! where N is the number of elements in the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. Calls N times to disposer functor. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { + node_algorithms::clear_and_dispose(this->priv_header_ptr() + , detail::node_disposer<Disposer, rbtree_impl>(disposer, this)); + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given value. + //! + //! <b>Throws</b>: Nothing. + size_type count(const_reference value) const + { return this->count(value, priv_comp()); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType &key, KeyValueCompare comp) const + { + std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp); + return std::distance(ret.first, ret.second); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator lower_bound(const_reference value) + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator lower_bound(const_reference value) const + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator upper_bound(const_reference value) + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator upper_bound(const_reference value) const + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator find(const_reference value) + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + return iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator find(const_reference value) const + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + return const_iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<iterator,iterator> equal_range(const_reference value) + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<iterator, iterator>(iterator(ret.first, this), iterator(ret.second, this)); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, rbtree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<const_iterator, const_iterator>(const_iterator(ret.first, this), const_iterator(ret.second, this)); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const rbtree_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + if(!src.empty()){ + detail::exception_disposer<rbtree_impl, Disposer> + rollback(*this, disposer); + node_algorithms::clone + (const_node_ptr(src.priv_header_ptr()) + ,node_ptr(this->priv_header_ptr()) + ,detail::node_cloner<Cloner, rbtree_impl>(cloner, this) + ,detail::node_disposer<Disposer, rbtree_impl>(disposer, this)); + this->priv_size_traits().set_size(src.priv_size_traits().get_size()); + this->priv_comp() = src.priv_comp(); + rollback.release(); + } + } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { + node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance + (this->priv_header_ptr())); + if(!to_be_disposed) + return 0; + this->priv_size_traits().decrement(); + if(safemode_or_autounlink)//If this is commented does not work with normal_link + node_algorithms::init(to_be_disposed); + return get_real_value_traits().to_value_ptr(to_be_disposed); + } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { + node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this) + , this->priv_header_ptr() + , get_real_value_traits().to_node_ptr(with_this)); + if(safemode_or_autounlink) + node_algorithms::init(replace_this.pointed_node()); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return iterator (value_traits::to_node_ptr(value), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return iterator (value_traits::to_node_ptr(value), this); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this); } + + //! <b>Requires</b>: value shall not be in a tree. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { node_algorithms::init(value_traits::to_node_ptr(value)); } + + //! <b>Effects</b>: removes "value" from the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic time. + //! + //! <b>Note</b>: This static function is only usable with non-constant + //! time size containers that have stateless comparison functors. + //! + //! If the user calls + //! this function with a constant time size container or stateful comparison + //! functor a compilation error will be issued. + static void remove_node(reference value) + { + BOOST_STATIC_ASSERT((!constant_time_size)); + node_ptr to_remove(value_traits::to_node_ptr(value)); + node_algorithms::unlink(to_remove); + if(safemode_or_autounlink) + node_algorithms::init(to_remove); + } + + /// @cond + private: + template<class Disposer> + iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer) + { + for(n = 0; b != e; ++n) + this->erase_and_dispose(b++, disposer); + return b.unconst(); + } + + iterator private_erase(const_iterator b, const_iterator e, size_type &n) + { + for(n = 0; b != e; ++n) + this->erase(b++); + return b.unconst(); + } + /// @endcond + + private: + static rbtree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) + { + header_plus_size *r = detail::parent_from_member<header_plus_size, node> + ( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), &header_plus_size::header_); + node_plus_pred_t *n = detail::parent_from_member + <node_plus_pred_t, header_plus_size>(r, &node_plus_pred_t::header_plus_size_); + data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(n, &data_t::node_plus_pred_); + rbtree_impl *rb = detail::parent_from_member<rbtree_impl, data_t>(d, &rbtree_impl::data_); + return *rb; + } + + static rbtree_impl &priv_container_from_iterator(const const_iterator &it) + { return priv_container_from_end_iterator(it.end_iterator_from_it()); } +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator< +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const rbtree_impl<T, Options...> &x, const rbtree_impl<T, Options...> &y) +#else +(const rbtree_impl<Config> &x, const rbtree_impl<Config> &y) +#endif +{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +bool operator== +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const rbtree_impl<T, Options...> &x, const rbtree_impl<T, Options...> &y) +#else +(const rbtree_impl<Config> &x, const rbtree_impl<Config> &y) +#endif +{ + typedef rbtree_impl<Config> tree_type; + typedef typename tree_type::const_iterator const_iterator; + + if(tree_type::constant_time_size && x.size() != y.size()){ + return false; + } + const_iterator end1 = x.end(); + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + if(tree_type::constant_time_size){ + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; + } + else{ + const_iterator end2 = y.end(); + while (i1 != end1 && i2 != end2 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1 && i2 == end2; + } +} + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const rbtree_impl<T, Options...> &x, const rbtree_impl<T, Options...> &y) +#else +(const rbtree_impl<Config> &x, const rbtree_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const rbtree_impl<T, Options...> &x, const rbtree_impl<T, Options...> &y) +#else +(const rbtree_impl<Config> &x, const rbtree_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const rbtree_impl<T, Options...> &x, const rbtree_impl<T, Options...> &y) +#else +(const rbtree_impl<Config> &x, const rbtree_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const rbtree_impl<T, Options...> &x, const rbtree_impl<T, Options...> &y) +#else +(const rbtree_impl<Config> &x, const rbtree_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(rbtree_impl<T, Options...> &x, rbtree_impl<T, Options...> &y) +#else +(rbtree_impl<Config> &x, rbtree_impl<Config> &y) +#endif +{ x.swap(y); } + +/// @cond +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none + > +#else +template<class T, class ...Options> +#endif +struct make_rbtree_opt +{ + typedef typename pack_options + < set_defaults<T>, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + + typedef setopt + < value_traits + , typename packed_options::compare + , typename packed_options::size_type + , packed_options::constant_time_size + > type; +}; +/// @endcond + +//! Helper metafunction to define a \c rbtree that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_rbtree +{ + /// @cond + typedef rbtree_impl + < typename make_rbtree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class rbtree + : public make_rbtree<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_rbtree + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(rbtree) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::real_value_traits real_value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + + rbtree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + rbtree( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(unique, b, e, cmp, v_traits) + {} + + rbtree(BOOST_RV_REF(rbtree) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + rbtree& operator=(BOOST_RV_REF(rbtree) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static rbtree &container_from_end_iterator(iterator end_iterator) + { return static_cast<rbtree &>(Base::container_from_end_iterator(end_iterator)); } + + static const rbtree &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const rbtree &>(Base::container_from_end_iterator(end_iterator)); } + + static rbtree &container_from_it(iterator it) + { return static_cast<rbtree &>(Base::container_from_iterator(it)); } + + static const rbtree &container_from_it(const_iterator it) + { return static_cast<const rbtree &>(Base::container_from_iterator(it)); } +}; + +#endif + + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_RBTREE_HPP diff --git a/src/third_party/boost/boost/intrusive/rbtree_algorithms.hpp b/src/third_party/boost/boost/intrusive/rbtree_algorithms.hpp new file mode 100644 index 00000000000..de012c2cad8 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/rbtree_algorithms.hpp @@ -0,0 +1,910 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +// The internal implementation of red-black trees is based on that of SGI STL +// stl_tree.h file: +// +// Copyright (c) 1996,1997 +// Silicon Graphics Computer Systems, Inc. +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. Silicon Graphics makes no +// representations about the suitability of this software for any +// purpose. It is provided "as is" without express or implied warranty. +// +// +// Copyright (c) 1994 +// Hewlett-Packard Company +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. Hewlett-Packard Company makes no +// representations about the suitability of this software for any +// purpose. It is provided "as is" without express or implied warranty. +// +// The tree destruction algorithm is based on Julienne Walker and The EC Team code: +// +// This code is in the public domain. Anyone may use it or change it in any way that +// they see fit. The author assumes no responsibility for damages incurred through +// use of the original code or any variations thereof. +// +// It is requested, but not required, that due credit is given to the original author +// and anyone who has modified the code through a header comment, such as this one. + +#ifndef BOOST_INTRUSIVE_RBTREE_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_RBTREE_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +#include <cstddef> +#include <boost/intrusive/intrusive_fwd.hpp> + +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/tree_algorithms.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace intrusive { + +//! rbtree_algorithms provides basic algorithms to manipulate +//! nodes forming a red-black tree. The insertion and deletion algorithms are +//! based on those in Cormen, Leiserson, and Rivest, Introduction to Algorithms +//! (MIT Press, 1990), except that +//! +//! (1) the header node is maintained with links not only to the root +//! but also to the leftmost node of the tree, to enable constant time +//! begin(), and to the rightmost node of the tree, to enable linear time +//! performance when used with the generic set algorithms (set_union, +//! etc.); +//! +//! (2) when a node being deleted has two children its successor node is +//! relinked into its place, rather than copied, so that the only +//! pointers invalidated are those referring to the deleted node. +//! +//! rbtree_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <tt>color</tt>: The type that can store the color of a node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_parent(const_node_ptr n);</tt> +//! +//! <tt>static void set_parent(node_ptr n, node_ptr parent);</tt> +//! +//! <tt>static node_ptr get_left(const_node_ptr n);</tt> +//! +//! <tt>static void set_left(node_ptr n, node_ptr left);</tt> +//! +//! <tt>static node_ptr get_right(const_node_ptr n);</tt> +//! +//! <tt>static void set_right(node_ptr n, node_ptr right);</tt> +//! +//! <tt>static color get_color(const_node_ptr n);</tt> +//! +//! <tt>static void set_color(node_ptr n, color c);</tt> +//! +//! <tt>static color black();</tt> +//! +//! <tt>static color red();</tt> +template<class NodeTraits> +class rbtree_algorithms +{ + public: + typedef NodeTraits node_traits; + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + typedef typename NodeTraits::color color; + + /// @cond + private: + + typedef detail::tree_algorithms<NodeTraits> tree_algorithms; + + template<class F> + struct rbtree_node_cloner + : private detail::ebo_functor_holder<F> + { + typedef detail::ebo_functor_holder<F> base_t; + + rbtree_node_cloner(F f) + : base_t(f) + {} + + node_ptr operator()(const node_ptr & p) + { + node_ptr n = base_t::get()(p); + NodeTraits::set_color(n, NodeTraits::get_color(p)); + return n; + } + }; + + struct rbtree_erase_fixup + { + void operator()(const node_ptr & to_erase, const node_ptr & successor) + { + //Swap color of y and z + color tmp(NodeTraits::get_color(successor)); + NodeTraits::set_color(successor, NodeTraits::get_color(to_erase)); + NodeTraits::set_color(to_erase, tmp); + } + }; + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + /// @endcond + + public: + static node_ptr begin_node(const const_node_ptr & header) + { return tree_algorithms::begin_node(header); } + + static node_ptr end_node(const const_node_ptr & header) + { return tree_algorithms::end_node(header); } + + //! This type is the information that will be + //! filled by insert_unique_check + typedef typename tree_algorithms::insert_commit_data insert_commit_data; + + //! <b>Requires</b>: header1 and header2 must be the header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two trees. After the function header1 will contain + //! links to the second tree and header2 will have links to the first tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static void swap_tree(const node_ptr & header1, const node_ptr & header2) + { return tree_algorithms::swap_tree(header1, header2); } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & node2) + { + if(node1 == node2) + return; + + node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2)); + swap_nodes(node1, header1, node2, header2); + } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees with header header1 and header2. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) + { + if(node1 == node2) return; + + tree_algorithms::swap_nodes(node1, header1, node2, header2); + //Swap color + color c = NodeTraits::get_color(node1); + NodeTraits::set_color(node1, NodeTraits::get_color(node2)); + NodeTraits::set_color(node2, c); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing and comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) + { + if(node_to_be_replaced == new_node) + return; + replace_node(node_to_be_replaced, tree_algorithms::get_header(node_to_be_replaced), new_node); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! with header "header" and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::replace_node(node_to_be_replaced, header, new_node); + NodeTraits::set_color(new_node, NodeTraits::get_color(node_to_be_replaced)); + } + + //! <b>Requires</b>: node is a tree node but not the header. + //! + //! <b>Effects</b>: Unlinks the node and rebalances the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + static void unlink(const node_ptr & node) + { + node_ptr x = NodeTraits::get_parent(node); + if(x){ + while(!is_header(x)) + x = NodeTraits::get_parent(x); + erase(x, node); + } + } + + //! <b>Requires</b>: header is the header of a tree. + //! + //! <b>Effects</b>: Unlinks the leftmost node from the tree, and + //! updates the header link to the new leftmost node. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + static node_ptr unlink_leftmost_without_rebalance(const node_ptr & header) + { return tree_algorithms::unlink_leftmost_without_rebalance(header); } + + //! <b>Requires</b>: node is a node of the tree or an node initialized + //! by init(...). + //! + //! <b>Effects</b>: Returns true if the node is initialized by init(). + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + static bool unique(const const_node_ptr & node) + { return tree_algorithms::unique(node); } + + //! <b>Requires</b>: node is a node of the tree but it's not the header. + //! + //! <b>Effects</b>: Returns the number of nodes of the subtree. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & node) + { return tree_algorithms::count(node); } + + //! <b>Requires</b>: header is the header node of the tree. + //! + //! <b>Effects</b>: Returns the number of nodes above the header. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t size(const const_node_ptr & header) + { return tree_algorithms::size(header); } + + //! <b>Requires</b>: p is a node from the tree except the header. + //! + //! <b>Effects</b>: Returns the next node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr next_node(const node_ptr & p) + { return tree_algorithms::next_node(p); } + + //! <b>Requires</b>: p is a node from the tree except the leftmost node. + //! + //! <b>Effects</b>: Returns the previous node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr prev_node(const node_ptr & p) + { return tree_algorithms::prev_node(p); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: After the function unique(node) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init(const node_ptr & node) + { tree_algorithms::init(node); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: Initializes the header to represent an empty tree. + //! unique(header) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init_header(const node_ptr & header) + { + tree_algorithms::init_header(header); + NodeTraits::set_color(header, NodeTraits::red()); + } + + //! <b>Requires</b>: header must be the header of a tree, z a node + //! of that tree and z != header. + //! + //! <b>Effects</b>: Erases node "z" from the tree with header "header". + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr erase(const node_ptr & header, const node_ptr & z) + { + typename tree_algorithms::data_for_rebalance info; + tree_algorithms::erase(header, z, rbtree_erase_fixup(), info); + node_ptr x = info.x; + node_ptr x_parent = info.x_parent; + + //Rebalance rbtree + if(NodeTraits::get_color(z) != NodeTraits::red()){ + rebalance_after_erasure(header, x, x_parent); + } + return z; + } + + //! <b>Requires</b>: "cloner" must be a function + //! object taking a node_ptr and returning a new cloned node of it. "disposer" must + //! take a node_ptr and shouldn't throw. + //! + //! <b>Effects</b>: First empties target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! Then, duplicates the entire tree pointed by "source_header" cloning each + //! source node with <tt>node_ptr Cloner::operator()(const node_ptr &)</tt> to obtain + //! the nodes of the target tree. If "cloner" throws, the cloned target nodes + //! are disposed using <tt>void disposer(const node_ptr &)</tt>. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template <class Cloner, class Disposer> + static void clone + (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) + { + rbtree_node_cloner<Cloner> new_cloner(cloner); + tree_algorithms::clone(source_header, target_header, new_cloner, disposer); + } + + //! <b>Requires</b>: "disposer" must be an object function + //! taking a node_ptr parameter and shouldn't throw. + //! + //! <b>Effects</b>: Empties the target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template<class Disposer> + static void clear_and_dispose(const node_ptr & header, Disposer disposer) + { tree_algorithms::clear_and_dispose(header, disposer); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is + //! not less than "key" according to "comp" or "header" if that element does + //! not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr lower_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::lower_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is greater + //! than "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr upper_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::upper_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the element that is equivalent to + //! "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr find + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::find(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an a pair of node_ptr delimiting a range containing + //! all elements that are equivalent to "key" according to "comp" or an + //! empty range that indicates the position where those elements would be + //! if they there are no equivalent elements. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, node_ptr> equal_range + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::equal_range(header, key, comp); } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the upper bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal_upper_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp) + { + tree_algorithms::insert_equal_upper_bound(h, new_node, comp); + rebalance_after_insertion(h, new_node); + return new_node; + } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the lower bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal_lower_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp) + { + tree_algorithms::insert_equal_lower_bound(h, new_node, comp); + rebalance_after_insertion(h, new_node); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. "hint" is node from + //! the "header"'s tree. + //! + //! <b>Effects</b>: Inserts new_node into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case). + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if new_node is inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal + (const node_ptr & header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp) + { + tree_algorithms::insert_equal(header, hint, new_node, comp); + rebalance_after_insertion(header, new_node); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "pos" must be a valid iterator or header (end) node. + //! "pos" must be an iterator pointing to the successor to "new_node" + //! once inserted according to the order of already inserted nodes. This function does not + //! check "pos" and this precondition must be guaranteed by the caller. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "pos" is not the successor of the newly inserted "new_node" + //! tree invariants might be broken. + static node_ptr insert_before + (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node) + { + tree_algorithms::insert_before(header, pos, new_node); + rebalance_after_insertion(header, new_node); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering no less than the + //! greatest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is less than the greatest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + static void push_back(const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::push_back(header, new_node); + rebalance_after_insertion(header, new_node); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering, no greater than the + //! lowest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is greater than the lowest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + static void push_front(const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::push_front(header, new_node); + rebalance_after_insertion(header, new_node); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { return tree_algorithms::insert_unique_check(header, key, comp, commit_data); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! "hint" is node from the "header"'s tree. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" using "hint" as a hint to where it should be + //! inserted and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! If "hint" is the upper_bound the function has constant time + //! complexity (two comparisons in the worst case). + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic, but it is + //! amortized constant time if new_node should be inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const node_ptr &hint, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { return tree_algorithms::insert_unique_check(header, hint, key, comp, commit_data); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "commit_data" must have been obtained from a previous call to + //! "insert_unique_check". No objects should have been inserted or erased + //! from the set between the "insert_unique_check" that filled "commit_data" + //! and the call to "insert_commit". + //! + //! + //! <b>Effects</b>: Inserts new_node in the set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_unique_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + static void insert_unique_commit + (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data) + { + tree_algorithms::insert_unique_commit(header, new_value, commit_data); + rebalance_after_insertion(header, new_value); + } + + //! <b>Requires</b>: "n" must be a node inserted in a tree. + //! + //! <b>Effects</b>: Returns a pointer to the header node of the tree. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_header(const node_ptr & n) + { return tree_algorithms::get_header(n); } + + /// @cond + private: + + //! <b>Requires</b>: p is a node of a tree. + //! + //! <b>Effects</b>: Returns true if p is the header of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool is_header(const const_node_ptr & p) + { + return NodeTraits::get_color(p) == NodeTraits::red() && + tree_algorithms::is_header(p); + //return NodeTraits::get_color(p) == NodeTraits::red() && + // NodeTraits::get_parent(NodeTraits::get_parent(p)) == p; + } + + static void rebalance_after_erasure(const node_ptr & header, const node_ptr &xnode, const node_ptr &xnode_parent) + { + node_ptr x(xnode), x_parent(xnode_parent); + while(x != NodeTraits::get_parent(header) && (x == node_ptr() || NodeTraits::get_color(x) == NodeTraits::black())){ + if(x == NodeTraits::get_left(x_parent)){ + node_ptr w = NodeTraits::get_right(x_parent); + if(NodeTraits::get_color(w) == NodeTraits::red()){ + NodeTraits::set_color(w, NodeTraits::black()); + NodeTraits::set_color(x_parent, NodeTraits::red()); + tree_algorithms::rotate_left(x_parent, header); + w = NodeTraits::get_right(x_parent); + } + if((NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()) && + (NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black())){ + NodeTraits::set_color(w, NodeTraits::red()); + x = x_parent; + x_parent = NodeTraits::get_parent(x_parent); + } + else { + if(NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()){ + NodeTraits::set_color(NodeTraits::get_left(w), NodeTraits::black()); + NodeTraits::set_color(w, NodeTraits::red()); + tree_algorithms::rotate_right(w, header); + w = NodeTraits::get_right(x_parent); + } + NodeTraits::set_color(w, NodeTraits::get_color(x_parent)); + NodeTraits::set_color(x_parent, NodeTraits::black()); + if(NodeTraits::get_right(w)) + NodeTraits::set_color(NodeTraits::get_right(w), NodeTraits::black()); + tree_algorithms::rotate_left(x_parent, header); + break; + } + } + else { + // same as above, with right_ <-> left_. + node_ptr w = NodeTraits::get_left(x_parent); + if(NodeTraits::get_color(w) == NodeTraits::red()){ + NodeTraits::set_color(w, NodeTraits::black()); + NodeTraits::set_color(x_parent, NodeTraits::red()); + tree_algorithms::rotate_right(x_parent, header); + w = NodeTraits::get_left(x_parent); + } + if((NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()) && + (NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black())){ + NodeTraits::set_color(w, NodeTraits::red()); + x = x_parent; + x_parent = NodeTraits::get_parent(x_parent); + } + else { + if(NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()){ + NodeTraits::set_color(NodeTraits::get_right(w), NodeTraits::black()); + NodeTraits::set_color(w, NodeTraits::red()); + tree_algorithms::rotate_left(w, header); + w = NodeTraits::get_left(x_parent); + } + NodeTraits::set_color(w, NodeTraits::get_color(x_parent)); + NodeTraits::set_color(x_parent, NodeTraits::black()); + if(NodeTraits::get_left(w)) + NodeTraits::set_color(NodeTraits::get_left(w), NodeTraits::black()); + tree_algorithms::rotate_right(x_parent, header); + break; + } + } + } + if(x) + NodeTraits::set_color(x, NodeTraits::black()); + } + + + static void rebalance_after_insertion(const node_ptr & header, const node_ptr &pnode) + { + node_ptr p(pnode); + NodeTraits::set_color(p, NodeTraits::red()); + while(p != NodeTraits::get_parent(header) && NodeTraits::get_color(NodeTraits::get_parent(p)) == NodeTraits::red()){ + node_ptr p_parent(NodeTraits::get_parent(p)); + node_ptr p_parent_parent(NodeTraits::get_parent(p_parent)); + if(tree_algorithms::is_left_child(p_parent)){ + node_ptr x = NodeTraits::get_right(p_parent_parent); + if(x && NodeTraits::get_color(x) == NodeTraits::red()){ + NodeTraits::set_color(p_parent, NodeTraits::black()); + NodeTraits::set_color(p_parent_parent, NodeTraits::red()); + NodeTraits::set_color(x, NodeTraits::black()); + p = p_parent_parent; + } + else { + if(!tree_algorithms::is_left_child(p)){ + p = p_parent; + tree_algorithms::rotate_left(p, header); + } + node_ptr new_p_parent(NodeTraits::get_parent(p)); + node_ptr new_p_parent_parent(NodeTraits::get_parent(new_p_parent)); + NodeTraits::set_color(new_p_parent, NodeTraits::black()); + NodeTraits::set_color(new_p_parent_parent, NodeTraits::red()); + tree_algorithms::rotate_right(new_p_parent_parent, header); + } + } + else{ + node_ptr x = NodeTraits::get_left(p_parent_parent); + if(x && NodeTraits::get_color(x) == NodeTraits::red()){ + NodeTraits::set_color(p_parent, NodeTraits::black()); + NodeTraits::set_color(p_parent_parent, NodeTraits::red()); + NodeTraits::set_color(x, NodeTraits::black()); + p = p_parent_parent; + } + else{ + if(tree_algorithms::is_left_child(p)){ + p = p_parent; + tree_algorithms::rotate_right(p, header); + } + node_ptr new_p_parent(NodeTraits::get_parent(p)); + node_ptr new_p_parent_parent(NodeTraits::get_parent(new_p_parent)); + NodeTraits::set_color(new_p_parent, NodeTraits::black()); + NodeTraits::set_color(new_p_parent_parent, NodeTraits::red()); + tree_algorithms::rotate_left(new_p_parent_parent, header); + } + } + } + NodeTraits::set_color(NodeTraits::get_parent(header), NodeTraits::black()); + } + /// @endcond +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_RBTREE_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/set.hpp b/src/third_party/boost/boost/intrusive/set.hpp new file mode 100644 index 00000000000..9b0207023d5 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/set.hpp @@ -0,0 +1,2384 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_SET_HPP +#define BOOST_INTRUSIVE_SET_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/rbtree.hpp> +#include <iterator> +#include <boost/move/move.hpp> + +namespace boost { +namespace intrusive { + +//! The class template set is an intrusive container, that mimics most of +//! the interface of std::set as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class set_impl +{ + /// @cond + typedef rbtree_impl<Config> tree_type; + BOOST_MOVABLE_BUT_NOT_COPYABLE(set_impl) + + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + //static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + + /// @cond + private: + tree_type tree_; + + protected: + node &prot_header_node(){ return tree_.prot_header_node(); } + node const &prot_header_node() const{ return tree_.prot_header_node(); } + void prot_set_size(size_type s){ tree_.prot_set_size(s); } + value_compare &prot_comp(){ return tree_.prot_comp(); } + + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare object throws. + set_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty set and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is std::distance(last, first). + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + set_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(true, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + set_impl(BOOST_RV_REF(set_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + set_impl& operator=(BOOST_RV_REF(set_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~set_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of set. + //! + //! <b>Effects</b>: Returns a reference to the set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static set_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &set_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of set. + //! + //! <b>Effects</b>: Returns a const reference to the set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const set_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of set. + //! + //! <b>Effects</b>: Returns a reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static set_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of set. + //! + //! <b>Effects</b>: Returns a const reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const set_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &set_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the set. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two sets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(set_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const set_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to inserts value into the set. + //! + //! <b>Returns</b>: If the value + //! is not already present inserts it and returns a pair containing the + //! iterator to the new value and true. If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert(reference value) + { return tree_.insert_unique(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to to insert x into the set, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the + //! new element was inserted into the set. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_unique(hint, value); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the set, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(key, key_value_comp, commit_data); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the set, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(hint, key, key_value_comp, commit_data); } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the set between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_commit(reference value, const insert_commit_data &commit_data) + { return tree_.insert_unique_commit(value, commit_data); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the set. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_unique(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate. "value" must not be equal to any + //! inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" or "value" is not unique tree ordering and uniqueness + //! invariants will be broken respectively. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be greater than + //! any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than or equal to the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be less + //! than any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than or equal to the the mimum inserted key tree ordering or uniqueness + //! invariants will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size()) + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If the comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). Basic guarantee. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.find(value) != end(); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp) != end(); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a set/multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + /// @cond + friend bool operator==(const set_impl &x, const set_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const set_impl &x, const set_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const set_impl<T, Options...> &x, const set_impl<T, Options...> &y) +#else +(const set_impl<Config> &x, const set_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const set_impl<T, Options...> &x, const set_impl<T, Options...> &y) +#else +(const set_impl<Config> &x, const set_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const set_impl<T, Options...> &x, const set_impl<T, Options...> &y) +#else +(const set_impl<Config> &x, const set_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const set_impl<T, Options...> &x, const set_impl<T, Options...> &y) +#else +(const set_impl<Config> &x, const set_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(set_impl<T, Options...> &x, set_impl<T, Options...> &y) +#else +(set_impl<Config> &x, set_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c set that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_set +{ + /// @cond + typedef set_impl + < typename make_rbtree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class set + : public make_set<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_set + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(set) + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + set( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + set(BOOST_RV_REF(set) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + set& operator=(BOOST_RV_REF(set) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static set &container_from_end_iterator(iterator end_iterator) + { return static_cast<set &>(Base::container_from_end_iterator(end_iterator)); } + + static const set &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const set &>(Base::container_from_end_iterator(end_iterator)); } + + static set &container_from_iterator(iterator it) + { return static_cast<set &>(Base::container_from_iterator(it)); } + + static const set &container_from_iterator(const_iterator it) + { return static_cast<const set &>(Base::container_from_iterator(it)); } +}; + +#endif + +//! The class template multiset is an intrusive container, that mimics most of +//! the interface of std::multiset as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class multiset_impl +{ + /// @cond + typedef rbtree_impl<Config> tree_type; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(multiset_impl) + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + //static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + + /// @cond + private: + tree_type tree_; + + protected: + node &prot_header_node(){ return tree_.prot_header_node(); } + node const &prot_header_node() const{ return tree_.prot_header_node(); } + void prot_set_size(size_type s){ tree_.prot_set_size(s); } + value_compare &prot_comp(){ return tree_.prot_comp(); } + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + multiset_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty multiset and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + multiset_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(false, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + multiset_impl(BOOST_RV_REF(multiset_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + multiset_impl& operator=(BOOST_RV_REF(multiset_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~multiset_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static multiset_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &multiset_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const multiset_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static multiset_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const multiset_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &multiset_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the multiset. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two multisets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(multiset_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const multiset_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(reference value) + { return tree_.insert_equal(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts x into the multiset, using pos as a hint to + //! where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_equal(hint, value); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_equal(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" tree ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be no less + //! than the greatest inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be no greater + //! than the minimum inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.count(value); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.count(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a set/multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + //! <b>Effects</b>: removes "value" from the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic time. + //! + //! <b>Note</b>: This static function is only usable with non-constant + //! time size containers that have stateless comparison functors. + //! + //! If the user calls + //! this function with a constant time size container or stateful comparison + //! functor a compilation error will be issued. + static void remove_node(reference value) + { tree_type::remove_node(value); } + + /// @cond + friend bool operator==(const multiset_impl &x, const multiset_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const multiset_impl &x, const multiset_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const multiset_impl<T, Options...> &x, const multiset_impl<T, Options...> &y) +#else +(const multiset_impl<Config> &x, const multiset_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const multiset_impl<T, Options...> &x, const multiset_impl<T, Options...> &y) +#else +(const multiset_impl<Config> &x, const multiset_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const multiset_impl<T, Options...> &x, const multiset_impl<T, Options...> &y) +#else +(const multiset_impl<Config> &x, const multiset_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const multiset_impl<T, Options...> &x, const multiset_impl<T, Options...> &y) +#else +(const multiset_impl<Config> &x, const multiset_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(multiset_impl<T, Options...> &x, multiset_impl<T, Options...> &y) +#else +(multiset_impl<Config> &x, multiset_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c multiset that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_multiset +{ + /// @cond + typedef multiset_impl + < typename make_rbtree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class multiset + : public make_multiset<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_multiset<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(multiset) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + multiset( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + multiset( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + multiset(BOOST_RV_REF(multiset) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + multiset& operator=(BOOST_RV_REF(multiset) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static multiset &container_from_end_iterator(iterator end_iterator) + { return static_cast<multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static const multiset &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static multiset &container_from_iterator(iterator it) + { return static_cast<multiset &>(Base::container_from_iterator(it)); } + + static const multiset &container_from_iterator(const_iterator it) + { return static_cast<const multiset &>(Base::container_from_iterator(it)); } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SET_HPP diff --git a/src/third_party/boost/boost/intrusive/set_hook.hpp b/src/third_party/boost/boost/intrusive/set_hook.hpp new file mode 100644 index 00000000000..35746a29a58 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/set_hook.hpp @@ -0,0 +1,300 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_SET_HOOK_HPP +#define BOOST_INTRUSIVE_SET_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/rbtree_node.hpp> +#include <boost/intrusive/rbtree_algorithms.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +template<class VoidPointer, bool OptimizeSize = false> +struct get_set_node_algo +{ + typedef rbtree_algorithms<rbtree_node_traits<VoidPointer, OptimizeSize> > type; +}; +/// @endcond + +//! Helper metafunction to define a \c set_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none, class O4 = none> +#endif +struct make_set_base_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_set_node_algo<typename packed_options::void_pointer + ,packed_options::optimize_size> + , typename packed_options::tag + , packed_options::link_mode + , detail::SetBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from set_base_hook in order to store objects in +//! in a set/multiset. set_base_hook holds the data necessary to maintain +//! the set/multiset and provides an appropriate value_traits class for set/multiset. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<>, +//! \c link_mode<> and \c optimize_size<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its +//! unique tag. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c optimize_size<> will tell the hook to optimize the hook for size instead +//! of speed. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3, class O4> +#endif +class set_base_hook + : public make_set_base_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + set_base_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + set_base_hook(const set_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + set_base_hook& operator=(const set_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~set_base_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(set_base_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +//! Helper metafunction to define a \c set_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none, class O4 = none> +#endif +struct make_set_member_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_set_node_algo<typename packed_options::void_pointer + ,packed_options::optimize_size> + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Put a public data member set_member_hook in order to store objects of this class in +//! a set/multiset. set_member_hook holds the data necessary for maintaining the +//! set/multiset and provides an appropriate value_traits class for set/multiset. +//! +//! The hook admits the following options: \c void_pointer<>, +//! \c link_mode<> and \c optimize_size<>. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c optimize_size<> will tell the hook to optimize the hook for size instead +//! of speed. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3, class O4> +#endif +class set_member_hook + : public make_set_member_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + set_member_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + set_member_hook(const set_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + set_member_hook& operator=(const set_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~set_member_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(set_member_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SET_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/sg_set.hpp b/src/third_party/boost/boost/intrusive/sg_set.hpp new file mode 100644 index 00000000000..fb59496ee13 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/sg_set.hpp @@ -0,0 +1,2431 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_SG_SET_HPP +#define BOOST_INTRUSIVE_SG_SET_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/sgtree.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/move/move.hpp> +#include <iterator> + +namespace boost { +namespace intrusive { + +//! The class template sg_set is an intrusive container, that mimics most of +//! the interface of std::set as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class sg_set_impl +{ + /// @cond + typedef sgtree_impl<Config> tree_type; + //! This class is + //! movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_set_impl) + + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare object throws. + sg_set_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty sg_set and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is std::distance(last, first). + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + sg_set_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(true, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + sg_set_impl(BOOST_RV_REF(sg_set_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + sg_set_impl& operator=(BOOST_RV_REF(sg_set_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the sg_set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~sg_set_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of sg_set. + //! + //! <b>Effects</b>: Returns a const reference to the sg_set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static sg_set_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<sg_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &sg_set_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of sg_set. + //! + //! <b>Effects</b>: Returns a const reference to the sg_set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const sg_set_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<sg_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &sg_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of set. + //! + //! <b>Effects</b>: Returns a reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static sg_set_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<sg_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &sg_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of set. + //! + //! <b>Effects</b>: Returns a const reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const sg_set_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<sg_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &sg_set_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the sg_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the sg_set. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two sets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(sg_set_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const sg_set_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to inserts value into the sg_set. + //! + //! <b>Returns</b>: If the value + //! is not already present inserts it and returns a pair containing the + //! iterator to the new value and true. If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert(reference value) + { return tree_.insert_unique(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to to insert x into the sg_set, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the + //! new element was inserted into the sg_set. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_unique(hint, value); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the sg_set, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the sg_set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(key, key_value_comp, commit_data); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the sg_set, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the sg_set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(hint, key, key_value_comp, commit_data); } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the sg_set between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the sg_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_commit(reference value, const insert_commit_data &commit_data) + { return tree_.insert_unique_commit(value, commit_data); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the sg_set. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_unique(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate. "value" must not be equal to any + //! inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" or "value" is not unique tree ordering and uniqueness + //! invariants will be broken respectively. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be greater than + //! any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than or equal to the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be less + //! than any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than or equal to the the mimum inserted key tree ordering or uniqueness + //! invariants will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size()) + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If the comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). Basic guarantee. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.find(value) != end(); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp) != end(); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the sg_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! sg_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the sg_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! sg_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a sg_set/sg_multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { tree_.rebalance(); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return tree_.rebalance_subtree(root); } + + //! <b>Returns</b>: The balance factor (alpha) used in this tree + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + float balance_factor() const + { return tree_.balance_factor(); } + + //! <b>Requires</b>: new_alpha must be a value between 0.5 and 1.0 + //! + //! <b>Effects</b>: Establishes a new balance factor (alpha) and rebalances + //! the tree if the new balance factor is stricter (less) than the old factor. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + void balance_factor(float new_alpha) + { tree_.balance_factor(new_alpha); } + + /// @cond + friend bool operator==(const sg_set_impl &x, const sg_set_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const sg_set_impl &x, const sg_set_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y) +#else +(const sg_set_impl<Config> &x, const sg_set_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y) +#else +(const sg_set_impl<Config> &x, const sg_set_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y) +#else +(const sg_set_impl<Config> &x, const sg_set_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y) +#else +(const sg_set_impl<Config> &x, const sg_set_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(sg_set_impl<T, Options...> &x, sg_set_impl<T, Options...> &y) +#else +(sg_set_impl<Config> &x, sg_set_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c sg_set that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_sg_set +{ + /// @cond + typedef sg_set_impl + < typename make_sgtree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class sg_set + : public make_sg_set<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_sg_set + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_set) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + sg_set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + sg_set( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + sg_set(BOOST_RV_REF(sg_set) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + sg_set& operator=(BOOST_RV_REF(sg_set) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static sg_set &container_from_end_iterator(iterator end_iterator) + { return static_cast<sg_set &>(Base::container_from_end_iterator(end_iterator)); } + + static const sg_set &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const sg_set &>(Base::container_from_end_iterator(end_iterator)); } + + static sg_set &container_from_iterator(iterator it) + { return static_cast<sg_set &>(Base::container_from_iterator(it)); } + + static const sg_set &container_from_iterator(const_iterator it) + { return static_cast<const sg_set &>(Base::container_from_iterator(it)); } +}; + +#endif + +//! The class template sg_multiset is an intrusive container, that mimics most of +//! the interface of std::sg_multiset as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class sg_multiset_impl +{ + /// @cond + typedef sgtree_impl<Config> tree_type; + + //Non-copyable and non-assignable + BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_multiset_impl) + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + sg_multiset_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty sg_multiset and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + sg_multiset_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(false, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + sg_multiset_impl(BOOST_RV_REF(sg_multiset_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + sg_multiset_impl& operator=(BOOST_RV_REF(sg_multiset_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the sg_multiset + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~sg_multiset_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of sg_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the sg_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static sg_multiset_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<sg_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &sg_multiset_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of sg_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the sg_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const sg_multiset_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<sg_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &sg_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static sg_multiset_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<sg_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &sg_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const sg_multiset_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<sg_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &sg_multiset_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the sg_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the sg_multiset. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two sg_multisets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(sg_multiset_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const sg_multiset_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the sg_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(reference value) + { return tree_.insert_equal(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts x into the sg_multiset, using pos as a hint to + //! where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_equal(hint, value); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the sg_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_equal(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" tree ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be no less + //! than the greatest inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be no greater + //! than the minimum inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.count(value); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.count(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the sg_multiset + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! sg_multiset that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the sg_multiset + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a sg_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! sg_multiset that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a sg_multiset/sg_multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { tree_.rebalance(); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return tree_.rebalance_subtree(root); } + + //! <b>Returns</b>: The balance factor (alpha) used in this tree + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + float balance_factor() const + { return tree_.balance_factor(); } + + //! <b>Requires</b>: new_alpha must be a value between 0.5 and 1.0 + //! + //! <b>Effects</b>: Establishes a new balance factor (alpha) and rebalances + //! the tree if the new balance factor is stricter (less) than the old factor. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + void balance_factor(float new_alpha) + { tree_.balance_factor(new_alpha); } + + /// @cond + friend bool operator==(const sg_multiset_impl &x, const sg_multiset_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const sg_multiset_impl &x, const sg_multiset_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y) +#else +(const sg_multiset_impl<Config> &x, const sg_multiset_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y) +#else +(const sg_multiset_impl<Config> &x, const sg_multiset_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y) +#else +(const sg_multiset_impl<Config> &x, const sg_multiset_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y) +#else +(const sg_multiset_impl<Config> &x, const sg_multiset_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(sg_multiset_impl<T, Options...> &x, sg_multiset_impl<T, Options...> &y) +#else +(sg_multiset_impl<Config> &x, sg_multiset_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c sg_multiset that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_sg_multiset +{ + /// @cond + typedef sg_multiset_impl + < typename make_sgtree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class sg_multiset + : public make_sg_multiset<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_sg_multiset + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_multiset) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + sg_multiset( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + sg_multiset( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + sg_multiset(BOOST_RV_REF(sg_multiset) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + sg_multiset& operator=(BOOST_RV_REF(sg_multiset) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static sg_multiset &container_from_end_iterator(iterator end_iterator) + { return static_cast<sg_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static const sg_multiset &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const sg_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static sg_multiset &container_from_iterator(iterator it) + { return static_cast<sg_multiset &>(Base::container_from_iterator(it)); } + + static const sg_multiset &container_from_iterator(const_iterator it) + { return static_cast<const sg_multiset &>(Base::container_from_iterator(it)); } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SG_SET_HPP diff --git a/src/third_party/boost/boost/intrusive/sgtree.hpp b/src/third_party/boost/boost/intrusive/sgtree.hpp new file mode 100644 index 00000000000..0c4177ba423 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/sgtree.hpp @@ -0,0 +1,1911 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +// +// The option that yields to non-floating point 1/sqrt(2) alpha is taken +// from the scapegoat tree implementation of the PSPP library. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_SGTREE_HPP +#define BOOST_INTRUSIVE_SGTREE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <algorithm> +#include <cstddef> +#include <functional> +#include <iterator> +#include <utility> +#include <cmath> +#include <cstddef> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/static_assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/bs_set_hook.hpp> +#include <boost/intrusive/detail/tree_node.hpp> +#include <boost/intrusive/detail/ebo_functor_holder.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/sgtree_algorithms.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/move/move.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +namespace detail{ + +//! Returns floor(log(n)/log(sqrt(2))) -> floor(2*log2(n)) +//! Undefined if N is 0. +//! +//! This function does not use float point operations. +inline std::size_t calculate_h_sqrt2 (std::size_t n) +{ + std::size_t f_log2 = detail::floor_log2(n); + return (2*f_log2) + (n >= detail::sqrt2_pow_2xplus1 (f_log2)); +} + +struct h_alpha_sqrt2_t +{ + h_alpha_sqrt2_t(void){} + std::size_t operator()(std::size_t n) const + { return calculate_h_sqrt2(n); } +}; + +struct alpha_0_75_by_max_size_t +{ + alpha_0_75_by_max_size_t(void){} + std::size_t operator()(std::size_t max_tree_size) const + { + const std::size_t max_tree_size_limit = ((~std::size_t(0))/std::size_t(3)); + return max_tree_size > max_tree_size_limit ? max_tree_size/4*3 : max_tree_size*3/4; + } +}; + +struct h_alpha_t +{ + h_alpha_t(float inv_minus_logalpha) + : inv_minus_logalpha_(inv_minus_logalpha) + {} + + std::size_t operator()(std::size_t n) const + { + //Returns floor(log1/alpha(n)) -> + // floor(log(n)/log(1/alpha)) -> + // floor(log(n)/(-log(alpha))) + //return static_cast<std::size_t>(std::log(float(n))*inv_minus_logalpha_); + return static_cast<std::size_t>(detail::fast_log2(float(n))*inv_minus_logalpha_); + } + + private: + //Since the function will be repeatedly called + //precalculate constant data to avoid repeated + //calls to log and division. + //This will store 1/(-std::log(alpha_)) + float inv_minus_logalpha_; +}; + +struct alpha_by_max_size_t +{ + alpha_by_max_size_t(float alpha) + : alpha_(alpha) + {} + + float operator()(std::size_t max_tree_size) const + { return float(max_tree_size)*alpha_; } + + private: + float alpha_; + float inv_minus_logalpha_; +}; + +template<bool Activate> +struct alpha_holder +{ + typedef boost::intrusive::detail::h_alpha_t h_alpha_t; + typedef boost::intrusive::detail::alpha_by_max_size_t multiply_by_alpha_t; + + alpha_holder() + { set_alpha(0.7f); } + + float get_alpha() const + { return alpha_; } + + void set_alpha(float alpha) + { + alpha_ = alpha; + inv_minus_logalpha_ = 1/(-detail::fast_log2(alpha)); + } + + h_alpha_t get_h_alpha_t() const + { return h_alpha_t(inv_minus_logalpha_); } + + multiply_by_alpha_t get_multiply_by_alpha_t() const + { return multiply_by_alpha_t(alpha_); } + + private: + float alpha_; + float inv_minus_logalpha_; +}; + +template<> +struct alpha_holder<false> +{ + //This specialization uses alpha = 1/sqrt(2) + //without using floating point operations + //Downside: alpha CAN't be changed. + typedef boost::intrusive::detail::h_alpha_sqrt2_t h_alpha_t; + typedef boost::intrusive::detail::alpha_0_75_by_max_size_t multiply_by_alpha_t; + + float get_alpha() const + { return 0.70710677f; } + + void set_alpha(float) + { //alpha CAN't be changed. + BOOST_INTRUSIVE_INVARIANT_ASSERT(0); + } + + h_alpha_t get_h_alpha_t() const + { return h_alpha_t(); } + + multiply_by_alpha_t get_multiply_by_alpha_t() const + { return multiply_by_alpha_t(); } +}; + +} //namespace detail{ + +template <class ValueTraits, class Compare, class SizeType, bool FloatingPoint> +struct sg_setopt +{ + typedef ValueTraits value_traits; + typedef Compare compare; + typedef SizeType size_type; + static const bool floating_point = FloatingPoint; +}; + +template <class T> +struct sg_set_defaults + : pack_options + < none + , base_hook<detail::default_bs_set_hook> + , floating_point<true> + , size_type<std::size_t> + , compare<std::less<T> > + >::type +{}; + +/// @endcond + +//! The class template sgtree is an intrusive scapegoat tree container, that +//! is used to construct intrusive sg_set and sg_multiset containers. +//! The no-throw guarantee holds only, if the value_compare object +//! doesn't throw. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c floating_point<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class sgtree_impl + : private detail::clear_on_destructor_base<sgtree_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + public: + typedef typename Config::value_traits value_traits; + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + /// @endcond + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + typedef typename pointer_traits<pointer>::element_type value_type; + typedef value_type key_type; + typedef typename pointer_traits<pointer>::reference reference; + typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef typename pointer_traits<const_pointer>::difference_type difference_type; + typedef typename Config::size_type size_type; + typedef typename Config::compare value_compare; + typedef value_compare key_compare; + typedef tree_iterator<sgtree_impl, false> iterator; + typedef tree_iterator<sgtree_impl, true> const_iterator; + typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator; + typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <node>::type node_ptr; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <const node>::type const_node_ptr; + typedef sgtree_algorithms<node_traits> node_algorithms; + + static const bool floating_point = Config::floating_point; + static const bool constant_time_size = true; + static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + + /// @cond + private: + typedef detail::size_holder<true, size_type> size_traits; + typedef detail::alpha_holder<floating_point> alpha_traits; + typedef typename alpha_traits::h_alpha_t h_alpha_t; + typedef typename alpha_traits::multiply_by_alpha_t multiply_by_alpha_t; + + //noncopyable + BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + BOOST_STATIC_ASSERT(((int)real_value_traits::link_mode != (int)auto_unlink)); + + //BOOST_STATIC_ASSERT(( + // (int)real_value_traits::link_mode != (int)auto_unlink || + // !floating_point + // )); + + struct header_plus_alpha : public alpha_traits + { node header_; }; + + struct node_plus_pred_t : public detail::ebo_functor_holder<value_compare> + { + node_plus_pred_t(const value_compare &comp) + : detail::ebo_functor_holder<value_compare>(comp) + {} + header_plus_alpha header_plus_alpha_; + size_traits size_traits_; + }; + + struct data_t : public sgtree_impl::value_traits + { + typedef typename sgtree_impl::value_traits value_traits; + data_t(const value_compare & comp, const value_traits &val_traits) + : value_traits(val_traits), node_plus_pred_(comp) + , max_tree_size_(0) + {} + node_plus_pred_t node_plus_pred_; + size_type max_tree_size_; + } data_; + + float priv_alpha() const + { return this->priv_alpha_traits().get_alpha(); } + + void priv_alpha(float alpha) + { return this->priv_alpha_traits().set_alpha(alpha); } + + const value_compare &priv_comp() const + { return data_.node_plus_pred_.get(); } + + value_compare &priv_comp() + { return data_.node_plus_pred_.get(); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + node_ptr priv_header_ptr() + { return pointer_traits<node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_alpha_.header_); } + + const_node_ptr priv_header_ptr() const + { return pointer_traits<const_node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_alpha_.header_); } + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + size_traits &priv_size_traits() + { return data_.node_plus_pred_.size_traits_; } + + const size_traits &priv_size_traits() const + { return data_.node_plus_pred_.size_traits_; } + + alpha_traits &priv_alpha_traits() + { return data_.node_plus_pred_.header_plus_alpha_; } + + const alpha_traits &priv_alpha_traits() const + { return data_.node_plus_pred_.header_plus_alpha_; } + + const real_value_traits &get_real_value_traits(detail::bool_<false>) const + { return data_; } + + const real_value_traits &get_real_value_traits(detail::bool_<true>) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::bool_<false>) + { return data_; } + + real_value_traits &get_real_value_traits(detail::bool_<true>) + { return data_.get_value_traits(*this); } + + h_alpha_t get_h_alpha_func() const + { return priv_alpha_traits().get_h_alpha_t(); } + + multiply_by_alpha_t get_alpha_by_max_size_func() const + { return priv_alpha_traits().get_multiply_by_alpha_t(); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + typedef typename node_algorithms::insert_commit_data insert_commit_data; + + //! <b>Effects</b>: Constructs an empty tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructorof the value_compare object throws. Basic guarantee. + sgtree_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty tree and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. Basic guarantee. + template<class Iterator> + sgtree_impl( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + if(unique) + this->insert_unique(b, e); + else + this->insert_equal(b, e); + } + + //! <b>Effects</b>: to-do + //! + sgtree_impl(BOOST_RV_REF(sgtree_impl) x) + : data_(::boost::move(x.priv_comp()), ::boost::move(x.priv_value_traits())) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + this->swap(x); + } + + //! <b>Effects</b>: to-do + //! + sgtree_impl& operator=(BOOST_RV_REF(sgtree_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called), but the nodes according to + //! the value_traits template parameter are reinitialized and thus can be reused. + //! + //! <b>Complexity</b>: Linear to elements contained in *this. + //! + //! <b>Throws</b>: Nothing. + ~sgtree_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return cbegin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return const_iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return iterator (this->priv_header_ptr(), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return cend(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return const_iterator (uncast(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return const_reverse_iterator(begin()); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of sgtree. + //! + //! <b>Effects</b>: Returns a const reference to the sgtree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static sgtree_impl &container_from_end_iterator(iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of sgtree. + //! + //! <b>Effects</b>: Returns a const reference to the sgtree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const sgtree_impl &container_from_end_iterator(const_iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: it must be a valid iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static sgtree_impl &container_from_iterator(iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Precondition</b>: it must be a valid end const_iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const sgtree_impl &container_from_iterator(const_iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Effects</b>: Returns the value_compare object used by the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return priv_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return node_algorithms::unique(this->priv_header_ptr()); } + + //! <b>Effects</b>: Returns the number of elements stored in the tree. + //! + //! <b>Complexity</b>: Linear to elements contained in *this + //! if constant-time size option is disabled. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { + if(constant_time_size) + return this->priv_size_traits().get_size(); + else{ + return (size_type)node_algorithms::size(this->priv_header_ptr()); + } + } + + //! <b>Effects</b>: Swaps the contents of two sgtrees. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the comparison functor's swap call throws. + void swap(sgtree_impl& other) + { + //This can throw + using std::swap; + swap(priv_comp(), priv_comp()); + swap(priv_alpha_traits(), priv_alpha_traits()); + swap(data_.max_tree_size_, other.data_.max_tree_size_); + //These can't throw + node_algorithms::swap_tree(this->priv_header_ptr(), other.priv_header_ptr()); + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree before the upper bound. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(reference value) + { + detail::key_nodeptr_comp<value_compare, sgtree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + std::size_t max_tree_size = (std::size_t)data_.max_tree_size_; + node_ptr p = node_algorithms::insert_equal_upper_bound + (this->priv_header_ptr(), to_insert, key_node_comp + , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); + this->priv_size_traits().increment(); + data_.max_tree_size_ = (size_type)max_tree_size; + return iterator(p, this); + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator. + //! + //! <b>Effects</b>: Inserts x into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case) + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(const_iterator hint, reference value) + { + detail::key_nodeptr_comp<value_compare, sgtree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + std::size_t max_tree_size = (std::size_t)data_.max_tree_size_; + node_ptr p = node_algorithms::insert_equal + (this->priv_header_ptr(), hint.pointed_node(), to_insert, key_node_comp + , (std::size_t)this->size(), this->get_h_alpha_func(), max_tree_size); + this->priv_size_traits().increment(); + data_.max_tree_size_ = (size_type)max_tree_size; + return iterator(p, this); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a each element of a range into the tree + //! before the upper bound of the key of each element. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_equal(Iterator b, Iterator e) + { + iterator end(this->end()); + for (; b != e; ++b) + this->insert_equal(end, *b); + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree if the value + //! is not already present. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert_unique(reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(value, priv_comp(), commit_data); + if(!ret.second) + return ret; + return std::pair<iterator, bool> (insert_unique_commit(value, commit_data), true); + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator + //! + //! <b>Effects</b>: Tries to insert x into the tree, using "hint" as a hint + //! to where it will be inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time (two comparisons in the worst case) + //! if t is inserted immediately before hint. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_unique(const_iterator hint, reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(hint, value, priv_comp(), commit_data); + if(!ret.second) + return ret.first; + return insert_unique_commit(value, commit_data); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Tries to insert each element of a range into the tree. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_unique(Iterator b, Iterator e) + { + if(this->empty()){ + iterator end(this->end()); + for (; b != e; ++b) + this->insert_unique(end, *b); + } + else{ + for (; b != e; ++b) + this->insert_unique(*b); + } + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), key, comp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), hint.pointed_node(), key, comp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the container between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + std::size_t max_tree_size = (std::size_t)data_.max_tree_size_; + node_algorithms::insert_unique_commit + ( this->priv_header_ptr(), to_insert, commit_data + , (std::size_t)this->size(), this->get_h_alpha_func(), max_tree_size); + this->priv_size_traits().increment(); + data_.max_tree_size_ = (size_type)max_tree_size; + return iterator(to_insert, this); + } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate + //! + //! <b>Effects</b>: Inserts x into the tree before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" tree ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + std::size_t max_tree_size = (std::size_t)data_.max_tree_size_; + node_ptr p = node_algorithms::insert_before + ( this->priv_header_ptr(), pos.pointed_node(), to_insert + , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); + this->priv_size_traits().increment(); + data_.max_tree_size_ = (size_type)max_tree_size; + return iterator(p, this); + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no less + //! than the greatest inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + std::size_t max_tree_size = (std::size_t)data_.max_tree_size_; + node_algorithms::push_back + ( this->priv_header_ptr(), to_insert + , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); + this->priv_size_traits().increment(); + data_.max_tree_size_ = (size_type)max_tree_size; + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no greater + //! than the minimum inserted key + //! + //! <b>Effects</b>: Inserts x into the tree in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key tree ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + std::size_t max_tree_size = (std::size_t)data_.max_tree_size_; + node_algorithms::push_front + ( this->priv_header_ptr(), to_insert + , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); + this->priv_size_traits().increment(); + data_.max_tree_size_ = (size_type)max_tree_size; + } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { + const_iterator ret(i); + ++ret; + node_ptr to_erase(i.pointed_node()); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); + std::size_t max_tree_size = data_.max_tree_size_; + node_algorithms::erase + ( this->priv_header_ptr(), to_erase, (std::size_t)this->size() + , max_tree_size, this->get_alpha_by_max_size_func()); + data_.max_tree_size_ = (size_type)max_tree_size; + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + return ret.unconst(); + } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { size_type n; return private_erase(b, e, n); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return this->erase(value, priv_comp()); } + + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { + node_ptr to_erase(i.pointed_node()); + iterator ret(this->erase(i)); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + return ret; + } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { size_type n; return private_erase(b, e, n, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { + std::pair<iterator,iterator> p = this->equal_range(value); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { + if(safemode_or_autounlink){ + this->clear_and_dispose(detail::null_disposer()); + } + else{ + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + } + + //! <b>Effects</b>: Erases all of the elements calling disposer(p) for + //! each node to be erased. + //! <b>Complexity</b>: Average complexity for is at most O(log(size() + N)), + //! where N is the number of elements in the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. Calls N times to disposer functor. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { + node_algorithms::clear_and_dispose(this->priv_header_ptr() + , detail::node_disposer<Disposer, sgtree_impl>(disposer, this)); + this->priv_size_traits().set_size(0); + } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given value. + //! + //! <b>Throws</b>: Nothing. + size_type count(const_reference value) const + { return this->count(value, priv_comp()); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType &key, KeyValueCompare comp) const + { + std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp); + return std::distance(ret.first, ret.second); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator lower_bound(const_reference value) + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator lower_bound(const_reference value) const + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator upper_bound(const_reference value) + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator upper_bound(const_reference value) const + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator find(const_reference value) + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + return iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator find(const_reference value) const + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + return const_iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<iterator,iterator> equal_range(const_reference value) + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<iterator, iterator>(iterator(ret.first, this), iterator(ret.second, this)); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, sgtree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<const_iterator, const_iterator>(const_iterator(ret.first, this), const_iterator(ret.second, this)); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const sgtree_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + if(!src.empty()){ + detail::exception_disposer<sgtree_impl, Disposer> + rollback(*this, disposer); + node_algorithms::clone + (src.priv_header_ptr() + ,this->priv_header_ptr() + ,detail::node_cloner<Cloner, sgtree_impl>(cloner, this) + ,detail::node_disposer<Disposer, sgtree_impl>(disposer, this)); + this->priv_size_traits().set_size(src.priv_size_traits().get_size()); + this->priv_comp() = src.priv_comp(); + rollback.release(); + } + } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { + node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance + (this->priv_header_ptr())); + if(!to_be_disposed) + return 0; + this->priv_size_traits().decrement(); + if(safemode_or_autounlink)//If this is commented does not work with normal_link + node_algorithms::init(to_be_disposed); + return get_real_value_traits().to_value_ptr(to_be_disposed); + } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { + node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this) + , this->priv_header_ptr() + , get_real_value_traits().to_node_ptr(with_this)); + if(safemode_or_autounlink) + node_algorithms::init(replace_this.pointed_node()); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return iterator (value_traits::to_node_ptr(value), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return iterator (value_traits::to_node_ptr(value), this); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this); } + + //! <b>Requires</b>: value shall not be in a tree. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { node_algorithms::init(value_traits::to_node_ptr(value)); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { node_algorithms::rebalance(this->priv_header_ptr()); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return iterator(node_algorithms::rebalance_subtree(root.pointed_node()), this); } + + //! <b>Returns</b>: The balance factor (alpha) used in this tree + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + float balance_factor() const + { return this->priv_alpha(); } + + //! <b>Requires</b>: new_alpha must be a value between 0.5 and 1.0 + //! + //! <b>Effects</b>: Establishes a new balance factor (alpha) and rebalances + //! the tree if the new balance factor is stricter (less) than the old factor. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + void balance_factor(float new_alpha) + { + BOOST_INTRUSIVE_INVARIANT_ASSERT((new_alpha > 0.5f && new_alpha < 1.0f)); + if(new_alpha < 0.5f && new_alpha >= 1.0f) return; + + //The alpha factor CAN't be changed if the fixed, floating operation-less + //1/sqrt(2) alpha factor option is activated + BOOST_STATIC_ASSERT((floating_point)); + float old_alpha = this->priv_alpha(); + this->priv_alpha(new_alpha); + + if(new_alpha < old_alpha){ + data_.max_tree_size_ = this->size(); + this->rebalance(); + } + } +/* + //! <b>Effects</b>: removes x from a tree of the appropriate type. It has no effect, + //! if x is not in such a tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This static function is only usable with the "safe mode" + //! hook and non-constant time size lists. Otherwise, the user must use + //! the non-static "erase(reference )" member. If the user calls + //! this function with a non "safe mode" or constant time size list + //! a compilation error will be issued. + template<class T> + static void remove_node(T& value) + { + //This function is only usable for safe mode hooks and non-constant + //time lists. + //BOOST_STATIC_ASSERT((!(safemode_or_autounlink && constant_time_size))); + BOOST_STATIC_ASSERT((!constant_time_size)); + BOOST_STATIC_ASSERT((boost::is_convertible<T, value_type>::value)); + node_ptr to_remove(value_traits::to_node_ptr(value)); + node_algorithms::unlink_and_rebalance(to_remove); + if(safemode_or_autounlink) + node_algorithms::init(to_remove); + } +*/ + + /// @cond + private: + template<class Disposer> + iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer) + { + for(n = 0; b != e; ++n) + this->erase_and_dispose(b++, disposer); + return b.unconst(); + } + + iterator private_erase(const_iterator b, const_iterator e, size_type &n) + { + for(n = 0; b != e; ++n) + this->erase(b++); + return b.unconst(); + } + /// @endcond + + private: + static sgtree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) + { + header_plus_alpha *r = detail::parent_from_member<header_plus_alpha, node> + ( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), &header_plus_alpha::header_); + node_plus_pred_t *n = detail::parent_from_member + <node_plus_pred_t, header_plus_alpha>(r, &node_plus_pred_t::header_plus_alpha_); + data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(n, &data_t::node_plus_pred_); + sgtree_impl *scapegoat = detail::parent_from_member<sgtree_impl, data_t>(d, &sgtree_impl::data_); + return *scapegoat; + } + + static sgtree_impl &priv_container_from_iterator(const const_iterator &it) + { return priv_container_from_end_iterator(it.end_iterator_from_it()); } +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator< +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sgtree_impl<T, Options...> &x, const sgtree_impl<T, Options...> &y) +#else +(const sgtree_impl<Config> &x, const sgtree_impl<Config> &y) +#endif +{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +bool operator== +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sgtree_impl<T, Options...> &x, const sgtree_impl<T, Options...> &y) +#else +(const sgtree_impl<Config> &x, const sgtree_impl<Config> &y) +#endif +{ + typedef sgtree_impl<Config> tree_type; + typedef typename tree_type::const_iterator const_iterator; + + if(tree_type::constant_time_size && x.size() != y.size()){ + return false; + } + const_iterator end1 = x.end(); + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + if(tree_type::constant_time_size){ + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; + } + else{ + const_iterator end2 = y.end(); + while (i1 != end1 && i2 != end2 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1 && i2 == end2; + } +} + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sgtree_impl<T, Options...> &x, const sgtree_impl<T, Options...> &y) +#else +(const sgtree_impl<Config> &x, const sgtree_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sgtree_impl<T, Options...> &x, const sgtree_impl<T, Options...> &y) +#else +(const sgtree_impl<Config> &x, const sgtree_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sgtree_impl<T, Options...> &x, const sgtree_impl<T, Options...> &y) +#else +(const sgtree_impl<Config> &x, const sgtree_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const sgtree_impl<T, Options...> &x, const sgtree_impl<T, Options...> &y) +#else +(const sgtree_impl<Config> &x, const sgtree_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(sgtree_impl<T, Options...> &x, sgtree_impl<T, Options...> &y) +#else +(sgtree_impl<Config> &x, sgtree_impl<Config> &y) +#endif +{ x.swap(y); } + +/// @cond +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#else +template<class T, class ...Options> +#endif +struct make_sgtree_opt +{ + typedef typename pack_options + < sg_set_defaults<T>, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + + typedef sg_setopt + < value_traits + , typename packed_options::compare + , typename packed_options::size_type + , packed_options::floating_point + > type; +}; +/// @endcond + +//! Helper metafunction to define a \c sgtree that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_sgtree +{ + /// @cond + typedef sgtree_impl + < typename make_sgtree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class sgtree + : public make_sgtree<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_sgtree + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::real_value_traits real_value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + + sgtree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + sgtree( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(unique, b, e, cmp, v_traits) + {} + + sgtree(BOOST_RV_REF(sgtree) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + sgtree& operator=(BOOST_RV_REF(sgtree) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static sgtree &container_from_end_iterator(iterator end_iterator) + { return static_cast<sgtree &>(Base::container_from_end_iterator(end_iterator)); } + + static const sgtree &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const sgtree &>(Base::container_from_end_iterator(end_iterator)); } +}; + +#endif + + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SGTREE_HPP diff --git a/src/third_party/boost/boost/intrusive/sgtree_algorithms.hpp b/src/third_party/boost/boost/intrusive/sgtree_algorithms.hpp new file mode 100644 index 00000000000..f3c433225e7 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/sgtree_algorithms.hpp @@ -0,0 +1,782 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007. +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +// +// Scapegoat tree algorithms are taken from the paper titled: +// "Scapegoat Trees" by Igal Galperin Ronald L. Rivest. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_SGTREE_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_SGTREE_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +#include <cstddef> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/tree_algorithms.hpp> +#include <boost/intrusive/pointer_traits.hpp> + + +namespace boost { +namespace intrusive { + +//! sgtree_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_parent(const_node_ptr n);</tt> +//! +//! <tt>static void set_parent(node_ptr n, node_ptr parent);</tt> +//! +//! <tt>static node_ptr get_left(const_node_ptr n);</tt> +//! +//! <tt>static void set_left(node_ptr n, node_ptr left);</tt> +//! +//! <tt>static node_ptr get_right(const_node_ptr n);</tt> +//! +//! <tt>static void set_right(node_ptr n, node_ptr right);</tt> +template<class NodeTraits> +class sgtree_algorithms +{ + public: + typedef typename NodeTraits::node node; + typedef NodeTraits node_traits; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + + /// @cond + private: + + typedef detail::tree_algorithms<NodeTraits> tree_algorithms; + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + /// @endcond + + public: + static node_ptr begin_node(const const_node_ptr & header) + { return tree_algorithms::begin_node(header); } + + static node_ptr end_node(const const_node_ptr & header) + { return tree_algorithms::end_node(header); } + + //! This type is the information that will be + //! filled by insert_unique_check + struct insert_commit_data + : tree_algorithms::insert_commit_data + { + std::size_t depth; + }; + + //! <b>Requires</b>: header1 and header2 must be the header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two trees. After the function header1 will contain + //! links to the second tree and header2 will have links to the first tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static void swap_tree(const node_ptr & header1, const node_ptr & header2) + { return tree_algorithms::swap_tree(header1, header2); } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & node2) + { + if(node1 == node2) + return; + + node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2)); + swap_nodes(node1, header1, node2, header2); + } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees with header header1 and header2. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) + { tree_algorithms::swap_nodes(node1, header1, node2, header2); } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing and comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) + { + if(node_to_be_replaced == new_node) + return; + replace_node(node_to_be_replaced, tree_algorithms::get_header(node_to_be_replaced), new_node); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! with header "header" and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) + { tree_algorithms::replace_node(node_to_be_replaced, header, new_node); } + + //! <b>Requires</b>: node is a tree node but not the header. + //! + //! <b>Effects</b>: Unlinks the node and rebalances the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + static void unlink(const node_ptr & node) + { + node_ptr x = NodeTraits::get_parent(node); + if(x){ + while(!is_header(x)) + x = NodeTraits::get_parent(x); + tree_algorithms::erase(x, node); + } + } + + //! <b>Requires</b>: header is the header of a tree. + //! + //! <b>Effects</b>: Unlinks the leftmost node from the tree, and + //! updates the header link to the new leftmost node. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + static node_ptr unlink_leftmost_without_rebalance(const node_ptr & header) + { return tree_algorithms::unlink_leftmost_without_rebalance(header); } + + //! <b>Requires</b>: node is a node of the tree or an node initialized + //! by init(...). + //! + //! <b>Effects</b>: Returns true if the node is initialized by init(). + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + static bool unique(const const_node_ptr & node) + { return tree_algorithms::unique(node); } + + //! <b>Requires</b>: node is a node of the tree but it's not the header. + //! + //! <b>Effects</b>: Returns the number of nodes of the subtree. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & node) + { return tree_algorithms::count(node); } + + //! <b>Requires</b>: header is the header node of the tree. + //! + //! <b>Effects</b>: Returns the number of nodes above the header. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t size(const const_node_ptr & header) + { return tree_algorithms::size(header); } + + //! <b>Requires</b>: p is a node from the tree except the header. + //! + //! <b>Effects</b>: Returns the next node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr next_node(const node_ptr & p) + { return tree_algorithms::next_node(p); } + + //! <b>Requires</b>: p is a node from the tree except the leftmost node. + //! + //! <b>Effects</b>: Returns the previous node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr prev_node(const node_ptr & p) + { return tree_algorithms::prev_node(p); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: After the function unique(node) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init(const node_ptr & node) + { tree_algorithms::init(node); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: Initializes the header to represent an empty tree. + //! unique(header) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init_header(const node_ptr & header) + { tree_algorithms::init_header(header); } + + //! <b>Requires</b>: header must be the header of a tree, z a node + //! of that tree and z != header. + //! + //! <b>Effects</b>: Erases node "z" from the tree with header "header". + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + template<class AlphaByMaxSize> + static node_ptr erase(const node_ptr & header, const node_ptr & z, std::size_t tree_size, std::size_t &max_tree_size, AlphaByMaxSize alpha_by_maxsize) + { + //typename tree_algorithms::data_for_rebalance info; + tree_algorithms::erase(header, z); + --tree_size; + if (tree_size > 0 && + tree_size < alpha_by_maxsize(max_tree_size)){ + tree_algorithms::rebalance(header); + max_tree_size = tree_size; + } + return z; + } + + //! <b>Requires</b>: "cloner" must be a function + //! object taking a node_ptr and returning a new cloned node of it. "disposer" must + //! take a node_ptr and shouldn't throw. + //! + //! <b>Effects</b>: First empties target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! Then, duplicates the entire tree pointed by "source_header" cloning each + //! source node with <tt>node_ptr Cloner::operator()(const node_ptr &)</tt> to obtain + //! the nodes of the target tree. If "cloner" throws, the cloned target nodes + //! are disposed using <tt>void disposer(const node_ptr &)</tt>. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template <class Cloner, class Disposer> + static void clone + (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) + { + tree_algorithms::clone(source_header, target_header, cloner, disposer); + } + + //! <b>Requires</b>: "disposer" must be an object function + //! taking a node_ptr parameter and shouldn't throw. + //! + //! <b>Effects</b>: Empties the target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template<class Disposer> + static void clear_and_dispose(const node_ptr & header, Disposer disposer) + { tree_algorithms::clear_and_dispose(header, disposer); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is + //! not less than "key" according to "comp" or "header" if that element does + //! not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr lower_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::lower_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is greater + //! than "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr upper_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::upper_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the element that is equivalent to + //! "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr find + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::find(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an a pair of node_ptr delimiting a range containing + //! all elements that are equivalent to "key" according to "comp" or an + //! empty range that indicates the position where those elements would be + //! if they there are no equivalent elements. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, node_ptr> equal_range + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::equal_range(header, key, comp); } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the upper bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare, class H_Alpha> + static node_ptr insert_equal_upper_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp + ,std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + std::size_t depth; + tree_algorithms::insert_equal_upper_bound(h, new_node, comp, &depth); + rebalance_after_insertion(new_node, depth, tree_size+1, h_alpha, max_tree_size); + return new_node; + } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the lower bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare, class H_Alpha> + static node_ptr insert_equal_lower_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp + ,std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + std::size_t depth; + tree_algorithms::insert_equal_lower_bound(h, new_node, comp, &depth); + rebalance_after_insertion(new_node, depth, tree_size+1, h_alpha, max_tree_size); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. "hint" is node from + //! the "header"'s tree. + //! + //! <b>Effects</b>: Inserts new_node into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case). + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if new_node is inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare, class H_Alpha> + static node_ptr insert_equal + (const node_ptr & header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp + ,std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + std::size_t depth; + tree_algorithms::insert_equal(header, hint, new_node, comp, &depth); + rebalance_after_insertion(new_node, depth, tree_size+1, h_alpha, max_tree_size); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { + std::size_t depth; + std::pair<node_ptr, bool> ret = + tree_algorithms::insert_unique_check(header, key, comp, commit_data, &depth); + commit_data.depth = depth; + return ret; + } + + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "pos" must be a valid iterator or header (end) node. + //! "pos" must be an iterator pointing to the successor to "new_node" + //! once inserted according to the order of already inserted nodes. This function does not + //! check "pos" and this precondition must be guaranteed by the caller. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "pos" is not the successor of the newly inserted "new_node" + //! tree invariants might be broken. + template<class H_Alpha> + static node_ptr insert_before + (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node + ,std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + std::size_t depth; + tree_algorithms::insert_before(header, pos, new_node, &depth); + rebalance_after_insertion(new_node, depth, tree_size+1, h_alpha, max_tree_size); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering no less than the + //! greatest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is less than the greatest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + template<class H_Alpha> + static void push_back(const node_ptr & header, const node_ptr & new_node + ,std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + std::size_t depth; + tree_algorithms::push_back(header, new_node, &depth); + rebalance_after_insertion(new_node, depth, tree_size+1, h_alpha, max_tree_size); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering, no greater than the + //! lowest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is greater than the lowest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + template<class H_Alpha> + static void push_front(const node_ptr & header, const node_ptr & new_node + ,std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + std::size_t depth; + tree_algorithms::push_front(header, new_node, &depth); + rebalance_after_insertion(new_node, depth, tree_size+1, h_alpha, max_tree_size); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! "hint" is node from the "header"'s tree. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" using "hint" as a hint to where it should be + //! inserted and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! If "hint" is the upper_bound the function has constant time + //! complexity (two comparisons in the worst case). + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic, but it is + //! amortized constant time if new_node should be inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const node_ptr &hint, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { + std::size_t depth; + std::pair<node_ptr, bool> ret = + tree_algorithms::insert_unique_check + (header, hint, key, comp, commit_data, &depth); + commit_data.depth = depth; + return ret; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "commit_data" must have been obtained from a previous call to + //! "insert_unique_check". No objects should have been inserted or erased + //! from the set between the "insert_unique_check" that filled "commit_data" + //! and the call to "insert_commit". + //! + //! + //! <b>Effects</b>: Inserts new_node in the set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_unique_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + template<class H_Alpha> + static void insert_unique_commit + (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data + ,std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + tree_algorithms::insert_unique_commit(header, new_value, commit_data); + rebalance_after_insertion(new_value, commit_data.depth, tree_size+1, h_alpha, max_tree_size); + } + + //! <b>Requires</b>: header must be the header of a tree. + //! + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + static void rebalance(const node_ptr & header) + { tree_algorithms::rebalance(header); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + static node_ptr rebalance_subtree(const node_ptr & old_root) + { return tree_algorithms::rebalance_subtree(old_root); } + + //! <b>Requires</b>: "n" must be a node inserted in a tree. + //! + //! <b>Effects</b>: Returns a pointer to the header node of the tree. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_header(const node_ptr & n) + { return tree_algorithms::get_header(n); } + + /// @cond + private: + + //! <b>Requires</b>: p is a node of a tree. + //! + //! <b>Effects</b>: Returns true if p is the header of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool is_header(const const_node_ptr & p) + { return tree_algorithms::is_header(p); } + + template<class H_Alpha> + static void rebalance_after_insertion + (const node_ptr &x, std::size_t depth + , std::size_t tree_size, H_Alpha h_alpha, std::size_t &max_tree_size) + { + if(tree_size > max_tree_size) + max_tree_size = tree_size; + + if(tree_size != 1 && depth > h_alpha(tree_size)){ + //Find the first non height-balanced node + //as described in the section 4.2 of the paper. + //This method is the alternative method described + //in the paper. Authors claim that this method + //may tend to yield more balanced trees on the average + //than the weight balanced method. + node_ptr s = x; + std::size_t size = 1; + + for(std::size_t i = 1; true; ++i){ + bool rebalance = false; + if(i == depth){ + BOOST_INTRUSIVE_INVARIANT_ASSERT(tree_size == count(s)); + rebalance = true; + } + else if(i > h_alpha(size)){ + node_ptr s_parent = NodeTraits::get_parent(s); + node_ptr s_parent_left = NodeTraits::get_left(s_parent); + size += 1 + tree_algorithms::count + ( s_parent_left == s ? NodeTraits::get_right(s_parent) : s_parent_left ); + s = s_parent; + rebalance = true; + } + if(rebalance){ + rebalance_subtree(s); + break; + } + } + } + } + + /// @endcond +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SGTREE_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/slist.hpp b/src/third_party/boost/boost/intrusive/slist.hpp new file mode 100644 index 00000000000..505343869ac --- /dev/null +++ b/src/third_party/boost/boost/intrusive/slist.hpp @@ -0,0 +1,2134 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_SLIST_HPP +#define BOOST_INTRUSIVE_SLIST_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/static_assert.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/slist_hook.hpp> +#include <boost/intrusive/circular_slist_algorithms.hpp> +#include <boost/intrusive/linear_slist_algorithms.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <iterator> +#include <functional> +#include <algorithm> +#include <cstddef> //std::size_t +#include <utility> //std::pair +#include <boost/move/move.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +template <class ValueTraits, class SizeType, bool ConstantTimeSize, bool Linear, bool CacheLast> +struct slistopt +{ + typedef ValueTraits value_traits; + typedef SizeType size_type; + static const bool constant_time_size = ConstantTimeSize; + static const bool linear = Linear; + static const bool cache_last = CacheLast; +}; + +template<class Node, class NodePtr, bool> +struct root_plus_last +{ + Node root_; + NodePtr last_; +}; + +template<class Node, class NodePtr> +struct root_plus_last<Node, NodePtr, false> +{ + Node root_; +}; + +template <class T> +struct slist_defaults + : pack_options + < none + , base_hook<detail::default_slist_hook> + , constant_time_size<true> + , linear<false> + , size_type<std::size_t> + , cache_last<false> + >::type +{}; + +/// @endcond + +//! The class template slist is an intrusive container, that encapsulates +//! a singly-linked list. You can use such a list to squeeze the last bit +//! of performance from your application. Unfortunately, the little gains +//! come with some huge drawbacks. A lot of member functions can't be +//! implemented as efficiently as for standard containers. To overcome +//! this limitation some other member functions with rather unusual semantics +//! have to be introduced. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<>, +//! \c linear<> and \c cache_last<>. +//! +//! The iterators of slist are forward iterators. slist provides a static +//! function called "previous" to compute the previous iterator of a given iterator. +//! This function has linear complexity. To improve the usability esp. with +//! the '*_after' functions, ++end() == begin() and previous(begin()) == end() +//! are defined. An new special function "before_begin()" is defined, which returns +//! an iterator that points one less the beginning of the list: ++before_begin() == begin() +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class slist_impl + : private detail::clear_on_destructor_base<slist_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + //Public typedefs + public: + typedef typename Config::value_traits value_traits; + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + /// @endcond + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + typedef typename pointer_traits<pointer>::element_type value_type; + typedef typename pointer_traits<pointer>::reference reference; + typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef typename pointer_traits<pointer>::difference_type difference_type; + typedef typename Config::size_type size_type; + typedef slist_iterator<slist_impl, false> iterator; + typedef slist_iterator<slist_impl, true> const_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + + typedef typename detail::if_c + < Config::linear + , linear_slist_algorithms<node_traits> + , circular_slist_algorithms<node_traits> + >::type node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + static const bool linear = Config::linear; + static const bool cache_last = Config::cache_last; + + /// @cond + private: + typedef detail::size_holder<constant_time_size, size_type> size_traits; + + //noncopyable + BOOST_MOVABLE_BUT_NOT_COPYABLE(slist_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + //Constant-time size is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink))); + //Linear singly linked lists are incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(linear && ((int)real_value_traits::link_mode == (int)auto_unlink))); + //A list with cached last node is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(cache_last && ((int)real_value_traits::link_mode == (int)auto_unlink))); + + node_ptr get_end_node() + { return node_ptr(linear ? node_ptr() : this->get_root_node()); } + + const_node_ptr get_end_node() const + { + return const_node_ptr + (linear ? const_node_ptr() : this->get_root_node()); } + + node_ptr get_root_node() + { return pointer_traits<node_ptr>::pointer_to(data_.root_plus_size_.root_); } + + const_node_ptr get_root_node() const + { return pointer_traits<const_node_ptr>::pointer_to(data_.root_plus_size_.root_); } + + node_ptr get_last_node() + { return this->get_last_node(detail::bool_<cache_last>()); } + + const_node_ptr get_last_node() const + { return this->get_last_node(detail::bool_<cache_last>()); } + + void set_last_node(const node_ptr &n) + { return this->set_last_node(n, detail::bool_<cache_last>()); } + + static node_ptr get_last_node(detail::bool_<false>) + { return node_ptr(); } + + static void set_last_node(const node_ptr &, detail::bool_<false>) + {} + + node_ptr get_last_node(detail::bool_<true>) + { return node_ptr(data_.root_plus_size_.last_); } + + const_node_ptr get_last_node(detail::bool_<true>) const + { return const_node_ptr(data_.root_plus_size_.last_); } + + void set_last_node(const node_ptr & n, detail::bool_<true>) + { data_.root_plus_size_.last_ = n; } + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + void set_default_constructed_state() + { + node_algorithms::init_header(this->get_root_node()); + this->priv_size_traits().set_size(size_type(0)); + if(cache_last){ + this->set_last_node(this->get_root_node()); + } + } + + struct root_plus_size + : public size_traits + , public root_plus_last<node, node_ptr, cache_last> + {}; + + struct data_t + : public slist_impl::value_traits + { + typedef typename slist_impl::value_traits value_traits; + data_t(const value_traits &val_traits) + : value_traits(val_traits) + {} + + root_plus_size root_plus_size_; + } data_; + + size_traits &priv_size_traits() + { return data_.root_plus_size_; } + + const size_traits &priv_size_traits() const + { return data_.root_plus_size_; } + + const real_value_traits &get_real_value_traits(detail::bool_<false>) const + { return data_; } + + const real_value_traits &get_real_value_traits(detail::bool_<true>) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::bool_<false>) + { return data_; } + + real_value_traits &get_real_value_traits(detail::bool_<true>) + { return data_.get_value_traits(*this); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + protected: + node &prot_root_node() + { return data_.root_plus_size_.root_; } + + node const &prot_root_node() const + { return data_.root_plus_size_.root_; } + + void prot_set_size(size_type s) + { data_.root_plus_size_.set_size(s); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + public: + //! <b>Effects</b>: constructs an empty list. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). + slist_impl(const value_traits &v_traits = value_traits()) + : data_(v_traits) + { this->set_default_constructed_state(); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! + //! <b>Effects</b>: Constructs a list equal to [first,last). + //! + //! <b>Complexity</b>: Linear in std::distance(b, e). No copy constructors are called. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). + template<class Iterator> + slist_impl(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) + : data_(v_traits) + { + this->set_default_constructed_state(); + this->insert_after(this->cbefore_begin(), b, e); + } + + //! <b>Effects</b>: to-do + //! + slist_impl(BOOST_RV_REF(slist_impl) x) + : data_(::boost::move(x.priv_value_traits())) + { + this->priv_size_traits().set_size(size_type(0)); + node_algorithms::init_header(this->get_root_node()); + this->swap(x); + } + + //! <b>Effects</b>: to-do + //! + slist_impl& operator=(BOOST_RV_REF(slist_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: If it's a safe-mode + //! or auto-unlink value, the destructor does nothing + //! (ie. no code is generated). Otherwise it detaches all elements from this. + //! In this case the objects in the list are not deleted (i.e. no destructors + //! are called), but the hooks according to the value_traits template parameter + //! are set to their default value. + //! + //! <b>Complexity</b>: Linear to the number of elements in the list, if + //! it's a safe-mode or auto-unlink value. Otherwise constant. + ~slist_impl() + {} + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements of the list. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased elements. + void clear() + { + if(safemode_or_autounlink){ + this->clear_and_dispose(detail::null_disposer()); + } + else{ + this->set_default_constructed_state(); + } + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements of the list. + //! + //! <b>Note</b>: Invalidates the iterators to the erased elements. + template <class Disposer> + void clear_and_dispose(Disposer disposer) + { + const_iterator it(this->begin()), itend(this->end()); + while(it != itend){ + node_ptr to_erase(it.pointed_node()); + ++it; + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + } + this->set_default_constructed_state(); + } + + //! <b>Requires</b>: value must be an lvalue. + //! + //! <b>Effects</b>: Inserts the value in the front of the list. + //! No copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void push_front(reference value) + { + node_ptr to_insert = get_real_value_traits().to_node_ptr(value); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); + if(cache_last){ + if(this->empty()){ + this->set_last_node(to_insert); + } + } + node_algorithms::link_after(this->get_root_node(), to_insert); + this->priv_size_traits().increment(); + } + + //! <b>Requires</b>: value must be an lvalue. + //! + //! <b>Effects</b>: Inserts the value in the back of the list. + //! No copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! This function is only available is cache_last<> is true. + void push_back(reference value) + { + BOOST_STATIC_ASSERT((cache_last)); + this->insert_after(const_iterator(this->get_last_node(), this), value); + } + + //! <b>Effects</b>: Erases the first element of the list. + //! No destructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element. + void pop_front() + { return this->pop_front_and_dispose(detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the first element of the list. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Invalidates the iterators to the erased element. + template<class Disposer> + void pop_front_and_dispose(Disposer disposer) + { + node_ptr to_erase = node_traits::get_next(this->get_root_node()); + node_algorithms::unlink_after(this->get_root_node()); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + if(cache_last){ + if(this->empty()){ + this->set_last_node(this->get_root_node()); + } + } + } + + //! <b>Effects</b>: Returns a reference to the first element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + reference front() + { return *this->get_real_value_traits().to_value_ptr(node_traits::get_next(this->get_root_node())); } + + //! <b>Effects</b>: Returns a const_reference to the first element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_reference front() const + { return *this->get_real_value_traits().to_value_ptr(uncast(node_traits::get_next(this->get_root_node()))); } + + //! <b>Effects</b>: Returns a reference to the last element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! This function is only available is cache_last<> is true. + reference back() + { + BOOST_STATIC_ASSERT((cache_last)); + return *this->get_real_value_traits().to_value_ptr(this->get_last_node()); + } + + //! <b>Effects</b>: Returns a const_reference to the last element of the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! This function is only available is cache_last<> is true. + const_reference back() const + { + BOOST_STATIC_ASSERT((cache_last)); + return *this->get_real_value_traits().to_value_ptr(this->get_last_node()); + } + + //! <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 (node_traits::get_next(this->get_root_node()), this); } + + //! <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 const_iterator (node_traits::get_next(this->get_root_node()), this); } + + //! <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(node_traits::get_next(this->get_root_node()), this); } + + //! <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->get_end_node(), this); } + + //! <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 const_iterator(uncast(this->get_end_node()), this); } + + //! <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 this->end(); } + + //! <b>Effects</b>: Returns an iterator that points to a position + //! before the first element. Equivalent to "end()" + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + iterator before_begin() + { return iterator(this->get_root_node(), this); } + + //! <b>Effects</b>: Returns an iterator that points to a position + //! before the first element. Equivalent to "end()" + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_iterator before_begin() const + { return const_iterator(uncast(this->get_root_node()), this); } + + //! <b>Effects</b>: Returns an iterator that points to a position + //! before the first element. Equivalent to "end()" + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + const_iterator cbefore_begin() const + { return this->before_begin(); } + + //! <b>Effects</b>: Returns an iterator to the last element contained in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: This function is present only if cached_last<> option is true. + iterator last() + { return iterator (this->get_last_node(), this); } + + //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: This function is present only if cached_last<> option is true. + const_iterator last() const + { return const_iterator (this->get_last_node(), this); } + + //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: This function is present only if cached_last<> option is true. + const_iterator clast() const + { return const_iterator(this->get_last_node(), this); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of slist. + //! + //! <b>Effects</b>: Returns a const reference to the slist associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static slist_impl &container_from_end_iterator(iterator end_iterator) + { return slist_impl::priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of slist. + //! + //! <b>Effects</b>: Returns a const reference to the slist associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const slist_impl &container_from_end_iterator(const_iterator end_iterator) + { return slist_impl::priv_container_from_end_iterator(end_iterator); } + + //! <b>Effects</b>: Returns the number of the elements contained in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements contained in the list. + //! if constant_time_size is false. Constant time otherwise. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + size_type size() const + { + if(constant_time_size) + return this->priv_size_traits().get_size(); + else + return node_algorithms::count(this->get_root_node()) - 1; + } + + //! <b>Effects</b>: Returns true if the list contains no elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + bool empty() const + { return node_algorithms::unique(this->get_root_node()); } + + //! <b>Effects</b>: Swaps the elements of x and *this. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements of both lists. + //! Constant-time if linear<> and/or cache_last<> options are used. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void swap(slist_impl& other) + { + if(cache_last){ + priv_swap_cache_last(this, &other); + } + else{ + this->priv_swap_lists(this->get_root_node(), other.get_root_node(), detail::bool_<linear>()); + } + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + } + + //! <b>Effects</b>: Moves backwards all the elements, so that the first + //! element becomes the second, the second becomes the third... + //! the last element becomes the first one. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements plus the number shifts. + //! + //! <b>Note</b>: Iterators Does not affect the validity of iterators and references. + void shift_backwards(size_type n = 1) + { this->priv_shift_backwards(n, detail::bool_<linear>()); } + + //! <b>Effects</b>: Moves forward all the elements, so that the second + //! element becomes the first, the third becomes the second... + //! the first element becomes the last one. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements plus the number shifts. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + void shift_forward(size_type n = 1) + { this->priv_shift_forward(n, detail::bool_<linear>()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws. + template <class Cloner, class Disposer> + void clone_from(const slist_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + detail::exception_disposer<slist_impl, Disposer> + rollback(*this, disposer); + const_iterator prev(this->cbefore_begin()); + const_iterator b(src.begin()), e(src.end()); + for(; b != e; ++b){ + prev = this->insert_after(prev, *cloner(*b)); + } + rollback.release(); + } + + //! <b>Requires</b>: value must be an lvalue and prev_p must point to an element + //! contained by the list or to end(). + //! + //! <b>Effects</b>: Inserts the value after the position pointed by prev_p. + //! No copy constructor is called. + //! + //! <b>Returns</b>: An iterator to the inserted element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + iterator insert_after(const_iterator prev_p, reference value) + { + node_ptr n = get_real_value_traits().to_node_ptr(value); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(n)); + node_ptr prev_n(prev_p.pointed_node()); + node_algorithms::link_after(prev_n, n); + if(cache_last && (this->get_last_node() == prev_n)){ + this->set_last_node(n); + } + this->priv_size_traits().increment(); + return iterator (n, this); + } + + //! <b>Requires</b>: Dereferencing iterator must yield + //! an lvalue of type value_type and prev_p must point to an element + //! contained by the list or to the end node. + //! + //! <b>Effects</b>: Inserts the [first, last) + //! after the position prev_p. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements inserted. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + template<class Iterator> + void insert_after(const_iterator prev_p, Iterator first, Iterator last) + { + for (; first != last; ++first) + prev_p = this->insert_after(prev_p, *first); + } + + //! <b>Requires</b>: value must be an lvalue and p must point to an element + //! contained by the list or to end(). + //! + //! <b>Effects</b>: Inserts the value before the position pointed by p. + //! No copy constructor is called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements before p. + //! Constant-time if cache_last<> is true and p == end(). + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + iterator insert(const_iterator p, reference value) + { return this->insert_after(this->previous(p), value); } + + //! <b>Requires</b>: Dereferencing iterator must yield + //! an lvalue of type value_type and p must point to an element + //! contained by the list or to the end node. + //! + //! <b>Effects</b>: Inserts the pointed by b and e + //! before the position p. No copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements inserted plus linear + //! to the elements before b. + //! Linear to the number of elements to insert if cache_last<> option is true and p == end(). + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + template<class Iterator> + void insert(const_iterator p, Iterator b, Iterator e) + { return this->insert_after(this->previous(p), b, e); } + + //! <b>Effects</b>: Erases the element after the element pointed by prev of + //! the list. No destructors are called. + //! + //! <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>: Invalidates the iterators (but not the references) to the + //! erased element. + iterator erase_after(const_iterator prev) + { return this->erase_after_and_dispose(prev, detail::null_disposer()); } + + //! <b>Effects</b>: Erases the range (before_first, last) from + //! the list. No destructors are called. + //! + //! <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 if it's a safe-mode + //! , auto-unlink value or constant-time size is activated. Constant time otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased element. + iterator erase_after(const_iterator before_first, const_iterator last) + { + if(safemode_or_autounlink || constant_time_size){ + return this->erase_after_and_dispose(before_first, last, detail::null_disposer()); + } + else{ + node_ptr bfp = before_first.pointed_node(); + node_ptr lp = last.pointed_node(); + if(cache_last){ + if(lp == this->get_end_node()){ + this->set_last_node(bfp); + } + } + node_algorithms::unlink_after(bfp, lp); + return last.unconst(); + } + } + + //! <b>Effects</b>: Erases the range (before_first, last) from + //! the list. n must be std::distance(before_first, last) - 1. + //! No destructors are called. + //! + //! <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-time if link_mode is normal_link. + //! Linear to the elements (last - before_first) otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased element. + iterator erase_after(const_iterator before_first, const_iterator last, difference_type n) + { + BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(++const_iterator(before_first), last) == difference_type(n)); + if(safemode_or_autounlink){ + return this->erase_after(before_first, last); + } + else{ + node_ptr bfp = before_first.pointed_node(); + node_ptr lp = last.pointed_node(); + if(cache_last){ + if((lp == this->get_end_node())){ + this->set_last_node(bfp); + } + } + node_algorithms::unlink_after(bfp, lp); + if(constant_time_size){ + this->priv_size_traits().set_size(this->priv_size_traits().get_size() - n); + } + return last.unconst(); + } + } + + //! <b>Effects</b>: Erases the element pointed by i of the list. + //! No destructors are called. + //! + //! <b>Returns</b>: the first element remaining beyond the removed element, + //! or end() if no such element exists. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements before i. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased element. + iterator erase(const_iterator i) + { return this->erase_after(this->previous(i)); } + + //! <b>Requires</b>: first and last must be valid iterator to elements in *this. + //! + //! <b>Effects</b>: Erases the range pointed by b and e. + //! No destructors are called. + //! + //! <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 elements before last. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased elements. + iterator erase(const_iterator first, const_iterator last) + { return this->erase_after(this->previous(first), last); } + + //! <b>Effects</b>: Erases the range [first, last) from + //! the list. n must be std::distance(first, last). + //! No destructors are called. + //! + //! <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 elements before first if link_mode is normal_link + //! and constant_time_size is activated. Linear to the elements before last otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased element. + iterator erase(const_iterator first, const_iterator last, difference_type n) + { return this->erase_after(this->previous(first), last, n); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element after the element pointed by prev of + //! the list. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <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>: Invalidates the iterators to the erased element. + template<class Disposer> + iterator erase_after_and_dispose(const_iterator prev, Disposer disposer) + { + const_iterator it(prev); + ++it; + node_ptr to_erase(it.pointed_node()); + ++it; + node_ptr prev_n(prev.pointed_node()); + node_algorithms::unlink_after(prev_n); + if(cache_last && (to_erase == this->get_last_node())){ + this->set_last_node(prev_n); + } + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + this->priv_size_traits().decrement(); + return it.unconst(); + } + + /// @cond + + template<class Disposer> + static iterator s_erase_after_and_dispose(const_iterator prev, Disposer disposer) + { + BOOST_STATIC_ASSERT(((!cache_last)&&(!constant_time_size)&&(!stateful_value_traits))); + const_iterator it(prev); + ++it; + node_ptr to_erase(it.pointed_node()); + ++it; + node_ptr prev_n(prev.pointed_node()); + node_algorithms::unlink_after(prev_n); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(real_value_traits::to_value_ptr(to_erase)); + return it.unconst(); + } + + static iterator s_erase_after(const_iterator prev) + { return s_erase_after_and_dispose(prev, detail::null_disposer()); } + + /// @endcond + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range (before_first, last) from + //! the list. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <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>: Lineal to the elements (last - before_first + 1). + //! + //! <b>Note</b>: Invalidates the iterators to the erased element. + template<class Disposer> + iterator erase_after_and_dispose(const_iterator before_first, const_iterator last, Disposer disposer) + { + node_ptr bfp(before_first.pointed_node()), lp(last.pointed_node()); + node_ptr fp(node_traits::get_next(bfp)); + node_algorithms::unlink_after(bfp, lp); + while(fp != lp){ + node_ptr to_erase(fp); + fp = node_traits::get_next(fp); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + this->priv_size_traits().decrement(); + } + if(cache_last && (node_traits::get_next(bfp) == this->get_end_node())){ + this->set_last_node(bfp); + } + return last.unconst(); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed by i of the list. + //! No destructors are called. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Returns</b>: the first element remaining beyond the removed element, + //! or end() if no such element exists. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements before i. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased element. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return this->erase_after_and_dispose(this->previous(i), disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: first and last must be valid iterator to elements in *this. + //! Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed by b and e. + //! No destructors are called. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <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 plus linear + //! to the elements before first. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) to the + //! erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator first, const_iterator last, Disposer disposer) + { return this->erase_after_and_dispose(this->previous(first), last, disposer); } + + //! <b>Requires</b>: Dereferencing iterator must yield + //! an lvalue of type value_type. + //! + //! <b>Effects</b>: Clears the list and inserts the range pointed by b and e. + //! No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements inserted plus + //! linear to the elements contained in the list if it's a safe-mode + //! or auto-unlink value. + //! Linear to the number of elements inserted in the list otherwise. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. + template<class Iterator> + void assign(Iterator b, Iterator e) + { + this->clear(); + this->insert_after(this->cbefore_begin(), b, e); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Requires</b>: Dereferencing iterator must yield + //! an lvalue of type value_type. + //! + //! <b>Effects</b>: Clears the list and inserts the range pointed by b and e. + //! No destructors or copy constructors are called. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements inserted plus + //! linear to the elements contained in the list. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. + template<class Iterator, class Disposer> + void dispose_and_assign(Disposer disposer, Iterator b, Iterator e) + { + this->clear_and_dispose(disposer); + this->insert_after(this->cbefore_begin(), b, e, disposer); + } + + //! <b>Requires</b>: prev must point to an element contained by this list or + //! to the before_begin() element + //! + //! <b>Effects</b>: Transfers all the elements of list x to this list, after the + //! the element pointed by prev. No destructors or copy constructors are called. + //! + //! <b>Returns</b>: Nothing. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: In general, linear to the elements contained in x. + //! Constant-time if cache_last<> option is true and also constant-time if + //! linear<> option is true "this" is empty and "last" is not used. + //! + //! <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. + //! + //! <b>Additional note</b>: If the optional parameter "last" is provided, it will be + //! assigned to the last spliced element or prev if x is empty. + //! This iterator can be used as new "prev" iterator for a new splice_after call. + //! that will splice new values after the previously spliced values. + void splice_after(const_iterator prev, slist_impl &x, const_iterator *last = 0) + { + if(x.empty()){ + if(last) *last = prev; + } + else if(linear && this->empty()){ + this->swap(x); + if(last) *last = this->previous(this->cend()); + } + else{ + const_iterator last_x(x.previous(x.end())); //<- constant time if cache_last is active + node_ptr prev_n(prev.pointed_node()); + node_ptr last_x_n(last_x.pointed_node()); + if(cache_last){ + x.set_last_node(x.get_root_node()); + if(node_traits::get_next(prev_n) == this->get_end_node()){ + this->set_last_node(last_x_n); + } + } + node_algorithms::transfer_after( prev_n, x.before_begin().pointed_node(), last_x_n); + this->priv_size_traits().set_size(this->priv_size_traits().get_size() + x.priv_size_traits().get_size()); + x.priv_size_traits().set_size(size_type(0)); + if(last) *last = last_x; + } + } + + //! <b>Requires</b>: prev must point to an element contained by this list or + //! to the before_begin() element. prev_ele must point to an element contained in list + //! x or must be x.before_begin(). + //! + //! <b>Effects</b>: Transfers the element after prev_ele, from list x to this list, + //! after the element pointed by prev. No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <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_impl &x, const_iterator prev_ele) + { + const_iterator elem = prev_ele; + this->splice_after(prev_pos, x, prev_ele, ++elem, 1); + } + + //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be + //! before_begin(), and before_first and before_last belong to x and + //! ++before_first != x.end() && before_last != x.end(). + //! + //! <b>Effects</b>: Transfers the range (before_first, before_last] from list x to this + //! list, after the element pointed by prev_pos. + //! No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements transferred + //! if constant_time_size is true. Constant-time otherwise. + //! + //! <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_impl &x, const_iterator before_first, const_iterator before_last) + { + if(constant_time_size) + this->splice_after(prev_pos, x, before_first, before_last, std::distance(before_first, before_last)); + else + this->priv_splice_after + (prev_pos.pointed_node(), x, before_first.pointed_node(), before_last.pointed_node()); + } + + //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be + //! before_begin(), and before_first and before_last belong to x and + //! ++before_first != x.end() && before_last != x.end() and + //! n == std::distance(before_first, before_last). + //! + //! <b>Effects</b>: Transfers the range (before_first, before_last] from list x to this + //! list, after the element pointed by p. No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <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_impl &x, const_iterator before_first, const_iterator before_last, difference_type n) + { + if(n){ + BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(before_first, before_last) == n); + this->priv_splice_after + (prev_pos.pointed_node(), x, before_first.pointed_node(), before_last.pointed_node()); + if(constant_time_size){ + this->priv_size_traits().set_size(this->priv_size_traits().get_size() + n); + x.priv_size_traits().set_size(x.priv_size_traits().get_size() - n); + } + } + } + + //! <b>Requires</b>: it is an iterator to an element in *this. + //! + //! <b>Effects</b>: Transfers all the elements of list x to this list, before the + //! the element pointed by it. No destructors or copy constructors are called. + //! + //! <b>Returns</b>: Nothing. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements contained in x plus linear to + //! the elements before it. + //! Linear to the elements before it if cache_last<> option is true. + //! Constant-time if cache_last<> option is true and it == end(). + //! + //! <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. + //! + //! <b>Additional note</b>: If the optional parameter "last" is provided, it will be + //! assigned to the last spliced element or prev if x is empty. + //! This iterator can be used as new "prev" iterator for a new splice_after call. + //! that will splice new values after the previously spliced values. + void splice(const_iterator it, slist_impl &x, const_iterator *last = 0) + { this->splice_after(this->previous(it), x, last); } + + //! <b>Requires</b>: it p must be a valid iterator of *this. + //! elem must point to an element contained in list + //! x. + //! + //! <b>Effects</b>: Transfers the element elem, from list x to this list, + //! before the element pointed by pos. No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements before pos and before elem. + //! Linear to the elements before elem if cache_last<> option is true and pos == end(). + //! + //! <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 pos, slist_impl &x, const_iterator elem) + { return this->splice_after(this->previous(pos), x, x.previous(elem)); } + + //! <b>Requires</b>: pos must be a dereferenceable iterator in *this + //! and first and last belong to x and first and last a valid range on x. + //! + //! <b>Effects</b>: Transfers the range [first, last) from list x to this + //! list, before the element pointed by pos. + //! No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the sum of elements before pos, first, and last + //! plus linear to the number of elements transferred if constant_time_size is true. + //! Linear to the sum of elements before first, and last + //! plus linear to the number of elements transferred if constant_time_size is true + //! if cache_last<> is true and pos == end() + //! + //! <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 pos, slist_impl &x, const_iterator first, const_iterator last) + { return this->splice_after(this->previous(pos), x, x.previous(first), x.previous(last)); } + + //! <b>Requires</b>: pos must be a dereferenceable iterator in *this + //! and first and last belong to x and first and last a valid range on x. + //! n == std::distance(first, last). + //! + //! <b>Effects</b>: Transfers the range [first, last) from list x to this + //! list, before the element pointed by pos. + //! No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the sum of elements before pos, first, and last. + //! Linear to the sum of elements before first and last + //! if cache_last<> is true and pos == end(). + //! + //! <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 pos, slist_impl &x, const_iterator first, const_iterator last, difference_type n) + { return this->splice_after(this->previous(pos), x, x.previous(first), x.previous(last), n); } + + //! <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>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the predicate throws. Basic guarantee. + //! + //! <b>Complexity</b>: The number of comparisons is approximately N log N, where N + //! is the list's size. + //! + //! <b>Note</b>: Iterators and references are not invalidated + template<class Predicate> + void sort(Predicate p) + { + if (node_traits::get_next(node_traits::get_next(this->get_root_node())) + != this->get_root_node()) { + + slist_impl carry(this->priv_value_traits()); + detail::array_initializer<slist_impl, 64> counter(this->priv_value_traits()); + int fill = 0; + const_iterator last_inserted; + while(!this->empty()){ + last_inserted = this->cbegin(); + carry.splice_after(carry.cbefore_begin(), *this, this->cbefore_begin()); + int i = 0; + while(i < fill && !counter[i].empty()) { + carry.swap(counter[i]); + carry.merge(counter[i++], p, &last_inserted); + } + BOOST_INTRUSIVE_INVARIANT_ASSERT(counter[i].empty()); + const_iterator last_element(carry.previous(last_inserted, carry.end())); + + if(constant_time_size){ + counter[i].splice_after( counter[i].cbefore_begin(), carry + , carry.cbefore_begin(), last_element + , carry.size()); + } + else{ + counter[i].splice_after( counter[i].cbefore_begin(), carry + , carry.cbefore_begin(), last_element); + } + if(i == fill) + ++fill; + } + + for (int i = 1; i < fill; ++i) + counter[i].merge(counter[i-1], p, &last_inserted); + --fill; + const_iterator last_element(counter[fill].previous(last_inserted, counter[fill].end())); + if(constant_time_size){ + this->splice_after( cbefore_begin(), counter[fill], counter[fill].cbefore_begin() + , last_element, counter[fill].size()); + } + else{ + this->splice_after( cbefore_begin(), counter[fill], counter[fill].cbefore_begin() + , last_element); + } + } + } + + //! <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. + //! + //! <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. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or std::less<value_type> throws. Basic guarantee. + //! + //! <b>Complexity</b>: This function is linear time: it performs at most + //! size() + x.size() - 1 comparisons. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + void sort() + { this->sort(std::less<value_type>()); } + + //! <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. + //! + //! <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. + //! + //! <b>Returns</b>: Nothing. + //! + //! <b>Throws</b>: If the predicate throws. Basic guarantee. + //! + //! <b>Complexity</b>: This function is linear time: it performs at most + //! size() + x.size() - 1 comparisons. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + //! + //! <b>Additional note</b>: If optional "last" argument is passed, it is assigned + //! to an iterator to the last transferred value or end() is x is empty. + template<class Predicate> + void merge(slist_impl& x, Predicate p, const_iterator *last = 0) + { + const_iterator e(this->cend()), ex(x.cend()), bb(this->cbefore_begin()), + bb_next; + if(last) *last = e.unconst(); + while(!x.empty()){ + const_iterator ibx_next(x.cbefore_begin()), ibx(ibx_next++); + while (++(bb_next = bb) != e && !p(*ibx_next, *bb_next)){ + bb = bb_next; + } + if(bb_next == e){ + //Now transfer the rest to the end of the container + this->splice_after(bb, x, last); + break; + } + else{ + size_type n(0); + do{ + ibx = ibx_next; ++n; + } while(++(ibx_next = ibx) != ex && p(*ibx_next, *bb_next)); + this->splice_after(bb, x, x.before_begin(), ibx, n); + if(last) *last = ibx; + } + } + } + + //! <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. + //! + //! <b>Throws</b>: if std::less<value_type> throws. Basic guarantee. + //! + //! <b>Complexity</b>: This function is linear time: it performs at most + //! size() + x.size() - 1 comparisons. + //! + //! <b>Note</b>: Iterators and references are not invalidated + void merge(slist_impl& x) + { this->merge(x, std::less<value_type>()); } + + //! <b>Effects</b>: Reverses the order of elements in the list. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: This function is linear to the contained elements. + //! + //! <b>Note</b>: Iterators and references are not invalidated + void reverse() + { + if(cache_last && !this->empty()){ + this->set_last_node(node_traits::get_next(this->get_root_node())); + } + this->priv_reverse(detail::bool_<linear>()); + } + + //! <b>Effects</b>: Removes all the elements that compare equal to value. + //! No destructors are called. + //! + //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee. + //! + //! <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. This function is + //! linear time: it performs exactly size() comparisons for equality. + void remove(const_reference value) + { this->remove_if(detail::equal_to_value<const_reference>(value)); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes all the elements that compare equal to value. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee. + //! + //! <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. + template<class Disposer> + void remove_and_dispose(const_reference value, Disposer disposer) + { this->remove_and_dispose_if(detail::equal_to_value<const_reference>(value), disposer); } + + //! <b>Effects</b>: Removes all the elements for which a specified + //! predicate is satisfied. No destructors are called. + //! + //! <b>Throws</b>: If pred throws. Basic guarantee. + //! + //! <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> + void remove_if(Pred pred) + { this->remove_and_dispose_if(pred, detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes all the elements for which a specified + //! predicate is satisfied. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If pred throws. Basic guarantee. + //! + //! <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. + template<class Pred, class Disposer> + void remove_and_dispose_if(Pred pred, Disposer disposer) + { + const_iterator bcur(this->before_begin()), cur(this->begin()), e(this->end()); + + while(cur != e){ + if (pred(*cur)){ + cur = this->erase_after_and_dispose(bcur, disposer); + } + else{ + bcur = cur; + ++cur; + } + } + if(cache_last){ + this->set_last_node(bcur.pointed_node()); + } + } + + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that are equal from the list. No destructors are called. + //! + //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee. + //! + //! <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_and_dispose(std::equal_to<value_type>(), detail::null_disposer()); } + + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that satisfy some binary predicate from the list. + //! No destructors are called. + //! + //! <b>Throws</b>: If the predicate throws. Basic guarantee. + //! + //! <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> + void unique(BinaryPredicate pred) + { this->unique_and_dispose(pred, detail::null_disposer()); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that satisfy some binary predicate from the list. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee. + //! + //! <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 Disposer> + void unique_and_dispose(Disposer disposer) + { this->unique(std::equal_to<value_type>(), disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent + //! elements that satisfy some binary predicate from the list. + //! Disposer::operator()(pointer) is called for every removed element. + //! + //! <b>Throws</b>: If the predicate throws. Basic guarantee. + //! + //! <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, class Disposer> + void unique_and_dispose(BinaryPredicate pred, Disposer disposer) + { + const_iterator end_n(this->cend()); + const_iterator bcur(this->cbegin()); + if(bcur != end_n){ + const_iterator cur(bcur); + ++cur; + while(cur != end_n) { + if (pred(*bcur, *cur)){ + cur = this->erase_after_and_dispose(bcur, disposer); + } + else{ + bcur = cur; + ++cur; + } + } + if(cache_last){ + this->set_last_node(bcur.pointed_node()); + } + } + } + + //! <b>Requires</b>: value must be a reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns a const_iterator pointing to the element + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + //! This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + //BOOST_INTRUSIVE_INVARIANT_ASSERT (!node_algorithms::inited(value_traits::to_node_ptr(value))); + return iterator (value_traits::to_node_ptr(value), 0); + } + + //! <b>Requires</b>: value must be a const reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns an iterator pointing to the element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + //! This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + //BOOST_INTRUSIVE_INVARIANT_ASSERT (!node_algorithms::inited(value_traits::to_node_ptr(const_cast<reference> (value)))); + return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), 0); + } + + //! <b>Requires</b>: value must be a reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns a const_iterator pointing to the element + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + iterator iterator_to(reference value) + { + //BOOST_INTRUSIVE_INVARIANT_ASSERT (!node_algorithms::inited(value_traits::to_node_ptr(value))); + return iterator (value_traits::to_node_ptr(value), this); + } + + //! <b>Requires</b>: value must be a const reference to a value inserted in a list. + //! + //! <b>Effects</b>: This function returns an iterator pointing to the element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: Iterators and references are not invalidated. + const_iterator iterator_to(const_reference value) const + { + //BOOST_INTRUSIVE_INVARIANT_ASSERT (!node_algorithms::inited(value_traits::to_node_ptr(const_cast<reference> (value)))); + return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this); + } + + //! <b>Returns</b>: The iterator to the element before i in the list. + //! Returns the end-iterator, if either i is the begin-iterator or the + //! list is empty. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements before i. + //! Constant if cache_last<> is true and i == end(). + iterator previous(iterator i) + { return this->previous(this->cbefore_begin(), i); } + + //! <b>Returns</b>: The const_iterator to the element before i in the list. + //! Returns the end-const_iterator, if either i is the begin-const_iterator or + //! the list is empty. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements before i. + //! Constant if cache_last<> is true and i == end(). + const_iterator previous(const_iterator i) const + { return this->previous(this->cbefore_begin(), i); } + + //! <b>Returns</b>: The iterator to the element before i in the list, + //! starting the search on element after prev_from. + //! Returns the end-iterator, if either i is the begin-iterator or the + //! list is empty. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements before i. + //! Constant if cache_last<> is true and i == end(). + iterator previous(const_iterator prev_from, iterator i) + { return this->previous(prev_from, const_iterator(i)).unconst(); } + + //! <b>Returns</b>: The const_iterator to the element before i in the list, + //! starting the search on element after prev_from. + //! Returns the end-const_iterator, if either i is the begin-const_iterator or + //! the list is empty. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements before i. + //! Constant if cache_last<> is true and i == end(). + const_iterator previous(const_iterator prev_from, const_iterator i) const + { + if(cache_last && (i.pointed_node() == this->get_end_node())){ + return const_iterator(uncast(this->get_last_node()), this); + } + return const_iterator + (node_algorithms::get_previous_node + (prev_from.pointed_node(), i.pointed_node()), this); + } + + //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be + //! before_begin(), and before_first and before_last belong to x and + //! ++before_first != x.end() && before_last != x.end(). + //! + //! <b>Effects</b>: Transfers the range (before_first, before_last] to this + //! list, after the element pointed by prev_pos. + //! No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the number of elements transferred + //! if constant_time_size is true. Constant-time otherwise. + //! + //! <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 incorporate_after(const_iterator prev_from, const node_ptr & first, const node_ptr & before_last) + { + if(constant_time_size) + this->incorporate_after(prev_from, first, before_last, std::distance(first, before_last)+1); + else + this->priv_incorporate_after + (prev_from.pointed_node(), first, before_last); + } + + //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be + //! before_begin(), and before_first and before_last belong to x and + //! ++before_first != x.end() && before_last != x.end() and + //! n == std::distance(first, before_last) + 1. + //! + //! <b>Effects</b>: Transfers the range (before_first, before_last] from list x to this + //! list, after the element pointed by p. No destructors or copy constructors are called. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <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 incorporate_after(const_iterator prev_pos, const node_ptr & first, const node_ptr & before_last, difference_type n) + { + if(n){ + BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(iterator(first, this), iterator(before_last, this))+1 == n); + this->priv_incorporate_after(prev_pos.pointed_node(), first, before_last); + if(constant_time_size){ + this->priv_size_traits().set_size(this->priv_size_traits().get_size() + n); + } + } + } + + private: + void priv_splice_after(const node_ptr & prev_pos_n, slist_impl &x, const node_ptr & before_first_n, const node_ptr & before_last_n) + { + if (before_first_n != before_last_n && prev_pos_n != before_first_n && prev_pos_n != before_last_n) + { + if(cache_last){ + if(node_traits::get_next(prev_pos_n) == this->get_end_node()){ + this->set_last_node(before_last_n); + } + if(node_traits::get_next(before_last_n) == x.get_end_node()){ + x.set_last_node(before_first_n); + } + } + node_algorithms::transfer_after(prev_pos_n, before_first_n, before_last_n); + } + } + + void priv_incorporate_after(const node_ptr & prev_pos_n, const node_ptr & first_n, const node_ptr & before_last_n) + { + if(cache_last){ + if(node_traits::get_next(prev_pos_n) == this->get_end_node()){ + this->set_last_node(before_last_n); + } + } + node_algorithms::incorporate_after(prev_pos_n, first_n, before_last_n); + } + + void priv_reverse(detail::bool_<false>) + { node_algorithms::reverse(this->get_root_node()); } + + void priv_reverse(detail::bool_<true>) + { + node_ptr new_first = node_algorithms::reverse + (node_traits::get_next(this->get_root_node())); + node_traits::set_next(this->get_root_node(), new_first); + } + + void priv_shift_backwards(size_type n, detail::bool_<false>) + { + node_ptr last = node_algorithms::move_forward(this->get_root_node(), (std::size_t)n); + if(cache_last && last){ + this->set_last_node(last); + } + } + + void priv_shift_backwards(size_type n, detail::bool_<true>) + { + std::pair<node_ptr, node_ptr> ret( + node_algorithms::move_first_n_forward + (node_traits::get_next(this->get_root_node()), (std::size_t)n)); + if(ret.first){ + node_traits::set_next(this->get_root_node(), ret.first); + if(cache_last){ + this->set_last_node(ret.second); + } + } + } + + void priv_shift_forward(size_type n, detail::bool_<false>) + { + node_ptr last = node_algorithms::move_backwards(this->get_root_node(), (std::size_t)n); + if(cache_last && last){ + this->set_last_node(last); + } + } + + void priv_shift_forward(size_type n, detail::bool_<true>) + { + std::pair<node_ptr, node_ptr> ret( + node_algorithms::move_first_n_backwards + (node_traits::get_next(this->get_root_node()), (std::size_t)n)); + if(ret.first){ + node_traits::set_next(this->get_root_node(), ret.first); + if(cache_last){ + this->set_last_node(ret.second); + } + } + } + + static void priv_swap_cache_last(slist_impl *this_impl, slist_impl *other_impl) + { + bool other_was_empty = false; + if(this_impl->empty()){ + //Check if both are empty or + if(other_impl->empty()) + return; + //If this is empty swap pointers + slist_impl *tmp = this_impl; + this_impl = other_impl; + other_impl = tmp; + other_was_empty = true; + } + else{ + other_was_empty = other_impl->empty(); + } + + //Precondition: this is not empty + node_ptr other_old_last(other_impl->get_last_node()); + node_ptr other_bfirst(other_impl->get_root_node()); + node_ptr this_bfirst(this_impl->get_root_node()); + node_ptr this_old_last(this_impl->get_last_node()); + + //Move all nodes from this to other's beginning + node_algorithms::transfer_after(other_bfirst, this_bfirst, this_old_last); + other_impl->set_last_node(this_old_last); + + if(other_was_empty){ + this_impl->set_last_node(this_bfirst); + } + else{ + //Move trailing nodes from other to this + node_algorithms::transfer_after(this_bfirst, this_old_last, other_old_last); + this_impl->set_last_node(other_old_last); + } + } + + //circular version + static void priv_swap_lists(const node_ptr & this_node, const node_ptr & other_node, detail::bool_<false>) + { node_algorithms::swap_nodes(this_node, other_node); } + + //linear version + static void priv_swap_lists(const node_ptr & this_node, const node_ptr & other_node, detail::bool_<true>) + { node_algorithms::swap_trailing_nodes(this_node, other_node); } + + static slist_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) + { + //Obtaining the container from the end iterator is not possible with linear + //singly linked lists (because "end" is represented by the null pointer) + BOOST_STATIC_ASSERT(!linear); + root_plus_size *r = detail::parent_from_member<root_plus_size, node> + ( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), (&root_plus_size::root_)); + data_t *d = detail::parent_from_member<data_t, root_plus_size> + ( r, &data_t::root_plus_size_); + slist_impl *s = detail::parent_from_member<slist_impl, data_t>(d, &slist_impl::data_); + return *s; + } +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator< +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y) +#else +(const slist_impl<Config> &x, const slist_impl<Config> &y) +#endif +{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +bool operator== +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y) +#else +(const slist_impl<Config> &x, const slist_impl<Config> &y) +#endif +{ + typedef slist_impl<Config> slist_type; + typedef typename slist_type::const_iterator const_iterator; + const bool C = slist_type::constant_time_size; + if(C && x.size() != y.size()){ + return false; + } + const_iterator end1 = x.end(); + + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + if(C){ + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; + } + else{ + const_iterator end2 = y.end(); + while (i1 != end1 && i2 != end2 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1 && i2 == end2; + } +} + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y) +#else +(const slist_impl<Config> &x, const slist_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y) +#else +(const slist_impl<Config> &x, const slist_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y) +#else +(const slist_impl<Config> &x, const slist_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const slist_impl<T, Options...> &x, const slist_impl<T, Options...> &y) +#else +(const slist_impl<Config> &x, const slist_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(slist_impl<T, Options...> &x, slist_impl<T, Options...> &y) +#else +(slist_impl<Config> &x, slist_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c slist that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none, class O3 = none, class O4 = none, class O5 = none> +#endif +struct make_slist +{ + /// @cond + typedef typename pack_options + < slist_defaults<T>, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5 + #else + Options... + #endif + >::type packed_options; + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + typedef slist_impl + < + slistopt + < value_traits + , typename packed_options::size_type + , packed_options::constant_time_size + , packed_options::linear + , packed_options::cache_last + > + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4, class O5> +#else +template<class T, class ...Options> +#endif +class slist + : public make_slist<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5 + #else + Options... + #endif + >::type +{ + typedef typename make_slist + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5 + #else + Options... + #endif + >::type Base; + typedef typename Base::real_value_traits real_value_traits; + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + BOOST_MOVABLE_BUT_NOT_COPYABLE(slist) + + public: + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + slist(const value_traits &v_traits = value_traits()) + : Base(v_traits) + {} + + template<class Iterator> + slist(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) + : Base(b, e, v_traits) + {} + + slist(BOOST_RV_REF(slist) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + slist& operator=(BOOST_RV_REF(slist) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static slist &container_from_end_iterator(iterator end_iterator) + { return static_cast<slist &>(Base::container_from_end_iterator(end_iterator)); } + + static const slist &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const slist &>(Base::container_from_end_iterator(end_iterator)); } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SLIST_HPP diff --git a/src/third_party/boost/boost/intrusive/slist_hook.hpp b/src/third_party/boost/boost/intrusive/slist_hook.hpp new file mode 100644 index 00000000000..1debe66c86d --- /dev/null +++ b/src/third_party/boost/boost/intrusive/slist_hook.hpp @@ -0,0 +1,294 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_SLIST_HOOK_HPP +#define BOOST_INTRUSIVE_SLIST_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/slist_node.hpp> +#include <boost/intrusive/circular_slist_algorithms.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +template<class VoidPointer> +struct get_slist_node_algo +{ + typedef circular_slist_algorithms<slist_node_traits<VoidPointer> > type; +}; + +/// @endcond + +//! Helper metafunction to define a \c slist_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_slist_base_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_slist_node_algo<typename packed_options::void_pointer> + , typename packed_options::tag + , packed_options::link_mode + , detail::SlistBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from slist_base_hook in order to store objects in +//! in an list. slist_base_hook holds the data necessary to maintain the +//! list and provides an appropriate value_traits class for list. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<> and +//! \c link_mode<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its +//! unique tag. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class slist_base_hook + : public make_slist_base_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + slist_base_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + slist_base_hook(const slist_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + slist_base_hook& operator=(const slist_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in an slist an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~slist_base_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(slist_base_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c slist::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +//! Helper metafunction to define a \c slist_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_slist_member_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_slist_node_algo<typename packed_options::void_pointer> + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Put a public data member slist_member_hook in order to store objects of this class in +//! an list. slist_member_hook holds the data necessary for maintaining the list and +//! provides an appropriate value_traits class for list. +//! +//! The hook admits the following options: \c void_pointer<> and +//! \c link_mode<>. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class slist_member_hook + : public make_slist_member_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + slist_member_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + slist_member_hook(const slist_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + slist_member_hook& operator=(const slist_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in an slist an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~slist_member_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(slist_member_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c slist::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SLIST_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/splay_set.hpp b/src/third_party/boost/boost/intrusive/splay_set.hpp new file mode 100644 index 00000000000..5a21a06af81 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/splay_set.hpp @@ -0,0 +1,2403 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_SPLAY_SET_HPP +#define BOOST_INTRUSIVE_SPLAY_SET_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/splaytree.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/move/move.hpp> +#include <iterator> + +namespace boost { +namespace intrusive { + +//! The class template splay_set is an intrusive container, that mimics most of +//! the interface of std::set as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class splay_set_impl +{ + /// @cond + typedef splaytree_impl<Config> tree_type; + //! This class is + //! movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(splay_set_impl) + + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare object throws. + splay_set_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty splay_set and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise amortized N * log N, where N is std::distance(last, first). + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + splay_set_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(true, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + splay_set_impl(BOOST_RV_REF(splay_set_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + splay_set_impl& operator=(BOOST_RV_REF(splay_set_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the splay_set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~splay_set_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of splay_set. + //! + //! <b>Effects</b>: Returns a const reference to the splay_set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static splay_set_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<splay_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &splay_set_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of splay_set. + //! + //! <b>Effects</b>: Returns a const reference to the splay_set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const splay_set_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<splay_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &splay_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of set. + //! + //! <b>Effects</b>: Returns a reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static splay_set_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<splay_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &splay_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of set. + //! + //! <b>Effects</b>: Returns a const reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const splay_set_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<splay_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &splay_set_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the splay_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the splay_set. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two splay_sets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(splay_set_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const splay_set_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to inserts value into the splay_set. + //! + //! <b>Returns</b>: If the value + //! is not already present inserts it and returns a pair containing the + //! iterator to the new value and true. If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert(reference value) + { return tree_.insert_unique(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to to insert x into the splay_set, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the + //! new element was inserted into the splay_set. + //! + //! <b>Complexity</b>: Amortized logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_unique(hint, value); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the splay_set, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the splay_set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(key, key_value_comp, commit_data); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the splay_set, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Amortized logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the splay_set. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { return tree_.insert_unique_check(hint, key, key_value_comp, commit_data); } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the splay_set between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the splay_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_commit(reference value, const insert_commit_data &commit_data) + { return tree_.insert_unique_commit(value, commit_data); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the splay_set. + //! + //! <b>Complexity</b>: Insert range is amortized O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_unique(b, e); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is amortized + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size()) + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If the comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + //! + //! <b>Complexity</b>: Amortized O(log(size() + this->count(value)). Basic guarantee. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) + { return tree_.find(value) != end(); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp) != end(); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count_dont_splay(const_reference value)const + { return tree_.find_dont_splay(value) != end(); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count_dont_splay(const KeyType& key, KeyValueCompare comp)const + { return tree_.find_dont_splay(key, comp) != end(); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound_dont_splay(const_reference value) const + { return tree_.lower_bound_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound_dont_splay(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound_dont_splay(const_reference value) const + { return tree_.upper_bound_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound_dont_splay(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find_dont_splay(const_reference value) const + { return tree_.find_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.find_dont_splay(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range_dont_splay(const_reference value) const + { return tree_.equal_range_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range_dont_splay(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a splay_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the splay_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a splay_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! splay_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a splay_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the splay_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a splay_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! splay_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a splay_set/multisplay_set. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + //! <b>Requires</b>: i must be a valid iterator of *this. + //! + //! <b>Effects</b>: Rearranges the splay set so that the element pointed by i + //! is placed as the root of the tree, improving future searches of this value. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + void splay_up(iterator i) + { tree_.splay_up(i); } + + //! <b>Effects</b>: Rearranges the splay set so that if *this stores an element + //! with a key equivalent to value the element is placed as the root of the + //! tree. If the element is not present returns the last node compared with the key. + //! If the tree is empty, end() is returned. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty. + //! + //! <b>Throws</b>: If the comparison functor throws. + template<class KeyType, class KeyNodePtrCompare> + iterator splay_down(const KeyType &key, KeyNodePtrCompare comp) + { return tree_.splay_down(key, comp); } + + //! <b>Effects</b>: Rearranges the splay set so that if *this stores an element + //! with a key equivalent to value the element is placed as the root of the + //! tree. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty. + //! + //! <b>Throws</b>: If the predicate throws. + iterator splay_down(const value_type &value) + { return tree_.splay_down(value); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { tree_.rebalance(); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return tree_.rebalance_subtree(root); } + + /// @cond + friend bool operator==(const splay_set_impl &x, const splay_set_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const splay_set_impl &x, const splay_set_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_set_impl<T, Options...> &x, const splay_set_impl<T, Options...> &y) +#else +(const splay_set_impl<Config> &x, const splay_set_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_set_impl<T, Options...> &x, const splay_set_impl<T, Options...> &y) +#else +(const splay_set_impl<Config> &x, const splay_set_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_set_impl<T, Options...> &x, const splay_set_impl<T, Options...> &y) +#else +(const splay_set_impl<Config> &x, const splay_set_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_set_impl<T, Options...> &x, const splay_set_impl<T, Options...> &y) +#else +(const splay_set_impl<Config> &x, const splay_set_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(splay_set_impl<T, Options...> &x, splay_set_impl<T, Options...> &y) +#else +(splay_set_impl<Config> &x, splay_set_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c splay_set that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_splay_set +{ + /// @cond + typedef splay_set_impl + < typename make_splaytree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class splay_set + : public make_splay_set<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_splay_set + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(splay_set) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + splay_set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + splay_set( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + splay_set(BOOST_RV_REF(splay_set) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + splay_set& operator=(BOOST_RV_REF(splay_set) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static splay_set &container_from_end_iterator(iterator end_iterator) + { return static_cast<splay_set &>(Base::container_from_end_iterator(end_iterator)); } + + static const splay_set &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const splay_set &>(Base::container_from_end_iterator(end_iterator)); } + + static splay_set &container_from_iterator(iterator it) + { return static_cast<splay_set &>(Base::container_from_iterator(it)); } + + static const splay_set &container_from_iterator(const_iterator it) + { return static_cast<const splay_set &>(Base::container_from_iterator(it)); } +}; + +#endif + +//! The class template splay_multiset is an intrusive container, that mimics most of +//! the interface of std::multiset as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class splay_multiset_impl +{ + /// @cond + typedef splaytree_impl<Config> tree_type; + + //Movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(splay_multiset_impl) + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + splay_multiset_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty splay_multiset and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise amortized N * log N, where N is the distance between first and last. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + splay_multiset_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : tree_(false, b, e, cmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + splay_multiset_impl(BOOST_RV_REF(splay_multiset_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + splay_multiset_impl& operator=(BOOST_RV_REF(splay_multiset_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~splay_multiset_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of splay_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the splay_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static splay_multiset_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<splay_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &splay_multiset_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of splay_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the splay_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const splay_multiset_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<splay_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &splay_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static splay_multiset_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<splay_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &splay_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const splay_multiset_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<splay_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &splay_multiset_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the splay_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the splay_multiset. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two splay_multisets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(splay_multiset_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const splay_multiset_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the splay_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(reference value) + { return tree_.insert_equal(this->end(), value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts x into the splay_multiset, using pos as a hint to + //! where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Amortized logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_equal(hint, value); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the splay_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Insert range is amortized O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_equal(b, e); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is amortized + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is amortized + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) + { return tree_.count(value); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) + { return tree_.count(key, comp); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count_dont_splay(const_reference value) const + { return tree_.count_dont_splay(value); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.count_dont_splay(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound_dont_splay(const_reference value) const + { return tree_.lower_bound_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound_dont_splay(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound_dont_splay(const_reference value) const + { return tree_.upper_bound_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound_dont_splay(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find_dont_splay(const_reference value) const + { return tree_.find_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.find_dont_splay(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range_dont_splay(const_reference value) const + { return tree_.equal_range_dont_splay(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range_dont_splay(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range_dont_splay(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a set/splay_multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + //! <b>Requires</b>: i must be a valid iterator of *this. + //! + //! <b>Effects</b>: Rearranges the splay set so that the element pointed by i + //! is placed as the root of the tree, improving future searches of this value. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + void splay_up(iterator i) + { tree_.splay_up(i); } + + //! <b>Effects</b>: Rearranges the splay set so that if *this stores an element + //! with a key equivalent to value the element is placed as the root of the + //! tree. If the element is not present returns the last node compared with the key. + //! If the tree is empty, end() is returned. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty. + //! + //! <b>Throws</b>: If the comparison functor throws. + template<class KeyType, class KeyNodePtrCompare> + iterator splay_down(const KeyType &key, KeyNodePtrCompare comp) + { return tree_.splay_down(key, comp); } + + //! <b>Effects</b>: Rearranges the splay set so that if *this stores an element + //! with a key equivalent to value the element is placed as the root of the + //! tree. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty. + //! + //! <b>Throws</b>: If the predicate throws. + iterator splay_down(const value_type &value) + { return tree_.splay_down(value); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { tree_.rebalance(); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return tree_.rebalance_subtree(root); } + + /// @cond + friend bool operator==(const splay_multiset_impl &x, const splay_multiset_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const splay_multiset_impl &x, const splay_multiset_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_multiset_impl<T, Options...> &x, const splay_multiset_impl<T, Options...> &y) +#else +(const splay_multiset_impl<Config> &x, const splay_multiset_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_multiset_impl<T, Options...> &x, const splay_multiset_impl<T, Options...> &y) +#else +(const splay_multiset_impl<Config> &x, const splay_multiset_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_multiset_impl<T, Options...> &x, const splay_multiset_impl<T, Options...> &y) +#else +(const splay_multiset_impl<Config> &x, const splay_multiset_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splay_multiset_impl<T, Options...> &x, const splay_multiset_impl<T, Options...> &y) +#else +(const splay_multiset_impl<Config> &x, const splay_multiset_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(splay_multiset_impl<T, Options...> &x, splay_multiset_impl<T, Options...> &y) +#else +(splay_multiset_impl<Config> &x, splay_multiset_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c splay_multiset that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_splay_multiset +{ + /// @cond + typedef splay_multiset_impl + < typename make_splaytree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class splay_multiset + : public make_splay_multiset<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_splay_multiset + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(splay_multiset) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + splay_multiset( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + splay_multiset( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, v_traits) + {} + + splay_multiset(BOOST_RV_REF(splay_multiset) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + splay_multiset& operator=(BOOST_RV_REF(splay_multiset) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static splay_multiset &container_from_end_iterator(iterator end_iterator) + { return static_cast<splay_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static const splay_multiset &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const splay_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static splay_multiset &container_from_iterator(iterator it) + { return static_cast<splay_multiset &>(Base::container_from_iterator(it)); } + + static const splay_multiset &container_from_iterator(const_iterator it) + { return static_cast<const splay_multiset &>(Base::container_from_iterator(it)); } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SPLAY_SET_HPP diff --git a/src/third_party/boost/boost/intrusive/splay_set_hook.hpp b/src/third_party/boost/boost/intrusive/splay_set_hook.hpp new file mode 100644 index 00000000000..d42f4c8beea --- /dev/null +++ b/src/third_party/boost/boost/intrusive/splay_set_hook.hpp @@ -0,0 +1,292 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_SPLAY_SET_HOOK_HPP +#define BOOST_INTRUSIVE_SPLAY_SET_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/tree_node.hpp> +#include <boost/intrusive/splaytree_algorithms.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +template<class VoidPointer> +struct get_splay_set_node_algo +{ + typedef splaytree_algorithms<tree_node_traits<VoidPointer> > type; +}; +/// @endcond + +//! Helper metafunction to define a \c splay_set_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_splay_set_base_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_splay_set_node_algo<typename packed_options::void_pointer> + , typename packed_options::tag + , packed_options::link_mode + , detail::SplaySetBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from splay_set_base_hook in order to store objects in +//! in a splay_set/splay_multiset. splay_set_base_hook holds the data necessary to maintain +//! the splay_set/splay_multiset and provides an appropriate value_traits class for splay_set/splay_multiset. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<>, +//! \c link_mode<> and \c optimize_size<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its +//! unique tag. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class splay_set_base_hook + : public make_splay_set_base_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + splay_set_base_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + splay_set_base_hook(const splay_set_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + splay_set_base_hook& operator=(const splay_set_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~splay_set_base_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(splay_set_base_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +//! Helper metafunction to define a \c splay_set_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none> +#endif +struct make_splay_set_member_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_splay_set_node_algo<typename packed_options::void_pointer> + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Put a public data member splay_set_member_hook in order to store objects of this +//! class in a splay_set/splay_multiset. splay_set_member_hook holds the data +//! necessary for maintaining the splay_set/splay_multiset and provides an appropriate +//! value_traits class for splay_set/splay_multiset. +//! +//! The hook admits the following options: \c void_pointer<>, +//! \c link_mode<> and \c optimize_size<>. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3> +#endif +class splay_set_member_hook + : public make_splay_set_member_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + splay_set_member_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + splay_set_member_hook(const splay_set_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + splay_set_member_hook& operator=(const splay_set_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in a set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~splay_set_member_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(splay_set_member_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SPLAY_SET_HOOK_HPP diff --git a/src/third_party/boost/boost/intrusive/splaytree.hpp b/src/third_party/boost/boost/intrusive/splaytree.hpp new file mode 100644 index 00000000000..01b28d0a778 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/splaytree.hpp @@ -0,0 +1,1686 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_SPLAYTREE_HPP +#define BOOST_INTRUSIVE_SPLAYTREE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <functional> +#include <iterator> +#include <utility> +#include <cstddef> +#include <algorithm> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/static_assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/splay_set_hook.hpp> +#include <boost/intrusive/detail/tree_node.hpp> +#include <boost/intrusive/detail/ebo_functor_holder.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/splaytree_algorithms.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/move/move.hpp> + + +namespace boost { +namespace intrusive { + +/// @cond + +template <class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize> +struct splaysetopt +{ + typedef ValueTraits value_traits; + typedef Compare compare; + typedef SizeType size_type; + static const bool constant_time_size = ConstantTimeSize; +}; + +template <class T> +struct splay_set_defaults + : pack_options + < none + , base_hook<detail::default_splay_set_hook> + , constant_time_size<true> + , size_type<std::size_t> + , compare<std::less<T> > + >::type +{}; + +/// @endcond + +//! The class template splaytree is an intrusive splay tree container that +//! is used to construct intrusive splay_set and splay_multiset containers. The no-throw +//! guarantee holds only, if the value_compare object +//! doesn't throw. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<> and +//! \c compare<>. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class splaytree_impl + : private detail::clear_on_destructor_base<splaytree_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + public: + typedef typename Config::value_traits value_traits; + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + /// @endcond + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + typedef typename pointer_traits<pointer>::element_type value_type; + typedef typename pointer_traits<pointer>::reference reference; + typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef typename pointer_traits<pointer>::difference_type difference_type; + typedef typename Config::size_type size_type; + typedef value_type key_type; + typedef typename Config::compare value_compare; + typedef value_compare key_compare; + typedef tree_iterator<splaytree_impl, false> iterator; + typedef tree_iterator<splaytree_impl, true> const_iterator; + typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator; + typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <node>::type node_ptr; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <const node>::type const_node_ptr; + typedef splaytree_algorithms<node_traits> node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + + /// @cond + private: + typedef detail::size_holder<constant_time_size, size_type> size_traits; + + //noncopyable + BOOST_MOVABLE_BUT_NOT_COPYABLE(splaytree_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + //Constant-time size is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink))); + + struct header_plus_size : public size_traits + { node header_; }; + + struct node_plus_pred_t : public detail::ebo_functor_holder<value_compare> + { + node_plus_pred_t(const value_compare &comp) + : detail::ebo_functor_holder<value_compare>(comp) + {} + header_plus_size header_plus_size_; + }; + + struct data_t : public splaytree_impl::value_traits + { + typedef typename splaytree_impl::value_traits value_traits; + data_t(const value_compare & comp, const value_traits &val_traits) + : value_traits(val_traits), node_plus_pred_(comp) + {} + node_plus_pred_t node_plus_pred_; + } data_; + + const value_compare &priv_comp() const + { return data_.node_plus_pred_.get(); } + + value_compare &priv_comp() + { return data_.node_plus_pred_.get(); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + node_ptr priv_header_ptr() + { return pointer_traits<node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); } + + const_node_ptr priv_header_ptr() const + { return pointer_traits<const_node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); } + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + size_traits &priv_size_traits() + { return data_.node_plus_pred_.header_plus_size_; } + + const size_traits &priv_size_traits() const + { return data_.node_plus_pred_.header_plus_size_; } + + const real_value_traits &get_real_value_traits(detail::bool_<false>) const + { return data_; } + + const real_value_traits &get_real_value_traits(detail::bool_<true>) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::bool_<false>) + { return data_; } + + real_value_traits &get_real_value_traits(detail::bool_<true>) + { return data_.get_value_traits(*this); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + typedef typename node_algorithms::insert_commit_data insert_commit_data; + + //! <b>Effects</b>: Constructs an empty tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructorof the value_compare object throws. Basic guarantee. + splaytree_impl( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty tree and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise amortized N * log N, where N is the distance between first and last. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. Basic guarantee. + template<class Iterator> + splaytree_impl ( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + if(unique) + this->insert_unique(b, e); + else + this->insert_equal(b, e); + } + + //! <b>Effects</b>: to-do + //! + splaytree_impl(BOOST_RV_REF(splaytree_impl) x) + : data_(::boost::move(x.priv_comp()), ::boost::move(x.priv_value_traits())) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + this->swap(x); + } + + //! <b>Effects</b>: to-do + //! + splaytree_impl& operator=(BOOST_RV_REF(splaytree_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called), but the nodes according to + //! the value_traits template parameter are reinitialized and thus can be reused. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~splaytree_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return iterator(node_algorithms::begin_node(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return cbegin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return const_iterator(node_algorithms::begin_node(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return iterator (this->priv_header_ptr(), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return cend(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return const_iterator (uncast(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return const_reverse_iterator(end()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return const_reverse_iterator(begin()); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of splaytree. + //! + //! <b>Effects</b>: Returns a const reference to the splaytree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static splaytree_impl &container_from_end_iterator(iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of splaytree. + //! + //! <b>Effects</b>: Returns a const reference to the splaytree associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const splaytree_impl &container_from_end_iterator(const_iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: it must be a valid iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static splaytree_impl &container_from_iterator(iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Precondition</b>: it must be a valid end const_iterator + //! of rbtree. + //! + //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const splaytree_impl &container_from_iterator(const_iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Effects</b>: Returns the value_compare object used by the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return priv_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return this->cbegin() == this->cend(); } + + //! <b>Effects</b>: Returns the number of elements stored in the tree. + //! + //! <b>Complexity</b>: Linear to elements contained in *this + //! if constant-time size option is disabled. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { + if(constant_time_size){ + return this->priv_size_traits().get_size(); + } + else{ + return (size_type)node_algorithms::size(this->priv_header_ptr()); + } + } + + //! <b>Effects</b>: Swaps the contents of two splaytrees. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the comparison functor's swap call throws. + void swap(splaytree_impl& other) + { + //This can throw + using std::swap; + swap(priv_comp(), priv_comp()); + //These can't throw + node_algorithms::swap_tree(this->priv_header_ptr(), other.priv_header_ptr()); + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree before the lower bound. + //! + //! <b>Complexity</b>: Average complexity for insert element is amortized + //! logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(reference value) + { + detail::key_nodeptr_comp<value_compare, splaytree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret (node_algorithms::insert_equal_lower_bound + (this->priv_header_ptr(), to_insert, key_node_comp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator. + //! + //! <b>Effects</b>: Inserts x into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case) + //! + //! <b>Complexity</b>: Amortized logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(const_iterator hint, reference value) + { + detail::key_nodeptr_comp<value_compare, splaytree_impl> + key_node_comp(priv_comp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret(node_algorithms::insert_equal + (this->priv_header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a each element of a range into the tree + //! before the upper bound of the key of each element. + //! + //! <b>Complexity</b>: Insert range is in general amortized O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_equal(Iterator b, Iterator e) + { + if(this->empty()){ + iterator end(this->end()); + for (; b != e; ++b) + this->insert_equal(end, *b); + } + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the tree if the value + //! is not already present. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert_unique(reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(value, priv_comp(), commit_data); + if(!ret.second) + return ret; + return std::pair<iterator, bool> (insert_unique_commit(value, commit_data), true); + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator + //! + //! <b>Effects</b>: Tries to insert x into the tree, using "hint" as a hint + //! to where it will be inserted. + //! + //! <b>Complexity</b>: Amortized logarithmic in general, but it is amortized + //! constant time (two comparisons in the worst case) + //! if t is inserted immediately before hint. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_unique(const_iterator hint, reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(hint, value, priv_comp(), commit_data); + if(!ret.second) + return ret.first; + return insert_unique_commit(value, commit_data); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Tries to insert each element of a range into the tree. + //! + //! <b>Complexity</b>: Insert range is in general amortized O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_unique(Iterator b, Iterator e) + { + for (; b != e; ++b) + this->insert_unique(*b); + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), key, comp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. The difference is that + //! key_value_comp compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare> + std::pair<iterator, bool> insert_unique_check + (const_iterator hint, const KeyType &key + ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + comp(key_value_comp, this); + std::pair<node_ptr, bool> ret = + node_algorithms::insert_unique_check + (this->priv_header_ptr(), hint.pointed_node(), key, comp, commit_data); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the container between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + node_algorithms::insert_unique_commit + (this->priv_header_ptr(), to_insert, commit_data); + this->priv_size_traits().increment(); + return iterator(to_insert, this); + } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { + const_iterator ret(i); + ++ret; + node_ptr to_erase(i.pointed_node()); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); + node_algorithms::erase(this->priv_header_ptr(), to_erase); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + return ret.unconst(); + } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is amortized + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { size_type n; return private_erase(b, e, n); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return this->erase(value, priv_comp()); } + + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { + node_ptr to_erase(i.pointed_node()); + iterator ret(this->erase(i)); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + return ret; + } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is amortized + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { size_type n; return private_erase(b, e, n, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { + std::pair<iterator,iterator> p = this->equal_range(value); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Amortized O(log(size() + N). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { + if(safemode_or_autounlink){ + this->clear_and_dispose(detail::null_disposer()); + } + else{ + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + } + + //! <b>Effects</b>: Erases all of the elements calling disposer(p) for + //! each node to be erased. + //! <b>Complexity</b>: Amortized O(log(size() + N)), + //! where N is the number of elements in the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. Calls N times to disposer functor. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { + node_algorithms::clear_and_dispose(this->priv_header_ptr() + , detail::node_disposer<Disposer, splaytree_impl>(disposer, this)); + this->priv_size_traits().set_size(0); + } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given value. + //! + //! <b>Throws</b>: Nothing. + size_type count(const_reference value) + { return this->count(value, priv_comp()); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType &key, KeyValueCompare comp) + { + std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp); + return std::distance(ret.first, ret.second); + } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given value. + //! + //! <b>Throws</b>: Nothing. + size_type count_dont_splay(const_reference value) const + { return this->count_dont_splay(value, priv_comp()); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Amortized logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + size_type count_dont_splay(const KeyType &key, KeyValueCompare comp) const + { + std::pair<const_iterator, const_iterator> ret = this->equal_range_dont_splay(key, comp); + return std::distance(ret.first, ret.second); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator lower_bound(const_reference value) + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator lower_bound_dont_splay(const_reference value) const + { return this->lower_bound_dont_splay(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound_dont_splay(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp, false), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator upper_bound(const_reference value) + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator upper_bound_dont_splay(const_reference value) const + { return this->upper_bound_dont_splay(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound_dont_splay(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::upper_bound_dont_splay + (this->priv_header_ptr(), key, key_node_comp, false), this); + } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator find(const_reference value) + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + return iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator find_dont_splay(const_reference value) const + { return this->find_dont_splay(value, priv_comp()); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator find_dont_splay(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + return const_iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp, false), this); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<iterator,iterator> equal_range(const_reference value) + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<iterator, iterator>(iterator(ret.first, this), iterator(ret.second, this)); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<const_iterator, const_iterator> + equal_range_dont_splay(const_reference value) const + { return this->equal_range_dont_splay(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range_dont_splay(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp, false)); + return std::pair<const_iterator, const_iterator>(const_iterator(ret.first, this), const_iterator(ret.second, this)); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const splaytree_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + if(!src.empty()){ + detail::exception_disposer<splaytree_impl, Disposer> + rollback(*this, disposer); + node_algorithms::clone + (src.priv_header_ptr() + ,this->priv_header_ptr() + ,detail::node_cloner<Cloner, splaytree_impl>(cloner, this) + ,detail::node_disposer<Disposer, splaytree_impl>(disposer, this)); + this->priv_size_traits().set_size(src.priv_size_traits().get_size()); + this->priv_comp() = src.priv_comp(); + rollback.release(); + } + } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { + node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance + (this->priv_header_ptr())); + if(!to_be_disposed) + return 0; + this->priv_size_traits().decrement(); + if(safemode_or_autounlink)//If this is commented does not work with normal_link + node_algorithms::init(to_be_disposed); + return get_real_value_traits().to_value_ptr(to_be_disposed); + } + + //! <b>Requires</b>: i must be a valid iterator of *this. + //! + //! <b>Effects</b>: Rearranges the splay set so that the element pointed by i + //! is placed as the root of the tree, improving future searches of this value. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Throws</b>: Nothing. + void splay_up(iterator i) + { return node_algorithms::splay_up(i.pointed_node(), this->priv_header_ptr()); } + + //! <b>Effects</b>: Rearranges the splay set so that if *this stores an element + //! with a key equivalent to value the element is placed as the root of the + //! tree. If the element is not present returns the last node compared with the key. + //! If the tree is empty, end() is returned. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty. + //! + //! <b>Throws</b>: If the comparison functor throws. + template<class KeyType, class KeyValueCompare> + iterator splay_down(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, splaytree_impl> + key_node_comp(comp, this); + node_ptr r = node_algorithms::splay_down(this->priv_header_ptr(), key, key_node_comp); + return iterator(r, this); + } + + //! <b>Effects</b>: Rearranges the splay set so that if *this stores an element + //! with a key equivalent to value the element is placed as the root of the + //! tree. + //! + //! <b>Complexity</b>: Amortized logarithmic. + //! + //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty. + //! + //! <b>Throws</b>: If the predicate throws. + iterator splay_down(const value_type &value) + { return this->splay_down(value, priv_comp()); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { + node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this) + , this->priv_header_ptr() + , get_real_value_traits().to_node_ptr(with_this)); + if(safemode_or_autounlink) + node_algorithms::init(replace_this.pointed_node()); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return iterator (value_traits::to_node_ptr(value), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return iterator (value_traits::to_node_ptr(value), this); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this); } + + //! <b>Requires</b>: value shall not be in a tree. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { node_algorithms::init(value_traits::to_node_ptr(value)); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { node_algorithms::rebalance(this->priv_header_ptr()); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return iterator(node_algorithms::rebalance_subtree(root.pointed_node()), this); } + +/* + //! <b>Effects</b>: removes x from a tree of the appropriate type. It has no effect, + //! if x is not in such a tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This static function is only usable with the "safe mode" + //! hook and non-constant time size lists. Otherwise, the user must use + //! the non-static "erase(reference )" member. If the user calls + //! this function with a non "safe mode" or constant time size list + //! a compilation error will be issued. + template<class T> + static void remove_node(T& value) + { + //This function is only usable for safe mode hooks and non-constant + //time lists. + //BOOST_STATIC_ASSERT((!(safemode_or_autounlink && constant_time_size))); + BOOST_STATIC_ASSERT((!constant_time_size)); + BOOST_STATIC_ASSERT((boost::is_convertible<T, value_type>::value)); + node_ptr to_remove(value_traits::to_node_ptr(value)); + node_algorithms::unlink_and_rebalance(to_remove); + if(safemode_or_autounlink) + node_algorithms::init(to_remove); + } +*/ + + /// @cond + private: + template<class Disposer> + iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer) + { + for(n = 0; b != e; ++n) + this->erase_and_dispose(b++, disposer); + return b.unconst(); + } + + iterator private_erase(const_iterator b, const_iterator e, size_type &n) + { + for(n = 0; b != e; ++n) + this->erase(b++); + return b.unconst(); + } + /// @endcond + + private: + static splaytree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) + { + header_plus_size *r = detail::parent_from_member<header_plus_size, node> + ( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), &header_plus_size::header_); + node_plus_pred_t *n = detail::parent_from_member + <node_plus_pred_t, header_plus_size>(r, &node_plus_pred_t::header_plus_size_); + data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(n, &data_t::node_plus_pred_); + splaytree_impl *rb = detail::parent_from_member<splaytree_impl, data_t>(d, &splaytree_impl::data_); + return *rb; + } + + static splaytree_impl &priv_container_from_iterator(const const_iterator &it) + { return priv_container_from_end_iterator(it.end_iterator_from_it()); } +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator< +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y) +#else +(const splaytree_impl<Config> &x, const splaytree_impl<Config> &y) +#endif +{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +bool operator== +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y) +#else +(const splaytree_impl<Config> &x, const splaytree_impl<Config> &y) +#endif +{ + typedef splaytree_impl<Config> tree_type; + typedef typename tree_type::const_iterator const_iterator; + + if(tree_type::constant_time_size && x.size() != y.size()){ + return false; + } + const_iterator end1 = x.end(); + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + if(tree_type::constant_time_size){ + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; + } + else{ + const_iterator end2 = y.end(); + while (i1 != end1 && i2 != end2 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1 && i2 == end2; + } +} + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y) +#else +(const splaytree_impl<Config> &x, const splaytree_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y) +#else +(const splaytree_impl<Config> &x, const splaytree_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y) +#else +(const splaytree_impl<Config> &x, const splaytree_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y) +#else +(const splaytree_impl<Config> &x, const splaytree_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(splaytree_impl<T, Options...> &x, splaytree_impl<T, Options...> &y) +#else +(splaytree_impl<Config> &x, splaytree_impl<Config> &y) +#endif +{ x.swap(y); } + +/// @cond + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#else +template<class T, class ...Options> +#endif +struct make_splaytree_opt +{ + typedef typename pack_options + < splay_set_defaults<T>, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + + typedef splaysetopt + < value_traits + , typename packed_options::compare + , typename packed_options::size_type + , packed_options::constant_time_size + > type; +}; +/// @endcond + +//! Helper metafunction to define a \c splaytree that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_splaytree +{ + /// @cond + typedef splaytree_impl + < typename make_splaytree_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class splaytree + : public make_splaytree<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_splaytree + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(splaytree) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::real_value_traits real_value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + + splaytree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, v_traits) + {} + + template<class Iterator> + splaytree( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) + : Base(unique, b, e, cmp, v_traits) + {} + + splaytree(BOOST_RV_REF(splaytree) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + splaytree& operator=(BOOST_RV_REF(splaytree) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static splaytree &container_from_end_iterator(iterator end_iterator) + { return static_cast<splaytree &>(Base::container_from_end_iterator(end_iterator)); } + + static const splaytree &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const splaytree &>(Base::container_from_end_iterator(end_iterator)); } +}; + +#endif + + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SPLAYTREE_HPP diff --git a/src/third_party/boost/boost/intrusive/splaytree_algorithms.hpp b/src/third_party/boost/boost/intrusive/splaytree_algorithms.hpp new file mode 100644 index 00000000000..0c699030eaf --- /dev/null +++ b/src/third_party/boost/boost/intrusive/splaytree_algorithms.hpp @@ -0,0 +1,973 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007. +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +// The implementation of splay trees is based on the article and code published +// in C++ Users Journal "Implementing Splay Trees in C++" (September 1, 2005). +// +// The code has been modified and (supposely) improved by Ion Gaztanaga. +// Here is the header of the file used as base code: +// +// splay_tree.h -- implementation of a STL complatible splay tree. +// +// Copyright (c) 2004 Ralf Mattethat +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// Please send questions, comments, complaints, performance data, etc to +// ralf.mattethat@teknologisk.dk +// +// Requirements for element type +// * must be copy-constructible +// * destructor must not throw exception +// +// Methods marked with note A only throws an exception if the evaluation of the +// predicate throws an exception. If an exception is thrown the call has no +// effect on the containers state +// +// Methods marked with note B only throws an exception if the coppy constructor +// or assignment operator of the predicate throws an exception. If an exception +// is thrown the call has no effect on the containers state +// +// iterators are only invalidated, if the element pointed to by the iterator +// is deleted. The same goes for element references +// + +#ifndef BOOST_INTRUSIVE_SPLAYTREE_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_SPLAYTREE_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <cstddef> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/tree_algorithms.hpp> + +namespace boost { +namespace intrusive { + +/// @cond +namespace detail { + +template<class NodeTraits> +struct splaydown_rollback +{ + typedef typename NodeTraits::node_ptr node_ptr; + splaydown_rollback( const node_ptr *pcur_subtree, const node_ptr & header + , const node_ptr & leftmost , const node_ptr & rightmost) + : pcur_subtree_(pcur_subtree) , header_(header) + , leftmost_(leftmost) , rightmost_(rightmost) + {} + + void release() + { pcur_subtree_ = 0; } + + ~splaydown_rollback() + { + if(pcur_subtree_){ + //Exception can only be thrown by comp, but + //tree invariants still hold. *pcur_subtree is the current root + //so link it to the header. + NodeTraits::set_parent(*pcur_subtree_, header_); + NodeTraits::set_parent(header_, *pcur_subtree_); + //Recover leftmost/rightmost pointers + NodeTraits::set_left (header_, leftmost_); + NodeTraits::set_right(header_, rightmost_); + } + } + const node_ptr *pcur_subtree_; + node_ptr header_, leftmost_, rightmost_; +}; + +} //namespace detail { +/// @endcond + +//! A splay tree is an implementation of a binary search tree. The tree is +//! self balancing using the splay algorithm as described in +//! +//! "Self-Adjusting Binary Search Trees +//! by Daniel Dominic Sleator and Robert Endre Tarjan +//! AT&T Bell Laboratories, Murray Hill, NJ +//! Journal of the ACM, Vol 32, no 3, July 1985, pp 652-686 + +//! splaytree_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_parent(const_node_ptr n);</tt> +//! +//! <tt>static void set_parent(node_ptr n, node_ptr parent);</tt> +//! +//! <tt>static node_ptr get_left(const_node_ptr n);</tt> +//! +//! <tt>static void set_left(node_ptr n, node_ptr left);</tt> +//! +//! <tt>static node_ptr get_right(const_node_ptr n);</tt> +//! +//! <tt>static void set_right(node_ptr n, node_ptr right);</tt> +template<class NodeTraits> +class splaytree_algorithms +{ + /// @cond + private: + typedef detail::tree_algorithms<NodeTraits> tree_algorithms; + /// @endcond + + public: + typedef typename NodeTraits::node node; + typedef NodeTraits node_traits; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + + //! This type is the information that will be + //! filled by insert_unique_check + typedef typename tree_algorithms::insert_commit_data insert_commit_data; + + /// @cond + private: + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + /// @endcond + + public: + static node_ptr begin_node(const const_node_ptr & header) + { return tree_algorithms::begin_node(header); } + + static node_ptr end_node(const const_node_ptr & header) + { return tree_algorithms::end_node(header); } + + //! <b>Requires</b>: node is a node of the tree or an node initialized + //! by init(...). + //! + //! <b>Effects</b>: Returns true if the node is initialized by init(). + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + static bool unique(const const_node_ptr & node) + { return tree_algorithms::unique(node); } + + static void unlink(const node_ptr & node) + { tree_algorithms::unlink(node); } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & node2) + { + if(node1 == node2) + return; + + node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2)); + swap_nodes(node1, header1, node2, header2); + } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees with header header1 and header2. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) + { tree_algorithms::swap_nodes(node1, header1, node2, header2); } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing and comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) + { + if(node_to_be_replaced == new_node) + return; + replace_node(node_to_be_replaced, tree_algorithms::get_header(node_to_be_replaced), new_node); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! with header "header" and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) + { tree_algorithms::replace_node(node_to_be_replaced, header, new_node); } + + //! <b>Requires</b>: p is a node from the tree except the header. + //! + //! <b>Effects</b>: Returns the next node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr next_node(const node_ptr & p) + { return tree_algorithms::next_node(p); } + + //! <b>Requires</b>: p is a node from the tree except the leftmost node. + //! + //! <b>Effects</b>: Returns the previous node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr prev_node(const node_ptr & p) + { return tree_algorithms::prev_node(p); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: After the function unique(node) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init(const node_ptr & node) + { tree_algorithms::init(node); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: Initializes the header to represent an empty tree. + //! unique(header) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init_header(const node_ptr & header) + { tree_algorithms::init_header(header); } + + //! <b>Requires</b>: "disposer" must be an object function + //! taking a node_ptr parameter and shouldn't throw. + //! + //! <b>Effects</b>: Empties the target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template<class Disposer> + static void clear_and_dispose(const node_ptr & header, Disposer disposer) + { tree_algorithms::clear_and_dispose(header, disposer); } + + //! <b>Requires</b>: node is a node of the tree but it's not the header. + //! + //! <b>Effects</b>: Returns the number of nodes of the subtree. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & node) + { return tree_algorithms::count(node); } + + //! <b>Requires</b>: header is the header node of the tree. + //! + //! <b>Effects</b>: Returns the number of nodes above the header. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t size(const const_node_ptr & header) + { return tree_algorithms::size(header); } + + //! <b>Requires</b>: header1 and header2 must be the header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two trees. After the function header1 will contain + //! links to the second tree and header2 will have links to the first tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static void swap_tree(const node_ptr & header1, const node_ptr & header2) + { return tree_algorithms::swap_tree(header1, header2); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "commit_data" must have been obtained from a previous call to + //! "insert_unique_check". No objects should have been inserted or erased + //! from the set between the "insert_unique_check" that filled "commit_data" + //! and the call to "insert_commit". + //! + //! + //! <b>Effects</b>: Inserts new_node in the set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_unique_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + static void insert_unique_commit + (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data) + { tree_algorithms::insert_unique_commit(header, new_value, commit_data); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const node_ptr & header, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { + splay_down(header, key, comp); + return tree_algorithms::insert_unique_check(header, key, comp, commit_data); + } + + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const node_ptr & header, const node_ptr &hint, const KeyType &key + ,KeyNodePtrCompare comp, insert_commit_data &commit_data) + { + splay_down(header, key, comp); + return tree_algorithms::insert_unique_check(header, hint, key, comp, commit_data); + } + + static bool is_header(const const_node_ptr & p) + { return tree_algorithms::is_header(p); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the element that is equivalent to + //! "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr find + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp, bool splay = true) + { + if(splay) + splay_down(uncast(header), key, comp); + node_ptr end = uncast(header); + node_ptr y = lower_bound(header, key, comp, false); + node_ptr r = (y == end || comp(key, y)) ? end : y; + return r; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an a pair of node_ptr delimiting a range containing + //! all elements that are equivalent to "key" according to "comp" or an + //! empty range that indicates the position where those elements would be + //! if they there are no equivalent elements. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, node_ptr> equal_range + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp, bool splay = true) + { + //if(splay) + //splay_down(uncast(header), key, comp); + std::pair<node_ptr, node_ptr> ret = + tree_algorithms::equal_range(header, key, comp); + + if(splay) + splay_up(ret.first, uncast(header)); + return ret; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is + //! not less than "key" according to "comp" or "header" if that element does + //! not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr lower_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp, bool splay = true) + { + //if(splay) + //splay_down(uncast(header), key, comp); + node_ptr y = tree_algorithms::lower_bound(header, key, comp); + if(splay) + splay_up(y, uncast(header)); + return y; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is greater + //! than "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr upper_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp, bool splay = true) + { + //if(splay) + //splay_down(uncast(header), key, comp); + node_ptr y = tree_algorithms::upper_bound(header, key, comp); + if(splay) + splay_up(y, uncast(header)); + return y; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. "hint" is node from + //! the "header"'s tree. + //! + //! <b>Effects</b>: Inserts new_node into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case). + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if new_node is inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal + (const node_ptr & header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp) + { + splay_down(header, new_node, comp); + return tree_algorithms::insert_equal(header, hint, new_node, comp); + } + + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "pos" must be a valid iterator or header (end) node. + //! "pos" must be an iterator pointing to the successor to "new_node" + //! once inserted according to the order of already inserted nodes. This function does not + //! check "pos" and this precondition must be guaranteed by the caller. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "pos" is not the successor of the newly inserted "new_node" + //! tree invariants might be broken. + static node_ptr insert_before + (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node) + { + tree_algorithms::insert_before(header, pos, new_node); + splay_up(new_node, header); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering no less than the + //! greatest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is less than the greatest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + static void push_back(const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::push_back(header, new_node); + splay_up(new_node, header); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering, no greater than the + //! lowest inserted key. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: If "new_node" is greater than the lowest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + static void push_front(const node_ptr & header, const node_ptr & new_node) + { + tree_algorithms::push_front(header, new_node); + splay_up(new_node, header); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the upper bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal_upper_bound + (const node_ptr & header, const node_ptr & new_node, NodePtrCompare comp) + { + splay_down(header, new_node, comp); + return tree_algorithms::insert_equal_upper_bound(header, new_node, comp); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the lower bound + //! according to "comp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare> + static node_ptr insert_equal_lower_bound + (const node_ptr & header, const node_ptr & new_node, NodePtrCompare comp) + { + splay_down(header, new_node, comp); + return tree_algorithms::insert_equal_lower_bound(header, new_node, comp); + } + + //! <b>Requires</b>: "cloner" must be a function + //! object taking a node_ptr and returning a new cloned node of it. "disposer" must + //! take a node_ptr and shouldn't throw. + //! + //! <b>Effects</b>: First empties target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! Then, duplicates the entire tree pointed by "source_header" cloning each + //! source node with <tt>node_ptr Cloner::operator()(const node_ptr &)</tt> to obtain + //! the nodes of the target tree. If "cloner" throws, the cloned target nodes + //! are disposed using <tt>void disposer(const node_ptr &)</tt>. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template <class Cloner, class Disposer> + static void clone + (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) + { tree_algorithms::clone(source_header, target_header, cloner, disposer); } + + // delete node | complexity : constant | exception : nothrow + static void erase(const node_ptr & header, const node_ptr & z, bool splay = true) + { +// node_base* n = t->right; +// if( t->left != node_ptr() ){ +// node_base* l = t->previous(); +// splay_up( l , t ); +// n = t->left; +// n->right = t->right; +// if( n->right != node_ptr() ) +// n->right->parent = n; +// } +// +// if( n != node_ptr() ) +// n->parent = t->parent; +// +// if( t->parent->left == t ) +// t->parent->left = n; +// else // must be ( t->parent->right == t ) +// t->parent->right = n; +// +// if( data_->parent == t ) +// data_->parent = find_leftmost(); + //posibility 1 + if(splay && NodeTraits::get_left(z)){ + splay_up(prev_node(z), header); + } + /* + //possibility 2 + if(splay && NodeTraits::get_left(z) != node_ptr() ){ + node_ptr l = NodeTraits::get_left(z); + splay_up(l, header); + }*//* + if(splay && NodeTraits::get_left(z) != node_ptr() ){ + node_ptr l = prev_node(z); + splay_up_impl(l, z); + }*/ + /* + //possibility 4 + if(splay){ + splay_up(z, header); + }*/ + + //if(splay) + //splay_up(z, header); + tree_algorithms::erase(header, z); + } + + // bottom-up splay, use data_ as parent for n | complexity : logarithmic | exception : nothrow + static void splay_up(const node_ptr & node, const node_ptr & header) + { + // If (node == header) do a splay for the right most node instead + // this is to boost performance of equal_range/count on equivalent containers in the case + // where there are many equal elements at the end + node_ptr n((node == header) ? NodeTraits::get_right(header) : node); + node_ptr t(header); + + if( n == t ) return; + + for( ;; ){ + node_ptr p(NodeTraits::get_parent(n)); + node_ptr g(NodeTraits::get_parent(p)); + + if( p == t ) break; + + if( g == t ){ + // zig + rotate(n); + } + else if ((NodeTraits::get_left(p) == n && NodeTraits::get_left(g) == p) || + (NodeTraits::get_right(p) == n && NodeTraits::get_right(g) == p) ){ + // zig-zig + rotate(p); + rotate(n); + } + else{ + // zig-zag + rotate(n); + rotate(n); + } + } + } + + // top-down splay | complexity : logarithmic | exception : strong, note A + template<class KeyType, class KeyNodePtrCompare> + static node_ptr splay_down(const node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { + if(!NodeTraits::get_parent(header)) + return header; + //Most splay tree implementations use a dummy/null node to implement. + //this function. This has some problems for a generic library like Intrusive: + // + // * The node might not have a default constructor. + // * The default constructor could throw. + // + //We already have a header node. Leftmost and rightmost nodes of the tree + //are not changed when splaying (because the invariants of the tree don't + //change) We can back up them, use the header as the null node and + //reassign old values after the function has been completed. + node_ptr t = NodeTraits::get_parent(header); + //Check if tree has a single node + if(!NodeTraits::get_left(t) && !NodeTraits::get_right(t)) + return t; + //Backup leftmost/rightmost + node_ptr leftmost (NodeTraits::get_left(header)); + node_ptr rightmost(NodeTraits::get_right(header)); + { + detail::splaydown_rollback<NodeTraits> rollback(&t, header, leftmost, rightmost); + node_ptr null = header; + node_ptr l = null; + node_ptr r = null; + + for( ;; ){ + if(comp(key, t)){ + if(NodeTraits::get_left(t) == node_ptr() ) + break; + if(comp(key, NodeTraits::get_left(t))){ + t = tree_algorithms::rotate_right(t); + + if(NodeTraits::get_left(t) == node_ptr()) + break; + link_right(t, r); + } + else if(comp(NodeTraits::get_left(t), key)){ + link_right(t, r); + + if(NodeTraits::get_right(t) == node_ptr() ) + break; + link_left(t, l); + } + else{ + link_right(t, r); + } + } + else if(comp(t, key)){ + if(NodeTraits::get_right(t) == node_ptr() ) + break; + + if(comp(NodeTraits::get_right(t), key)){ + t = tree_algorithms::rotate_left( t ); + + if(NodeTraits::get_right(t) == node_ptr() ) + break; + link_left(t, l); + } + else if(comp(key, NodeTraits::get_right(t))){ + link_left(t, l); + + if(NodeTraits::get_left(t) == node_ptr()) + break; + + link_right(t, r); + } + else{ + link_left(t, l); + } + } + else{ + break; + } + } + + assemble(t, l, r, null); + rollback.release(); + } + + //t is the current root + NodeTraits::set_parent(header, t); + NodeTraits::set_parent(t, header); + //Recover leftmost/rightmost pointers + NodeTraits::set_left (header, leftmost); + NodeTraits::set_right(header, rightmost); + return t; + } + + //! <b>Requires</b>: header must be the header of a tree. + //! + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + static void rebalance(const node_ptr & header) + { tree_algorithms::rebalance(header); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + static node_ptr rebalance_subtree(const node_ptr & old_root) + { return tree_algorithms::rebalance_subtree(old_root); } + + + //! <b>Requires</b>: "n" must be a node inserted in a tree. + //! + //! <b>Effects</b>: Returns a pointer to the header node of the tree. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_header(const node_ptr & n) + { return tree_algorithms::get_header(n); } + + private: + + /// @cond + + // assemble the three sub-trees into new tree pointed to by t | complexity : constant | exception : nothrow + static void assemble(const node_ptr &t, const node_ptr & l, const node_ptr & r, const const_node_ptr & null_node ) + { + NodeTraits::set_right(l, NodeTraits::get_left(t)); + NodeTraits::set_left(r, NodeTraits::get_right(t)); + + if(NodeTraits::get_right(l) != node_ptr()){ + NodeTraits::set_parent(NodeTraits::get_right(l), l); + } + + if(NodeTraits::get_left(r) != node_ptr()){ + NodeTraits::set_parent(NodeTraits::get_left(r), r); + } + + NodeTraits::set_left (t, NodeTraits::get_right(null_node)); + NodeTraits::set_right(t, NodeTraits::get_left(null_node)); + + if( NodeTraits::get_left(t) != node_ptr() ){ + NodeTraits::set_parent(NodeTraits::get_left(t), t); + } + + if( NodeTraits::get_right(t) ){ + NodeTraits::set_parent(NodeTraits::get_right(t), t); + } + } + + // break link to left child node and attach it to left tree pointed to by l | complexity : constant | exception : nothrow + static void link_left(node_ptr & t, node_ptr & l) + { + NodeTraits::set_right(l, t); + NodeTraits::set_parent(t, l); + l = t; + t = NodeTraits::get_right(t); + } + + // break link to right child node and attach it to right tree pointed to by r | complexity : constant | exception : nothrow + static void link_right(node_ptr & t, node_ptr & r) + { + NodeTraits::set_left(r, t); + NodeTraits::set_parent(t, r); + r = t; + t = NodeTraits::get_left(t); + } + + // rotate n with its parent | complexity : constant | exception : nothrow + static void rotate(const node_ptr & n) + { + node_ptr p = NodeTraits::get_parent(n); + node_ptr g = NodeTraits::get_parent(p); + //Test if g is header before breaking tree + //invariants that would make is_header invalid + bool g_is_header = is_header(g); + + if(NodeTraits::get_left(p) == n){ + NodeTraits::set_left(p, NodeTraits::get_right(n)); + if(NodeTraits::get_left(p) != node_ptr()) + NodeTraits::set_parent(NodeTraits::get_left(p), p); + NodeTraits::set_right(n, p); + } + else{ // must be ( p->right == n ) + NodeTraits::set_right(p, NodeTraits::get_left(n)); + if(NodeTraits::get_right(p) != node_ptr()) + NodeTraits::set_parent(NodeTraits::get_right(p), p); + NodeTraits::set_left(n, p); + } + + NodeTraits::set_parent(p, n); + NodeTraits::set_parent(n, g); + + if(g_is_header){ + if(NodeTraits::get_parent(g) == p) + NodeTraits::set_parent(g, n); + else{//must be ( g->right == p ) + BOOST_INTRUSIVE_INVARIANT_ASSERT(false); + NodeTraits::set_right(g, n); + } + } + else{ + if(NodeTraits::get_left(g) == p) + NodeTraits::set_left(g, n); + else //must be ( g->right == p ) + NodeTraits::set_right(g, n); + } + } + + /// @endcond +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_SPLAYTREE_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/treap.hpp b/src/third_party/boost/boost/intrusive/treap.hpp new file mode 100644 index 00000000000..cbf81c180e9 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/treap.hpp @@ -0,0 +1,1784 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008 +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_TRIE_HPP +#define BOOST_INTRUSIVE_TRIE_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <algorithm> +#include <cstddef> +#include <functional> +#include <iterator> +#include <utility> + +#include <boost/intrusive/detail/assert.hpp> +#include <boost/static_assert.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/bs_set_hook.hpp> +#include <boost/intrusive/detail/tree_node.hpp> +#include <boost/intrusive/detail/ebo_functor_holder.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/clear_on_destructor_base.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/intrusive/treap_algorithms.hpp> +#include <boost/intrusive/link_mode.hpp> +#include <boost/move/move.hpp> +#include <boost/intrusive/priority_compare.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +template <class ValueTraits, class Compare, class PrioCompare, class SizeType, bool ConstantTimeSize> +struct treap_setopt +{ + typedef ValueTraits value_traits; + typedef Compare compare; + typedef PrioCompare priority_compare; + typedef SizeType size_type; + static const bool constant_time_size = ConstantTimeSize; +}; + +template <class T> +struct treap_set_defaults + : pack_options + < none + , base_hook<detail::default_bs_set_hook> + , constant_time_size<true> + , size_type<std::size_t> + , compare<std::less<T> > + , priority<boost::intrusive::priority_compare<T> > + >::type +{}; + +/// @endcond + +//! The class template treap is an intrusive treap container that +//! is used to construct intrusive set and multiset containers. The no-throw +//! guarantee holds only, if the value_compare object and priority_compare object +//! don't throw. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<>, +//! \c compare<> and \c priority_compare<> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class treap_impl + : private detail::clear_on_destructor_base<treap_impl<Config> > +{ + template<class C> friend class detail::clear_on_destructor_base; + public: + typedef typename Config::value_traits value_traits; + /// @cond + static const bool external_value_traits = + detail::external_value_traits_is_true<value_traits>::value; + typedef typename detail::eval_if_c + < external_value_traits + , detail::eval_value_traits<value_traits> + , detail::identity<value_traits> + >::type real_value_traits; + /// @endcond + typedef typename real_value_traits::pointer pointer; + typedef typename real_value_traits::const_pointer const_pointer; + typedef typename pointer_traits<pointer>::element_type value_type; + typedef typename pointer_traits<pointer>::reference reference; + typedef typename pointer_traits<const_pointer>::reference const_reference; + typedef typename pointer_traits<pointer>::difference_type difference_type; + typedef value_type key_type; + typedef typename Config::size_type size_type; + typedef typename Config::compare value_compare; + typedef typename Config::priority_compare priority_compare; + typedef value_compare key_compare; + typedef tree_iterator<treap_impl, false> iterator; + typedef tree_iterator<treap_impl, true> const_iterator; + typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator; + typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator; + typedef typename real_value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <node>::type node_ptr; + typedef typename pointer_traits + <pointer>::template rebind_pointer + <const node>::type const_node_ptr; + typedef treap_algorithms<node_traits> node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; + + /// @cond + private: + typedef detail::size_holder<constant_time_size, size_type> size_traits; + + //noncopyable + BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_impl) + + enum { safemode_or_autounlink = + (int)real_value_traits::link_mode == (int)auto_unlink || + (int)real_value_traits::link_mode == (int)safe_link }; + + //Constant-time size is incompatible with auto-unlink hooks! + BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink))); + + struct header_plus_size : public size_traits + { node header_; }; + + struct node_plus_pred_t : public detail::ebo_functor_holder<value_compare> + { + node_plus_pred_t(const value_compare &comp, const priority_compare &p_comp) + : detail::ebo_functor_holder<value_compare>(comp) + , header_plus_priority_size_(p_comp) + {} + struct header_plus_priority_size + : public detail::ebo_functor_holder<priority_compare> + { + header_plus_priority_size(const priority_compare &p_comp) + : detail::ebo_functor_holder<priority_compare>(p_comp) + {} + header_plus_size header_plus_size_; + } header_plus_priority_size_; + }; + + struct data_t : public treap_impl::value_traits + { + typedef typename treap_impl::value_traits value_traits; + data_t(const value_compare & comp, const priority_compare &pcomp, const value_traits &val_traits) + : value_traits(val_traits), node_plus_pred_(comp, pcomp) + {} + node_plus_pred_t node_plus_pred_; + } data_; + + const value_compare &priv_comp() const + { return data_.node_plus_pred_.get(); } + + value_compare &priv_comp() + { return data_.node_plus_pred_.get(); } + + const priority_compare &priv_pcomp() const + { return data_.node_plus_pred_.header_plus_priority_size_.get(); } + + priority_compare &priv_pcomp() + { return data_.node_plus_pred_.header_plus_priority_size_.get(); } + + const value_traits &priv_value_traits() const + { return data_; } + + value_traits &priv_value_traits() + { return data_; } + + node_ptr priv_header_ptr() + { return pointer_traits<node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_priority_size_.header_plus_size_.header_); } + + const_node_ptr priv_header_ptr() const + { return pointer_traits<const_node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_priority_size_.header_plus_size_.header_); } + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + size_traits &priv_size_traits() + { return data_.node_plus_pred_.header_plus_priority_size_.header_plus_size_; } + + const size_traits &priv_size_traits() const + { return data_.node_plus_pred_.header_plus_priority_size_.header_plus_size_; } + + const real_value_traits &get_real_value_traits(detail::bool_<false>) const + { return data_; } + + const real_value_traits &get_real_value_traits(detail::bool_<true>) const + { return data_.get_value_traits(*this); } + + real_value_traits &get_real_value_traits(detail::bool_<false>) + { return data_; } + + real_value_traits &get_real_value_traits(detail::bool_<true>) + { return data_.get_value_traits(*this); } + + /// @endcond + + public: + + const real_value_traits &get_real_value_traits() const + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + real_value_traits &get_real_value_traits() + { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } + + typedef typename node_algorithms::insert_commit_data insert_commit_data; + + //! <b>Effects</b>: Constructs an empty treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare/priority_compare objects throw. Basic guarantee. + treap_impl( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, pcmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty treap and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare/priority_compare objects + //! throw. Basic guarantee. + template<class Iterator> + treap_impl( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : data_(cmp, pcmp, v_traits) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + if(unique) + this->insert_unique(b, e); + else + this->insert_equal(b, e); + } + + //! <b>Effects</b>: to-do + //! + treap_impl(BOOST_RV_REF(treap_impl) x) + : data_( ::boost::move(x.priv_comp()) + , ::boost::move(x.priv_pcomp()) + , ::boost::move(x.priv_value_traits())) + { + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(size_type(0)); + this->swap(x); + } + + //! <b>Effects</b>: to-do + //! + treap_impl& operator=(BOOST_RV_REF(treap_impl) x) + { this->swap(x); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the set + //! are not deleted (i.e. no destructors are called), but the nodes according to + //! the value_traits template parameter are reinitialized and thus can be reused. + //! + //! <b>Complexity</b>: Linear to elements contained in *this + //! if constant-time size option is disabled. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~treap_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return this->cbegin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return const_iterator (node_traits::get_left(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return iterator (this->priv_header_ptr(), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return this->cend(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return const_iterator (uncast(this->priv_header_ptr()), this); } + + + //! <b>Effects</b>: Returns an iterator pointing to the highest priority object of the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator top() + { return this->empty() ? this->end() : iterator (node_traits::get_parent(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the treap.. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator top() const + { return this->ctop(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the treap.. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator ctop() const + { return this->empty() ? this->cend() : const_iterator (node_traits::get_parent(this->priv_header_ptr()), this); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return reverse_iterator(this->end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return const_reverse_iterator(this->end()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return const_reverse_iterator(this->end()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return reverse_iterator(this->begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return const_reverse_iterator(this->begin()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return const_reverse_iterator(this->begin()); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the highest priority object of the + //! reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rtop() + { return reverse_iterator(this->top()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority objec + //! of the reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rtop() const + { return const_reverse_iterator(this->top()); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority object + //! of the reversed treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crtop() const + { return const_reverse_iterator(this->top()); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of treap. + //! + //! <b>Effects</b>: Returns a const reference to the treap associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static treap_impl &container_from_end_iterator(iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of treap. + //! + //! <b>Effects</b>: Returns a const reference to the treap associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const treap_impl &container_from_end_iterator(const_iterator end_iterator) + { return priv_container_from_end_iterator(end_iterator); } + + //! <b>Precondition</b>: it must be a valid iterator + //! of treap. + //! + //! <b>Effects</b>: Returns a const reference to the treap associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static treap_impl &container_from_iterator(iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Precondition</b>: it must be a valid end const_iterator + //! of treap. + //! + //! <b>Effects</b>: Returns a const reference to the treap associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const treap_impl &container_from_iterator(const_iterator it) + { return priv_container_from_iterator(it); } + + //! <b>Effects</b>: Returns the value_compare object used by the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return this->priv_comp(); } + + //! <b>Effects</b>: Returns the priority_compare object used by the treap. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If priority_compare copy-constructor throws. + priority_compare priority_comp() const + { return this->priv_pcomp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return node_algorithms::unique(this->priv_header_ptr()); } + + //! <b>Effects</b>: Returns the number of elements stored in the treap. + //! + //! <b>Complexity</b>: Linear to elements contained in *this + //! if constant-time size option is disabled. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { + if(constant_time_size) + return this->priv_size_traits().get_size(); + else{ + return (size_type)node_algorithms::size(this->priv_header_ptr()); + } + } + + //! <b>Effects</b>: Swaps the contents of two treaps. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the comparison functor's swap call throws. + void swap(treap_impl& other) + { + //This can throw + using std::swap; + swap(priv_comp(), priv_comp()); + swap(priv_pcomp(), priv_pcomp()); + //These can't throw + node_algorithms::swap_tree(this->priv_header_ptr(), other.priv_header_ptr()); + if(constant_time_size){ + size_type backup = this->priv_size_traits().get_size(); + this->priv_size_traits().set_size(other.priv_size_traits().get_size()); + other.priv_size_traits().set_size(backup); + } + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the treap before the upper bound. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare functions throw. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(reference value) + { + detail::key_nodeptr_comp<value_compare, treap_impl> + key_node_comp(priv_comp(), this); + detail::key_nodeptr_comp<priority_compare, treap_impl> + key_node_pcomp(priv_pcomp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret(node_algorithms::insert_equal_upper_bound + (this->priv_header_ptr(), to_insert, key_node_comp, key_node_pcomp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator. + //! + //! <b>Effects</b>: Inserts x into the treap, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case) + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare functions throw. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_equal(const_iterator hint, reference value) + { + detail::key_nodeptr_comp<value_compare, treap_impl> + key_node_comp(priv_comp(), this); + detail::key_nodeptr_comp<priority_compare, treap_impl> + key_node_pcomp(priv_pcomp(), this); + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + iterator ret (node_algorithms::insert_equal + (this->priv_header_ptr(), hint.pointed_node(), to_insert, key_node_comp, key_node_pcomp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a each element of a range into the treap + //! before the upper bound of the key of each element. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare functions throw. + //! Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_equal(Iterator b, Iterator e) + { + iterator end(this->end()); + for (; b != e; ++b) + this->insert_equal(end, *b); + } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the treap if the value + //! is not already present. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare functions throw. + //! Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert_unique(reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(value, priv_comp(), priv_pcomp(), commit_data); + if(!ret.second) + return ret; + return std::pair<iterator, bool> (insert_unique_commit(value, commit_data), true); + } + + //! <b>Requires</b>: value must be an lvalue, and "hint" must be + //! a valid iterator + //! + //! <b>Effects</b>: Tries to insert x into the treap, using "hint" as a hint + //! to where it will be inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time (two comparisons in the worst case) + //! if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare functions throw. + //! Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert_unique(const_iterator hint, reference value) + { + insert_commit_data commit_data; + std::pair<iterator, bool> ret = insert_unique_check(hint, value, priv_comp(), priv_pcomp(), commit_data); + if(!ret.second) + return ret.first; + return insert_unique_commit(value, commit_data); + } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Tries to insert each element of a range into the treap. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare functions throw. + //! Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert_unique(Iterator b, Iterator e) + { + if(this->empty()){ + iterator end(this->end()); + for (; b != e; ++b) + this->insert_unique(end, *b); + } + else{ + for (; b != e; ++b) + this->insert_unique(*b); + } + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. + //! key_value_pcomp must be a comparison function that induces + //! the same strict weak ordering as priority_compare. The difference is that + //! key_value_pcomp and key_value_comp compare an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If the key_value_comp or key_value_pcomp + //! ordering functions throw. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare, class KeyValuePrioCompare> + std::pair<iterator, bool> insert_unique_check + ( const KeyType &key, KeyValueCompare key_value_comp + , KeyValuePrioCompare key_value_pcomp, insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + comp(key_value_comp, this); + detail::key_nodeptr_comp<KeyValuePrioCompare, treap_impl> + pcomp(key_value_pcomp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), key, comp, pcomp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. + //! key_value_pcomp must be a comparison function that induces + //! the same strict weak ordering as priority_compare. The difference is that + //! key_value_pcomp and key_value_comp compare an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the container, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the key_value_comp or key_value_pcomp + //! ordering functions throw. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the container. + template<class KeyType, class KeyValueCompare, class KeyValuePrioCompare> + std::pair<iterator, bool> insert_unique_check + ( const_iterator hint, const KeyType &key + , KeyValueCompare key_value_comp + , KeyValuePrioCompare key_value_pcomp + , insert_commit_data &commit_data) + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + comp(key_value_comp, this); + detail::key_nodeptr_comp<KeyValuePrioCompare, treap_impl> + pcomp(key_value_pcomp, this); + std::pair<node_ptr, bool> ret = + (node_algorithms::insert_unique_check + (this->priv_header_ptr(), hint.pointed_node(), key, comp, pcomp, commit_data)); + return std::pair<iterator, bool>(iterator(ret.first, this), ret.second); + } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the container between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + node_algorithms::insert_unique_commit(this->priv_header_ptr(), to_insert, commit_data); + this->priv_size_traits().increment(); + return iterator(to_insert, this); + } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate + //! + //! <b>Effects</b>: Inserts x into the treap before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" treap ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + detail::key_nodeptr_comp<priority_compare, treap_impl> + pcomp(priv_pcomp(), this); + iterator ret (node_algorithms::insert_before + (this->priv_header_ptr(), pos.pointed_node(), to_insert, pcomp), this); + this->priv_size_traits().increment(); + return ret; + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no less + //! than the greatest inserted key + //! + //! <b>Effects</b>: Inserts x into the treap in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key treap ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + detail::key_nodeptr_comp<priority_compare, treap_impl> + pcomp(priv_pcomp(), this); + node_algorithms::push_back(this->priv_header_ptr(), to_insert, pcomp); + this->priv_size_traits().increment(); + } + + //! <b>Requires</b>: value must be an lvalue, and it must be no greater + //! than the minimum inserted key + //! + //! <b>Effects</b>: Inserts x into the treap in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key treap ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { + node_ptr to_insert(get_real_value_traits().to_node_ptr(value)); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + detail::key_nodeptr_comp<priority_compare, treap_impl> + pcomp(priv_pcomp(), this); + node_algorithms::push_front(this->priv_header_ptr(), to_insert, pcomp); + this->priv_size_traits().increment(); + } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { + const_iterator ret(i); + ++ret; + node_ptr to_erase(i.pointed_node()); + if(safemode_or_autounlink) + BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); + detail::key_nodeptr_comp<priority_compare, treap_impl> + key_node_pcomp(priv_pcomp(), this); + node_algorithms::erase(this->priv_header_ptr(), to_erase, key_node_pcomp); + this->priv_size_traits().decrement(); + if(safemode_or_autounlink) + node_algorithms::init(to_erase); + return ret.unconst(); + } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { size_type n; return private_erase(b, e, n); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return this->erase(value, priv_comp()); } + + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: if the internal priority_compare function throws. + //! Equivalent guarantee to <i>while(beg != end) erase(beg++);</i> + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { + node_ptr to_erase(i.pointed_node()); + iterator ret(this->erase(i)); + disposer(get_real_value_traits().to_value_ptr(to_erase)); + return ret; + } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { size_type n; return private_erase(b, e, n, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: if the priority_compare function throws then weak guarantee and heap invariants are broken. + //! The safest thing would be to clear or destroy the container. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { + std::pair<iterator,iterator> p = this->equal_range(value); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + N). + //! + //! <b>Throws</b>: if the priority_compare function throws then weak guarantee and heap invariants are broken. + //! The safest thing would be to clear or destroy the container. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { + std::pair<iterator,iterator> p = this->equal_range(key, comp); + size_type n; + private_erase(p.first, p.second, n, disposer); + return n; + } + + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { + if(safemode_or_autounlink){ + this->clear_and_dispose(detail::null_disposer()); + } + else{ + node_algorithms::init_header(priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + } + + //! <b>Effects</b>: Erases all of the elements calling disposer(p) for + //! each node to be erased. + //! <b>Complexity</b>: Average complexity for is at most O(log(size() + N)), + //! where N is the number of elements in the container. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. Calls N times to disposer functor. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { + node_algorithms::clear_and_dispose(this->priv_header_ptr() + , detail::node_disposer<Disposer, treap_impl>(disposer, this)); + node_algorithms::init_header(this->priv_header_ptr()); + this->priv_size_traits().set_size(0); + } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given value. + //! + //! <b>Throws</b>: Nothing. + size_type count(const_reference value) const + { return this->count(value, priv_comp()); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType &key, KeyValueCompare comp) const + { + std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp); + return std::distance(ret.first, ret.second); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator lower_bound(const_reference value) + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator lower_bound(const_reference value) const + { return this->lower_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::lower_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator upper_bound(const_reference value) + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + return iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator upper_bound(const_reference value) const + { return this->upper_bound(value, priv_comp()); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k according to comp or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + return const_iterator(node_algorithms::upper_bound + (this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + iterator find(const_reference value) + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + return iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + const_iterator find(const_reference value) const + { return this->find(value, priv_comp()); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + return const_iterator + (node_algorithms::find(this->priv_header_ptr(), key, key_node_comp), this); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<iterator,iterator> equal_range(const_reference value) + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp) + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<iterator, iterator>(iterator(ret.first, this), iterator(ret.second, this)); + } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return this->equal_range(value, priv_comp()); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType &key, KeyValueCompare comp) const + { + detail::key_nodeptr_comp<KeyValueCompare, treap_impl> + key_node_comp(comp, this); + std::pair<node_ptr, node_ptr> ret + (node_algorithms::equal_range(this->priv_header_ptr(), key, key_node_comp)); + return std::pair<const_iterator, const_iterator>(const_iterator(ret.first, this), const_iterator(ret.second, this)); + } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const treap_impl &src, Cloner cloner, Disposer disposer) + { + this->clear_and_dispose(disposer); + if(!src.empty()){ + detail::exception_disposer<treap_impl, Disposer> + rollback(*this, disposer); + node_algorithms::clone + (src.priv_header_ptr() + ,this->priv_header_ptr() + ,detail::node_cloner<Cloner, treap_impl>(cloner, this) + ,detail::node_disposer<Disposer, treap_impl>(disposer, this)); + this->priv_size_traits().set_size(src.priv_size_traits().get_size()); + this->priv_comp() = src.priv_comp(); + rollback.release(); + } + } + + //! <b>Effects</b>: Unlinks the leftmost node from the treap. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the treap and the treap can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the treap. + pointer unlink_leftmost_without_rebalance() + { + node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance + (this->priv_header_ptr())); + if(!to_be_disposed) + return 0; + this->priv_size_traits().decrement(); + if(safemode_or_autounlink)//If this is commented does not work with normal_link + node_algorithms::init(to_be_disposed); + return get_real_value_traits().to_value_ptr(to_be_disposed); + } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any treap. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! treap with with_this. The treap does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering and priority rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { + node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this) + , this->priv_header_ptr() + , get_real_value_traits().to_node_ptr(with_this)); + if(safemode_or_autounlink) + node_algorithms::init(replace_this.pointed_node()); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return iterator (value_traits::to_node_ptr(value), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { + BOOST_STATIC_ASSERT((!stateful_value_traits)); + return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), 0); + } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return iterator (value_traits::to_node_ptr(value), this); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this); } + + //! <b>Requires</b>: value shall not be in a treap. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { node_algorithms::init(value_traits::to_node_ptr(value)); } + + /// @cond + private: + template<class Disposer> + iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer) + { + for(n = 0; b != e; ++n) + this->erase_and_dispose(b++, disposer); + return b.unconst(); + } + + iterator private_erase(const_iterator b, const_iterator e, size_type &n) + { + for(n = 0; b != e; ++n) + this->erase(b++); + return b.unconst(); + } + /// @endcond + + private: + static treap_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) + { + header_plus_size *r = detail::parent_from_member<header_plus_size, node> + ( boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()), &header_plus_size::header_); + typename node_plus_pred_t::header_plus_priority_size *n = + detail::parent_from_member + < typename node_plus_pred_t::header_plus_priority_size + , header_plus_size> + (r, &node_plus_pred_t::header_plus_priority_size::header_plus_size_); + node_plus_pred_t *pn = detail::parent_from_member + < node_plus_pred_t + , typename node_plus_pred_t::header_plus_priority_size> + (n, &node_plus_pred_t::header_plus_priority_size_); + data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(pn, &data_t::node_plus_pred_); + treap_impl *tr = detail::parent_from_member<treap_impl, data_t>(d, &treap_impl::data_); + return *tr; + } + + static treap_impl &priv_container_from_iterator(const const_iterator &it) + { return priv_container_from_end_iterator(it.end_iterator_from_it()); } +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator< +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_impl<T, Options...> &x, const treap_impl<T, Options...> &y) +#else +(const treap_impl<Config> &x, const treap_impl<Config> &y) +#endif +{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +bool operator== +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_impl<T, Options...> &x, const treap_impl<T, Options...> &y) +#else +(const treap_impl<Config> &x, const treap_impl<Config> &y) +#endif +{ + typedef treap_impl<Config> tree_type; + typedef typename tree_type::const_iterator const_iterator; + + if(tree_type::constant_time_size && x.size() != y.size()){ + return false; + } + const_iterator end1 = x.end(); + const_iterator i1 = x.begin(); + const_iterator i2 = y.begin(); + if(tree_type::constant_time_size){ + while (i1 != end1 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1; + } + else{ + const_iterator end2 = y.end(); + while (i1 != end1 && i2 != end2 && *i1 == *i2) { + ++i1; + ++i2; + } + return i1 == end1 && i2 == end2; + } +} + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_impl<T, Options...> &x, const treap_impl<T, Options...> &y) +#else +(const treap_impl<Config> &x, const treap_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_impl<T, Options...> &x, const treap_impl<T, Options...> &y) +#else +(const treap_impl<Config> &x, const treap_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_impl<T, Options...> &x, const treap_impl<T, Options...> &y) +#else +(const treap_impl<Config> &x, const treap_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_impl<T, Options...> &x, const treap_impl<T, Options...> &y) +#else +(const treap_impl<Config> &x, const treap_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(treap_impl<T, Options...> &x, treap_impl<T, Options...> &y) +#else +(treap_impl<Config> &x, treap_impl<Config> &y) +#endif +{ x.swap(y); } + +/// @cond +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none + > +#else +template<class T, class ...Options> +#endif +struct make_treap_opt +{ + typedef typename pack_options + < treap_set_defaults<T>, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + typedef typename detail::get_value_traits + <T, typename packed_options::value_traits>::type value_traits; + + typedef treap_setopt + < value_traits + , typename packed_options::compare + , typename packed_options::priority + , typename packed_options::size_type + , packed_options::constant_time_size + > type; +}; +/// @endcond + +//! Helper metafunction to define a \c treap that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_trie +{ + /// @cond + typedef treap_impl + < typename make_treap_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class treap + : public make_trie<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_trie + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(treap) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::priority_compare priority_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::real_value_traits real_value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); + + treap( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, pcmp, v_traits) + {} + + template<class Iterator> + treap( bool unique, Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : Base(unique, b, e, cmp, pcmp, v_traits) + {} + + treap(BOOST_RV_REF(treap) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + treap& operator=(BOOST_RV_REF(treap) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static treap &container_from_end_iterator(iterator end_iterator) + { return static_cast<treap &>(Base::container_from_end_iterator(end_iterator)); } + + static const treap &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const treap &>(Base::container_from_end_iterator(end_iterator)); } + + static treap &container_from_it(iterator it) + { return static_cast<treap &>(Base::container_from_iterator(it)); } + + static const treap &container_from_it(const_iterator it) + { return static_cast<const treap &>(Base::container_from_iterator(it)); } +}; + +#endif + + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_TRIE_HPP diff --git a/src/third_party/boost/boost/intrusive/treap_algorithms.hpp b/src/third_party/boost/boost/intrusive/treap_algorithms.hpp new file mode 100644 index 00000000000..128e7ce2271 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/treap_algorithms.hpp @@ -0,0 +1,895 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_TREAP_ALGORITHMS_HPP +#define BOOST_INTRUSIVE_TREAP_ALGORITHMS_HPP + +#include <boost/intrusive/detail/config_begin.hpp> + +#include <cstddef> +#include <boost/intrusive/intrusive_fwd.hpp> + +#include <boost/intrusive/detail/assert.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/detail/tree_algorithms.hpp> +#include <algorithm> + + +namespace boost { +namespace intrusive { + +//! treap_algorithms provides basic algorithms to manipulate +//! nodes forming a treap. +//! +//! (1) the header node is maintained with links not only to the root +//! but also to the leftmost node of the tree, to enable constant time +//! begin(), and to the rightmost node of the tree, to enable linear time +//! performance when used with the generic set algorithms (set_union, +//! etc.); +//! +//! (2) when a node being deleted has two children its successor node is +//! relinked into its place, rather than copied, so that the only +//! pointers invalidated are those referring to the deleted node. +//! +//! treap_algorithms is configured with a NodeTraits class, which encapsulates the +//! information about the node to be manipulated. NodeTraits must support the +//! following interface: +//! +//! <b>Typedefs</b>: +//! +//! <tt>node</tt>: The type of the node that forms the circular list +//! +//! <tt>node_ptr</tt>: A pointer to a node +//! +//! <tt>const_node_ptr</tt>: A pointer to a const node +//! +//! <b>Static functions</b>: +//! +//! <tt>static node_ptr get_parent(const_node_ptr n);</tt> +//! +//! <tt>static void set_parent(node_ptr n, node_ptr parent);</tt> +//! +//! <tt>static node_ptr get_left(const_node_ptr n);</tt> +//! +//! <tt>static void set_left(node_ptr n, node_ptr left);</tt> +//! +//! <tt>static node_ptr get_right(const_node_ptr n);</tt> +//! +//! <tt>static void set_right(node_ptr n, node_ptr right);</tt> +template<class NodeTraits> +class treap_algorithms +{ + public: + typedef NodeTraits node_traits; + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + + /// @cond + private: + + class remove_on_destroy + { + remove_on_destroy(const remove_on_destroy&); + remove_on_destroy& operator=(const remove_on_destroy&); + public: + remove_on_destroy(const node_ptr & header, const node_ptr & z) + : header_(header), z_(z), remove_it_(true) + {} + ~remove_on_destroy() + { + if(remove_it_){ + tree_algorithms::erase(header_, z_); + } + } + + void release() + { remove_it_ = false; } + + const node_ptr header_; + const node_ptr z_; + bool remove_it_; + }; + + class rerotate_on_destroy + { + rerotate_on_destroy(const remove_on_destroy&); + rerotate_on_destroy& operator=(const rerotate_on_destroy&); + + public: + rerotate_on_destroy(const node_ptr & header, const node_ptr & p, std::size_t &n) + : header_(header), p_(p), n_(n), remove_it_(true) + {} + + ~rerotate_on_destroy() + { + if(remove_it_){ + rotate_up_n(header_, p_, n_); + } + } + + void release() + { remove_it_ = false; } + + const node_ptr header_; + const node_ptr p_; + std::size_t &n_; + bool remove_it_; + }; + + static void rotate_up_n(const node_ptr header, const node_ptr p, std::size_t n) + { + for( node_ptr p_parent = NodeTraits::get_parent(p) + ; n-- + ; p_parent = NodeTraits::get_parent(p)){ + //Check if left child + if(p == NodeTraits::get_left(p_parent)){ + tree_algorithms::rotate_right(p_parent, header); + } + else{ //Right child + tree_algorithms::rotate_left(p_parent, header); + } + } + } + + typedef detail::tree_algorithms<NodeTraits> tree_algorithms; + + static node_ptr uncast(const const_node_ptr & ptr) + { return pointer_traits<node_ptr>::const_cast_from(ptr); } + + /// @endcond + + public: + static node_ptr begin_node(const const_node_ptr & header) + { return tree_algorithms::begin_node(header); } + + static node_ptr end_node(const const_node_ptr & header) + { return tree_algorithms::end_node(header); } + + //! This type is the information that will be + //! filled by insert_unique_check + struct insert_commit_data + /// @cond + : public tree_algorithms::insert_commit_data + /// @endcond + { + /// @cond + std::size_t rotations; + /// @endcond + }; + + //! <b>Requires</b>: header1 and header2 must be the header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two trees. After the function header1 will contain + //! links to the second tree and header2 will have links to the first tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static void swap_tree(const node_ptr & header1, const node_ptr & header2) + { return tree_algorithms::swap_tree(header1, header2); } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & node2) + { + if(node1 == node2) + return; + + node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2)); + swap_nodes(node1, header1, node2, header2); + } + + //! <b>Requires</b>: node1 and node2 can't be header nodes + //! of two trees with header header1 and header2. + //! + //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted + //! in the position node2 before the function. node2 will be inserted in the + //! position node1 had before the function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! node1 and node2 are not equivalent according to the ordering rules. + //! + //!Experimental function + static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) + { tree_algorithms::swap_nodes(node1, header1, node2, header2); } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing and comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) + { + if(node_to_be_replaced == new_node) + return; + replace_node(node_to_be_replaced, tree_algorithms::get_header(node_to_be_replaced), new_node); + } + + //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree + //! with header "header" and new_node must not be inserted in a tree. + //! + //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the + //! tree with new_node. The tree does not need to be rebalanced + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! new_node is not equivalent to node_to_be_replaced according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + //! + //!Experimental function + static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) + { tree_algorithms::replace_node(node_to_be_replaced, header, new_node); } + + //! <b>Requires</b>: node is a tree node but not the header. + //! + //! <b>Effects</b>: Unlinks the node and rebalances the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: If "pcomp" throws, strong guarantee + template<class NodePtrPriorityCompare> + static void unlink(const node_ptr & node, NodePtrPriorityCompare pcomp) + { + node_ptr x = NodeTraits::get_parent(node); + if(x){ + while(!is_header(x)) + x = NodeTraits::get_parent(x); + erase(x, node, pcomp); + } + } + + //! <b>Requires</b>: header is the header of a tree. + //! + //! <b>Effects</b>: Unlinks the leftmost node from the tree, and + //! updates the header link to the new leftmost node. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + static node_ptr unlink_leftmost_without_rebalance(const node_ptr & header) + { return tree_algorithms::unlink_leftmost_without_rebalance(header); } + + //! <b>Requires</b>: node is a node of the tree or an node initialized + //! by init(...). + //! + //! <b>Effects</b>: Returns true if the node is initialized by init(). + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + static bool unique(const const_node_ptr & node) + { return tree_algorithms::unique(node); } + + //! <b>Requires</b>: node is a node of the tree but it's not the header. + //! + //! <b>Effects</b>: Returns the number of nodes of the subtree. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t count(const const_node_ptr & node) + { return tree_algorithms::count(node); } + + //! <b>Requires</b>: header is the header node of the tree. + //! + //! <b>Effects</b>: Returns the number of nodes above the header. + //! + //! <b>Complexity</b>: Linear time. + //! + //! <b>Throws</b>: Nothing. + static std::size_t size(const const_node_ptr & header) + { return tree_algorithms::size(header); } + + //! <b>Requires</b>: p is a node from the tree except the header. + //! + //! <b>Effects</b>: Returns the next node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr next_node(const node_ptr & p) + { return tree_algorithms::next_node(p); } + + //! <b>Requires</b>: p is a node from the tree except the leftmost node. + //! + //! <b>Effects</b>: Returns the previous node of the tree. + //! + //! <b>Complexity</b>: Average constant time. + //! + //! <b>Throws</b>: Nothing. + static node_ptr prev_node(const node_ptr & p) + { return tree_algorithms::prev_node(p); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: After the function unique(node) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init(const node_ptr & node) + { tree_algorithms::init(node); } + + //! <b>Requires</b>: node must not be part of any tree. + //! + //! <b>Effects</b>: Initializes the header to represent an empty tree. + //! unique(header) == true. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. + static void init_header(const node_ptr & header) + { + tree_algorithms::init_header(header); + } + + //! <b>Requires</b>: header must be the header of a tree, z a node + //! of that tree and z != header. + //! + //! <b>Effects</b>: Erases node "z" from the tree with header "header". + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: If "pcomp" throws, strong guarantee. + template<class NodePtrPriorityCompare> + static node_ptr erase(const node_ptr & header, const node_ptr & z, NodePtrPriorityCompare pcomp) + { + rebalance_for_erasure(header, z, pcomp); + tree_algorithms::erase(header, z); +// assert(check_invariant(header, pcomp)); + return z; + } + + //! <b>Requires</b>: "cloner" must be a function + //! object taking a node_ptr and returning a new cloned node of it. "disposer" must + //! take a node_ptr and shouldn't throw. + //! + //! <b>Effects</b>: First empties target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! Then, duplicates the entire tree pointed by "source_header" cloning each + //! source node with <tt>node_ptr Cloner::operator()(const node_ptr &)</tt> to obtain + //! the nodes of the target tree. If "cloner" throws, the cloned target nodes + //! are disposed using <tt>void disposer(const node_ptr &)</tt>. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template <class Cloner, class Disposer> + static void clone + (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) + { + tree_algorithms::clone(source_header, target_header, cloner, disposer); + } + + //! <b>Requires</b>: "disposer" must be an object function + //! taking a node_ptr parameter and shouldn't throw. + //! + //! <b>Effects</b>: Empties the target tree calling + //! <tt>void disposer::operator()(const node_ptr &)</tt> for every node of the tree + //! except the header. + //! + //! <b>Complexity</b>: Linear to the number of element of the source tree plus the. + //! number of elements of tree target tree when calling this function. + //! + //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed. + template<class Disposer> + static void clear_and_dispose(const node_ptr & header, Disposer disposer) + { tree_algorithms::clear_and_dispose(header, disposer); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is + //! not less than "key" according to "comp" or "header" if that element does + //! not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr lower_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::lower_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the first element that is greater + //! than "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr upper_bound + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::upper_bound(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an node_ptr to the element that is equivalent to + //! "key" according to "comp" or "header" if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static node_ptr find + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::find(header, key, comp); } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. + //! + //! <b>Effects</b>: Returns an a pair of node_ptr delimiting a range containing + //! all elements that are equivalent to "key" according to "comp" or an + //! empty range that indicates the position where those elements would be + //! if they there are no equivalent elements. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class KeyType, class KeyNodePtrCompare> + static std::pair<node_ptr, node_ptr> equal_range + (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) + { return tree_algorithms::equal_range(header, key, comp); } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! NodePtrPriorityCompare is a priority function object that induces a strict weak + //! ordering compatible with the one used to create the + //! the tree. NodePtrPriorityCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the upper bound + //! according to "comp" and rotates the tree according to "pcomp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throw or "pcomp" throw. + template<class NodePtrCompare, class NodePtrPriorityCompare> + static node_ptr insert_equal_upper_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, NodePtrPriorityCompare pcomp) + { + insert_commit_data commit_data; + tree_algorithms::insert_equal_upper_bound_check(h, new_node, comp, commit_data); + rebalance_check_and_commit(h, new_node, pcomp, commit_data); + return new_node; + } + + //! <b>Requires</b>: "h" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. + //! NodePtrPriorityCompare is a priority function object that induces a strict weak + //! ordering compatible with the one used to create the + //! the tree. NodePtrPriorityCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before the upper bound + //! according to "comp" and rotates the tree according to "pcomp". + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + template<class NodePtrCompare, class NodePtrPriorityCompare> + static node_ptr insert_equal_lower_bound + (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, NodePtrPriorityCompare pcomp) + { + insert_commit_data commit_data; + tree_algorithms::insert_equal_lower_bound_check(h, new_node, comp, commit_data); + rebalance_check_and_commit(h, new_node, pcomp, commit_data); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! NodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares two node_ptrs. "hint" is node from + //! the "header"'s tree. + //! NodePtrPriorityCompare is a priority function object that induces a strict weak + //! ordering compatible with the one used to create the + //! the tree. NodePtrPriorityCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree, using "hint" as a hint to + //! where it will be inserted. If "hint" is the upper_bound + //! the insertion takes constant time (two comparisons in the worst case). + //! Rotates the tree according to "pcomp". + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if new_node is inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throw or "pcomp" throw. + template<class NodePtrCompare, class NodePtrPriorityCompare> + static node_ptr insert_equal + (const node_ptr & h, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp, NodePtrPriorityCompare pcomp) + { + insert_commit_data commit_data; + tree_algorithms::insert_equal_check(h, hint, new_node, comp, commit_data); + rebalance_check_and_commit(h, new_node, pcomp, commit_data); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "pos" must be a valid node of the tree (including header end) node. + //! "pos" must be a node pointing to the successor to "new_node" + //! once inserted according to the order of already inserted nodes. This function does not + //! check "pos" and this precondition must be guaranteed by the caller. + //! NodePtrPriorityCompare is a priority function object that induces a strict weak + //! ordering compatible with the one used to create the + //! the tree. NodePtrPriorityCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts new_node into the tree before "pos" + //! and rotates the tree according to "pcomp". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: If "pcomp" throws, strong guarantee. + //! + //! <b>Note</b>: If "pos" is not the successor of the newly inserted "new_node" + //! tree invariants might be broken. + template<class NodePtrPriorityCompare> + static node_ptr insert_before + (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node, NodePtrPriorityCompare pcomp) + { + insert_commit_data commit_data; + tree_algorithms::insert_before_check(header, pos, commit_data); + rebalance_check_and_commit(header, new_node, pcomp, commit_data); + return new_node; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering no less than the + //! greatest inserted key. + //! NodePtrPriorityCompare is a priority function object that induces a strict weak + //! ordering compatible with the one used to create the + //! the tree. NodePtrPriorityCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts x into the tree in the last position + //! and rotates the tree according to "pcomp". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: If "pcomp" throws, strong guarantee. + //! + //! <b>Note</b>: If "new_node" is less than the greatest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + template<class NodePtrPriorityCompare> + static void push_back(const node_ptr & header, const node_ptr & new_node, NodePtrPriorityCompare pcomp) + { + insert_commit_data commit_data; + tree_algorithms::push_back_check(header, commit_data); + rebalance_check_and_commit(header, new_node, pcomp, commit_data); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "new_node" must be, according to the used ordering, no greater than the + //! lowest inserted key. + //! NodePtrPriorityCompare is a priority function object that induces a strict weak + //! ordering compatible with the one used to create the + //! the tree. NodePtrPriorityCompare compares two node_ptrs. + //! + //! <b>Effects</b>: Inserts x into the tree in the first position + //! and rotates the tree according to "pcomp". + //! + //! <b>Complexity</b>: Constant-time. + //! + //! <b>Throws</b>: If "pcomp" throws, strong guarantee. + //! + //! <b>Note</b>: If "new_node" is greater than the lowest inserted key + //! tree invariants are broken. This function is slightly faster than + //! using "insert_before". + template<class NodePtrPriorityCompare> + static void push_front(const node_ptr & header, const node_ptr & new_node, NodePtrPriorityCompare pcomp) + { + insert_commit_data commit_data; + tree_algorithms::push_front_check(header, commit_data); + rebalance_check_and_commit(header, new_node, pcomp, commit_data); + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare, class KeyNodePtrPrioCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const KeyType &key + ,KeyNodePtrCompare comp, KeyNodePtrPrioCompare pcomp + ,insert_commit_data &commit_data) + { + std::pair<node_ptr, bool> ret = + tree_algorithms::insert_unique_check(header, key, comp, commit_data); + if(ret.second) + rebalance_after_insertion_check(header, commit_data.node, key, pcomp, commit_data.rotations); + return ret; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! KeyNodePtrCompare is a function object that induces a strict weak + //! ordering compatible with the strict weak ordering used to create the + //! the tree. NodePtrCompare compares KeyType with a node_ptr. + //! "hint" is node from the "header"'s tree. + //! + //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the + //! tree according to "comp" using "hint" as a hint to where it should be + //! inserted and obtains the needed information to realize + //! a constant-time node insertion if there is no equivalent node. + //! If "hint" is the upper_bound the function has constant time + //! complexity (two comparisons in the worst case). + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing a node_ptr to the already present node + //! and false. If there is not equivalent key can be inserted returns true + //! in the returned pair's boolean and fills "commit_data" that is meant to + //! be used with the "insert_commit" function to achieve a constant-time + //! insertion function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic, but it is + //! amortized constant time if new_node should be inserted immediately before "hint". + //! + //! <b>Throws</b>: If "comp" throws. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a node is expensive and the user does not want to have two equivalent nodes + //! in the tree: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the node and this function offers the possibility to use that part + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the node and use + //! "insert_commit" to insert the node in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_unique_commit" only + //! if no more objects are inserted or erased from the set. + template<class KeyType, class KeyNodePtrCompare, class KeyNodePtrPrioCompare> + static std::pair<node_ptr, bool> insert_unique_check + (const const_node_ptr & header, const node_ptr & hint, const KeyType &key + ,KeyNodePtrCompare comp, KeyNodePtrPrioCompare pcomp, insert_commit_data &commit_data) + { + std::pair<node_ptr, bool> ret = + tree_algorithms::insert_unique_check(header, hint, key, comp, commit_data); + if(ret.second) + rebalance_after_insertion_check(header, commit_data.node, key, pcomp, commit_data.rotations); + return ret; + } + + //! <b>Requires</b>: "header" must be the header node of a tree. + //! "commit_data" must have been obtained from a previous call to + //! "insert_unique_check". No objects should have been inserted or erased + //! from the set between the "insert_unique_check" that filled "commit_data" + //! and the call to "insert_commit". + //! + //! + //! <b>Effects</b>: Inserts new_node in the set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_unique_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + static void insert_unique_commit + (const node_ptr & header, const node_ptr & new_node, const insert_commit_data &commit_data) + { + tree_algorithms::insert_unique_commit(header, new_node, commit_data); + rebalance_after_insertion_commit(header, new_node, commit_data.rotations); + } + + //! <b>Requires</b>: "n" must be a node inserted in a tree. + //! + //! <b>Effects</b>: Returns a pointer to the header node of the tree. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: Nothing. + static node_ptr get_header(const node_ptr & n) + { return tree_algorithms::get_header(n); } + + /// @cond + private: + + //! <b>Requires</b>: p is a node of a tree. + //! + //! <b>Effects</b>: Returns true if p is the header of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + static bool is_header(const const_node_ptr & p) + { + return tree_algorithms::is_header(p); + } + + template<class NodePtrPriorityCompare> + static void rebalance_for_erasure(const node_ptr & header, const node_ptr & z, NodePtrPriorityCompare pcomp) + { + std::size_t n = 0; + rerotate_on_destroy rb(header, z, n); + + node_ptr z_left = NodeTraits::get_left(z); + node_ptr z_right = NodeTraits::get_right(z); + while(z_left || z_right){ + if(!z_right || (z_left && pcomp(z_left, z_right))){ + tree_algorithms::rotate_right(z, header); + } + else{ + tree_algorithms::rotate_left(z, header); + } + ++n; + z_left = NodeTraits::get_left(z); + z_right = NodeTraits::get_right(z); + } + rb.release(); + } + + template<class NodePtrPriorityCompare> + static void rebalance_check_and_commit + (const node_ptr & h, const node_ptr & new_node, NodePtrPriorityCompare pcomp, insert_commit_data &commit_data) + { + rebalance_after_insertion_check(h, commit_data.node, new_node, pcomp, commit_data.rotations); + //No-throw + tree_algorithms::insert_unique_commit(h, new_node, commit_data); + rebalance_after_insertion_commit(h, new_node, commit_data.rotations); + } + + + template<class Key, class KeyNodePriorityCompare> + static void rebalance_after_insertion_check + (const const_node_ptr &header, const const_node_ptr & up, const Key &k + , KeyNodePriorityCompare pcomp, std::size_t &num_rotations) + { + const_node_ptr upnode(up); + //First check rotations since pcomp can throw + num_rotations = 0; + std::size_t n = 0; + while(upnode != header && pcomp(k, upnode)){ + ++n; + upnode = NodeTraits::get_parent(upnode); + } + num_rotations = n; + } + + static void rebalance_after_insertion_commit(const node_ptr & header, const node_ptr & p, std::size_t n) + { + // Now execute n rotations + for( node_ptr p_parent = NodeTraits::get_parent(p) + ; n-- + ; p_parent = NodeTraits::get_parent(p)){ + //Check if left child + if(p == NodeTraits::get_left(p_parent)){ + tree_algorithms::rotate_right(p_parent, header); + } + else{ //Right child + tree_algorithms::rotate_left(p_parent, header); + } + } + } + + template<class NodePtrPriorityCompare> + static bool check_invariant(const const_node_ptr & header, NodePtrPriorityCompare pcomp) + { + node_ptr beg = begin_node(header); + node_ptr end = end_node(header); + + while(beg != end){ + node_ptr p = NodeTraits::get_parent(beg); + if(p != header){ + if(pcomp(beg, p)) + return false; + } + beg = next_node(beg); + } + return true; + } + + /// @endcond +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_TREAP_ALGORITHMS_HPP diff --git a/src/third_party/boost/boost/intrusive/treap_set.hpp b/src/third_party/boost/boost/intrusive/treap_set.hpp new file mode 100644 index 00000000000..01dfcd8b30f --- /dev/null +++ b/src/third_party/boost/boost/intrusive/treap_set.hpp @@ -0,0 +1,2581 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2007-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_TRIE_SET_HPP +#define BOOST_INTRUSIVE_TRIE_SET_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/treap.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <boost/move/move.hpp> +#include <iterator> + +namespace boost { +namespace intrusive { + +//! The class template treap_set is an intrusive container, that mimics most of +//! the interface of std::set as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<>, +//! \c compare<> and \c priority_compare<> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class treap_set_impl +{ + /// @cond + typedef treap_impl<Config> tree_type; + //! This class is + //! movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_set_impl) + + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::priority_compare priority_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare object throws. + treap_set_impl( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, pcmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty treap_set and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is std::distance(last, first). + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare object throws. + template<class Iterator> + treap_set_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : tree_(true, b, e, cmp, pcmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + treap_set_impl(BOOST_RV_REF(treap_set_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + treap_set_impl& operator=(BOOST_RV_REF(treap_set_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the treap_set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~treap_set_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns an iterator pointing to the highest priority object of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator top() + { return tree_.top(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree.. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator top() const + { return this->ctop(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree.. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator ctop() const + { return tree_.ctop(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the highest priority object of the + //! reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rtop() + { return tree_.rtop(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority objec + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rtop() const + { return tree_.crtop(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority object + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crtop() const + { return tree_.crtop(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of treap_set. + //! + //! <b>Effects</b>: Returns a const reference to the treap_set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static treap_set_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<treap_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &treap_set_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of treap_set. + //! + //! <b>Effects</b>: Returns a const reference to the treap_set associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const treap_set_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<treap_set_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &treap_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of set. + //! + //! <b>Effects</b>: Returns a reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static treap_set_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<treap_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &treap_set_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of set. + //! + //! <b>Effects</b>: Returns a const reference to the set associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Logarithmic. + static const treap_set_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<treap_set_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &treap_set_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the priority_compare object used by the treap_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If priority_compare copy-constructor throws. + priority_compare priority_comp() const + { return tree_.priority_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the treap_set. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two sets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(treap_set_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const treap_set_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to inserts value into the treap_set. + //! + //! <b>Returns</b>: If the value + //! is not already present inserts it and returns a pair containing the + //! iterator to the new value and true. If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare ordering function throw. + //! Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert(reference value) + { return tree_.insert_unique(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to to insert x into the treap_set, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the + //! new element was inserted into the treap_set. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare ordering + //! functions throw. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_unique(hint, value); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. + //! key_value_pcomp must be a comparison function that induces + //! the same strict weak ordering as priority_compare. The difference is that + //! key_value_pcomp and key_value_comp compare an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the treap_set, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average complexity is at most logarithmic. + //! + //! <b>Throws</b>: If key_value_comp or key_value_pcomp ordering function throw. + //! Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that + //! part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This gives a total + //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the treap_set. + template<class KeyType, class KeyValueCompare, class KeyValuePriorityCompare> + std::pair<iterator, bool> insert_check + ( const KeyType &key, KeyValueCompare key_value_comp, KeyValuePriorityCompare key_value_pcomp + , insert_commit_data &commit_data) + { return tree_.insert_unique_check(key, key_value_comp, key_value_pcomp, commit_data); } + + //! <b>Requires</b>: key_value_comp must be a comparison function that induces + //! the same strict weak ordering as value_compare. + //! key_value_pcomp must be a comparison function that induces + //! the same strict weak ordering as priority_compare. The difference is that + //! key_value_pcomp and key_value_comp compare an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the treap_set, using + //! a user provided key instead of the value itself, using "hint" + //! as a hint to where it will be inserted. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Logarithmic in general, but it's amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If key_value_comp or key_value_pcomp ordering function throw. + //! Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! constructing that is used to impose the order is much cheaper to construct + //! than the value_type and this function offers the possibility to use that key + //! to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. This can give a total + //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the treap_set. + template<class KeyType, class KeyValueCompare, class KeyValuePriorityCompare> + std::pair<iterator, bool> insert_check + ( const_iterator hint, const KeyType &key + , KeyValueCompare key_value_comp, KeyValuePriorityCompare key_value_pcomp + , insert_commit_data &commit_data) + { return tree_.insert_unique_check(hint, key, key_value_comp, key_value_pcomp, commit_data); } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the treap_set between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the treap_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + iterator insert_commit(reference value, const insert_commit_data &commit_data) + { return tree_.insert_unique_commit(value, commit_data); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the treap_set. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare ordering function + //! throw. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_unique(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate. "value" must not be equal to any + //! inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the treap before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" treap ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be greater than + //! any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the treap in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key treap ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be less + //! than any inserted key according to the predicate. + //! + //! <b>Effects</b>: Inserts x into the treap in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key treap ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size()) + this->count(value)). + //! + //! <b>Throws</b>: If internal value_compare or priority_compare + //! ordering functions throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp or internal priority_compare + //! ordering functions throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). Basic guarantee. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp or internal priority_compare ordering functions throw. + //! Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.find(value) != end(); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp) != end(); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! treap_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! treap_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a treap_set/treap_multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { tree_.rebalance(); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return tree_.rebalance_subtree(root); } + + //! <b>Returns</b>: The balance factor (alpha) used in this tree + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + float balance_factor() const + { return tree_.balance_factor(); } + + //! <b>Requires</b>: new_alpha must be a value between 0.5 and 1.0 + //! + //! <b>Effects</b>: Establishes a new balance factor (alpha) and rebalances + //! the tree if the new balance factor is stricter (less) than the old factor. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + void balance_factor(float new_alpha) + { tree_.balance_factor(new_alpha); } + + /// @cond + friend bool operator==(const treap_set_impl &x, const treap_set_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const treap_set_impl &x, const treap_set_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y) +#else +(const treap_set_impl<Config> &x, const treap_set_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y) +#else +(const treap_set_impl<Config> &x, const treap_set_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y) +#else +(const treap_set_impl<Config> &x, const treap_set_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y) +#else +(const treap_set_impl<Config> &x, const treap_set_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(treap_set_impl<T, Options...> &x, treap_set_impl<T, Options...> &y) +#else +(treap_set_impl<Config> &x, treap_set_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c treap_set that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_treap_set +{ + /// @cond + typedef treap_set_impl + < typename make_treap_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class treap_set + : public make_treap_set<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_treap_set + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_set) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::priority_compare priority_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + treap_set( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, pcmp, v_traits) + {} + + template<class Iterator> + treap_set( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, pcmp, v_traits) + {} + + treap_set(BOOST_RV_REF(treap_set) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + treap_set& operator=(BOOST_RV_REF(treap_set) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static treap_set &container_from_end_iterator(iterator end_iterator) + { return static_cast<treap_set &>(Base::container_from_end_iterator(end_iterator)); } + + static const treap_set &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const treap_set &>(Base::container_from_end_iterator(end_iterator)); } + + static treap_set &container_from_iterator(iterator it) + { return static_cast<treap_set &>(Base::container_from_iterator(it)); } + + static const treap_set &container_from_iterator(const_iterator it) + { return static_cast<const treap_set &>(Base::container_from_iterator(it)); } +}; + +#endif + +//! The class template treap_multiset is an intrusive container, that mimics most of +//! the interface of std::treap_multiset as described in the C++ standard. +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<>, +//! \c compare<> and \c priority_compare<> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class treap_multiset_impl +{ + /// @cond + typedef treap_impl<Config> tree_type; + + BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_multiset_impl) + typedef tree_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::value_compare value_compare; + typedef typename implementation_defined::priority_compare priority_compare; + typedef typename implementation_defined::key_compare key_compare; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::reverse_iterator reverse_iterator; + typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + static const bool constant_time_size = Config::constant_time_size; + + /// @cond + private: + tree_type tree_; + /// @endcond + + public: + //! <b>Effects</b>: Constructs an empty treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor of the value_compare/priority_compare objects throw. + treap_multiset_impl( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : tree_(cmp, pcmp, v_traits) + {} + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. + //! cmp must be a comparison function that induces a strict weak ordering. + //! + //! <b>Effects</b>: Constructs an empty treap_multiset and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using + //! comp and otherwise N * log N, where N is the distance between first and last + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor/operator() of the value_compare/priority_compare objects throw. + template<class Iterator> + treap_multiset_impl( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : tree_(false, b, e, cmp, pcmp, v_traits) + {} + + //! <b>Effects</b>: to-do + //! + treap_multiset_impl(BOOST_RV_REF(treap_multiset_impl) x) + : tree_(::boost::move(x.tree_)) + {} + + //! <b>Effects</b>: to-do + //! + treap_multiset_impl& operator=(BOOST_RV_REF(treap_multiset_impl) x) + { tree_ = ::boost::move(x.tree_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the treap_multiset + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + ~treap_multiset_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return tree_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return tree_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return tree_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return tree_.cend(); } + + //! <b>Effects</b>: Returns an iterator pointing to the highest priority object of the tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator top() + { return tree_.top(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree.. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator top() const + { return this->ctop(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree.. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator ctop() const + { return tree_.ctop(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the + //! reversed treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rbegin() + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rbegin() const + { return tree_.rbegin(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning + //! of the reversed treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crbegin() const + { return tree_.crbegin(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the end + //! of the reversed treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rend() + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rend() const + { return tree_.rend(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end + //! of the reversed treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crend() const + { return tree_.crend(); } + + //! <b>Effects</b>: Returns a reverse_iterator pointing to the highest priority object of the + //! reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + reverse_iterator rtop() + { return tree_.rtop(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority objec + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator rtop() const + { return tree_.crtop(); } + + //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority object + //! of the reversed tree. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_reverse_iterator crtop() const + { return tree_.crtop(); } + + //! <b>Precondition</b>: end_iterator must be a valid end iterator + //! of treap_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the treap_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static treap_multiset_impl &container_from_end_iterator(iterator end_iterator) + { + return *detail::parent_from_member<treap_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &treap_multiset_impl::tree_); + } + + //! <b>Precondition</b>: end_iterator must be a valid end const_iterator + //! of treap_multiset. + //! + //! <b>Effects</b>: Returns a const reference to the treap_multiset associated to the end iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const treap_multiset_impl &container_from_end_iterator(const_iterator end_iterator) + { + return *detail::parent_from_member<treap_multiset_impl, tree_type> + ( &tree_type::container_from_end_iterator(end_iterator) + , &treap_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static treap_multiset_impl &container_from_iterator(iterator it) + { + return *detail::parent_from_member<treap_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &treap_multiset_impl::tree_); + } + + //! <b>Precondition</b>: it must be a valid const_iterator of multiset. + //! + //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + static const treap_multiset_impl &container_from_iterator(const_iterator it) + { + return *detail::parent_from_member<treap_multiset_impl, tree_type> + ( &tree_type::container_from_iterator(it) + , &treap_multiset_impl::tree_); + } + + //! <b>Effects</b>: Returns the key_compare object used by the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_compare copy-constructor throws. + key_compare key_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the value_compare object used by the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_compare copy-constructor throws. + value_compare value_comp() const + { return tree_.value_comp(); } + + //! <b>Effects</b>: Returns the priority_compare object used by the treap_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If priority_compare copy-constructor throws. + priority_compare priority_comp() const + { return tree_.priority_comp(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return tree_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the treap_multiset. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if, + //! constant-time size option is enabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return tree_.size(); } + + //! <b>Effects</b>: Swaps the contents of two treap_multisets. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison functor + //! found using ADL throws. Strong guarantee. + void swap(treap_multiset_impl& other) + { tree_.swap(other.tree_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes equivalent to the original nodes. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. Copies the predicate from the source container. + //! + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const treap_multiset_impl &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the treap_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Average complexity for insert element is at + //! most logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare ordering + //! function throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(reference value) + { return tree_.insert_equal(value); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts x into the treap_multiset, using pos as a hint to + //! where it will be inserted. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Logarithmic in general, but it is amortized + //! constant time if t is inserted immediately before hint. + //! + //! <b>Throws</b>: If internal value_compare or priority_compare ordering functions throw. + //! Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(const_iterator hint, reference value) + { return tree_.insert_equal(hint, value); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Inserts a range into the treap_multiset. + //! + //! <b>Returns</b>: An iterator that points to the position where the new + //! element was inserted. + //! + //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the + //! size of the range. However, it is linear in N if the range is already sorted + //! by value_comp(). + //! + //! <b>Throws</b>: If internal value_compare or priority_compare ordering functions throw. + //! Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { tree_.insert_equal(b, e); } + + //! <b>Requires</b>: value must be an lvalue, "pos" must be + //! a valid iterator (or end) and must be the succesor of value + //! once inserted according to the predicate + //! + //! <b>Effects</b>: Inserts x into the treap before "pos". + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if "pos" is not + //! the successor of "value" treap ordering invariant will be broken. + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + iterator insert_before(const_iterator pos, reference value) + { return tree_.insert_before(pos, value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be no less + //! than the greatest inserted key. + //! + //! <b>Effects</b>: Inserts x into the treap in the last position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! less than the greatest inserted key treap ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_back(reference value) + { tree_.push_back(value); } + + //! <b>Requires</b>: value must be an lvalue, and it must be no greater + //! than the minimum inserted key + //! + //! <b>Effects</b>: Inserts x into the treap in the first position. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: This function does not check preconditions so if value is + //! greater than the minimum inserted key treap ordering invariant will be broken. + //! This function is slightly more efficient than using "insert_before". + //! This is a low-level function to be used only for performance reasons + //! by advanced users. + void push_front(reference value) + { tree_.push_front(value); } + + //! <b>Effects</b>: Erases the element pointed to by pos. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator i) + { return tree_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + iterator erase(const_iterator b, const_iterator e) + { return tree_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare or priority_compare ordering + //! functiona throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return tree_.erase(value); } + + //! <b>Effects</b>: Erases all the elements that compare equal with + //! the given key and the given comparison functor. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp or internal priority_compare ordering functions throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyValueCompare> + size_type erase(const KeyType& key, KeyValueCompare comp + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase(key, comp); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased element. + //! + //! <b>Effects</b>: Erases the element pointed to by pos. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average complexity for erase element is constant time. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Strong guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Returns</b>: An iterator to the element after the erased elements. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average complexity for erase range is at most + //! O(log(size() + N)), where N is the number of elements in the range. + //! + //! <b>Throws</b>: If the internal priority_compare function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(value)). + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "comp". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: O(log(size() + this->count(key, comp)). + //! + //! <b>Throws</b>: If comp or internal priority_compare ordering functions throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyValueCompare, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 + /// @endcond + ) + { return tree_.erase_and_dispose(key, comp, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return tree_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + size_type count(const_reference value) const + { return tree_.count(value); } + + //! <b>Effects</b>: Returns the number of contained elements with the same key + //! compared with the given comparison functor. + //! + //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal + //! to number of objects with the given key. + //! + //! <b>Throws</b>: If comp ordering function throws. + template<class KeyType, class KeyValueCompare> + size_type count(const KeyType& key, KeyValueCompare comp) const + { return tree_.count(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator lower_bound(const_reference value) + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator lower_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns a const iterator to the first element whose + //! key is not less than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator lower_bound(const_reference value) const + { return tree_.lower_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is not less than k or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.lower_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator upper_bound(const_reference value) + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator upper_bound(const KeyType& key, KeyValueCompare comp) + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Returns an iterator to the first element whose + //! key is greater than k or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator upper_bound(const_reference value) const + { return tree_.upper_bound(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Returns a const_iterator to the first element whose + //! key according to the comparison functor is greater than key or + //! end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const + { return tree_.upper_bound(key, comp); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + iterator find(const_reference value) + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + iterator find(const KeyType& key, KeyValueCompare comp) + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + const_iterator find(const_reference value) const + { return tree_.find(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" according to the comparison functor or end() if that element + //! does not exist. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + const_iterator find(const KeyType& key, KeyValueCompare comp) const + { return tree_.find(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp) + { return tree_.equal_range(key, comp); } + + //! <b>Effects</b>: Finds a range containing all elements whose key is k or + //! an empty range that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If the internal value_compare ordering function throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return tree_.equal_range(value); } + + //! <b>Requires</b>: comp must imply the same element order as + //! value_compare. Usually key is the part of the value_type + //! that is used in the ordering functor. + //! + //! <b>Effects</b>: Finds a range containing all elements whose key is k + //! according to the comparison functor or an empty range + //! that indicates the position where those elements would be + //! if they there is no elements with key k. + //! + //! <b>Complexity</b>: Logarithmic. + //! + //! <b>Throws</b>: If comp ordering function throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyValueCompare> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyValueCompare comp) const + { return tree_.equal_range(key, comp); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_multiset + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static iterator s_iterator_to(reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! treap_multiset that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_iterator s_iterator_to(const_reference value) + { return tree_type::s_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_multiset + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator iterator_to(reference value) + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the + //! treap_multiset that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator iterator_to(const_reference value) const + { return tree_.iterator_to(value); } + + //! <b>Requires</b>: value shall not be in a treap_multiset/treap_multiset. + //! + //! <b>Effects</b>: init_node puts the hook of a value in a well-known default + //! state. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Note</b>: This function puts the hook in the well-known default state + //! used by auto_unlink and safe hooks. + static void init_node(reference value) + { tree_type::init_node(value); } + + //! <b>Effects</b>: Unlinks the leftmost node from the tree. + //! + //! <b>Complexity</b>: Average complexity is constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function breaks the tree and the tree can + //! only be used for more unlink_leftmost_without_rebalance calls. + //! This function is normally used to achieve a step by step + //! controlled destruction of the tree. + pointer unlink_leftmost_without_rebalance() + { return tree_.unlink_leftmost_without_rebalance(); } + + //! <b>Requires</b>: replace_this must be a valid iterator of *this + //! and with_this must not be inserted in any tree. + //! + //! <b>Effects</b>: Replaces replace_this in its position in the + //! tree with with_this. The tree does not need to be rebalanced. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This function will break container ordering invariants if + //! with_this is not equivalent to *replace_this according to the + //! ordering rules. This function is faster than erasing and inserting + //! the node, since no rebalancing or comparison is needed. + void replace_node(iterator replace_this, reference with_this) + { tree_.replace_node(replace_this, with_this); } + + //! <b>Effects</b>: Rebalances the tree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear. + void rebalance() + { tree_.rebalance(); } + + //! <b>Requires</b>: old_root is a node of a tree. + //! + //! <b>Effects</b>: Rebalances the subtree rooted at old_root. + //! + //! <b>Returns</b>: The new root of the subtree. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + iterator rebalance_subtree(iterator root) + { return tree_.rebalance_subtree(root); } + + //! <b>Returns</b>: The balance factor (alpha) used in this tree + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Constant. + float balance_factor() const + { return tree_.balance_factor(); } + + //! <b>Requires</b>: new_alpha must be a value between 0.5 and 1.0 + //! + //! <b>Effects</b>: Establishes a new balance factor (alpha) and rebalances + //! the tree if the new balance factor is stricter (less) than the old factor. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Complexity</b>: Linear to the elements in the subtree. + void balance_factor(float new_alpha) + { tree_.balance_factor(new_alpha); } + + /// @cond + friend bool operator==(const treap_multiset_impl &x, const treap_multiset_impl &y) + { return x.tree_ == y.tree_; } + + friend bool operator<(const treap_multiset_impl &x, const treap_multiset_impl &y) + { return x.tree_ < y.tree_; } + /// @endcond +}; + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator!= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y) +#else +(const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y) +#endif +{ return !(x == y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator> +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y) +#else +(const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y) +#endif +{ return y < x; } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator<= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y) +#else +(const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y) +#endif +{ return !(y < x); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline bool operator>= +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y) +#else +(const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y) +#endif +{ return !(x < y); } + +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +inline void swap +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +(treap_multiset_impl<T, Options...> &x, treap_multiset_impl<T, Options...> &y) +#else +(treap_multiset_impl<Config> &x, treap_multiset_impl<Config> &y) +#endif +{ x.swap(y); } + +//! Helper metafunction to define a \c treap_multiset that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none> +#endif +struct make_treap_multiset +{ + /// @cond + typedef treap_multiset_impl + < typename make_treap_opt<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4> +#else +template<class T, class ...Options> +#endif +class treap_multiset + : public make_treap_multiset<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + typedef typename make_treap_multiset + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type Base; + //Movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_multiset) + + public: + typedef typename Base::value_compare value_compare; + typedef typename Base::priority_compare priority_compare; + typedef typename Base::value_traits value_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); + + treap_multiset( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : Base(cmp, pcmp, v_traits) + {} + + template<class Iterator> + treap_multiset( Iterator b, Iterator e + , const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) + : Base(b, e, cmp, pcmp, v_traits) + {} + + treap_multiset(BOOST_RV_REF(treap_multiset) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + treap_multiset& operator=(BOOST_RV_REF(treap_multiset) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } + + static treap_multiset &container_from_end_iterator(iterator end_iterator) + { return static_cast<treap_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static const treap_multiset &container_from_end_iterator(const_iterator end_iterator) + { return static_cast<const treap_multiset &>(Base::container_from_end_iterator(end_iterator)); } + + static treap_multiset &container_from_iterator(iterator it) + { return static_cast<treap_multiset &>(Base::container_from_iterator(it)); } + + static const treap_multiset &container_from_iterator(const_iterator it) + { return static_cast<const treap_multiset &>(Base::container_from_iterator(it)); } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_TRIE_SET_HPP diff --git a/src/third_party/boost/boost/intrusive/trivial_value_traits.hpp b/src/third_party/boost/boost/intrusive/trivial_value_traits.hpp new file mode 100644 index 00000000000..c924022608f --- /dev/null +++ b/src/third_party/boost/boost/intrusive/trivial_value_traits.hpp @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP +#define BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP + +#include <boost/intrusive/link_mode.hpp> +#include <boost/intrusive/pointer_traits.hpp> + +namespace boost { +namespace intrusive { + +//!This value traits template is used to create value traits +//!from user defined node traits where value_traits::value_type and +//!node_traits::node should be equal +template<class NodeTraits, link_mode_type LinkMode = normal_link> +struct trivial_value_traits +{ + typedef NodeTraits node_traits; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef typename node_traits::node value_type; + typedef node_ptr pointer; + typedef const_node_ptr const_pointer; + static const link_mode_type link_mode = LinkMode; + static node_ptr to_node_ptr (value_type &value) + { return pointer_traits<node_ptr>::pointer_to(value); } + static const_node_ptr to_node_ptr (const value_type &value) + { return pointer_traits<const_node_ptr>::pointer_to(value); } + static const pointer & to_value_ptr(const node_ptr &n) { return n; } + static const const_pointer &to_value_ptr(const const_node_ptr &n) { return n; } +}; + +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP diff --git a/src/third_party/boost/boost/intrusive/unordered_set.hpp b/src/third_party/boost/boost/intrusive/unordered_set.hpp new file mode 100644 index 00000000000..6407fcfa451 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/unordered_set.hpp @@ -0,0 +1,2115 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_UNORDERED_SET_HPP +#define BOOST_INTRUSIVE_UNORDERED_SET_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/intrusive/hashtable.hpp> +#include <boost/move/move.hpp> +#include <iterator> + + +namespace boost { +namespace intrusive { + +//! The class template unordered_set is an intrusive container, that mimics most of +//! the interface of std::tr1::unordered_set as described in the C++ TR1. +//! +//! unordered_set is a semi-intrusive container: each object to be stored in the +//! container must contain a proper hook, but the container also needs +//! additional auxiliary memory to work: unordered_set needs a pointer to an array +//! of type `bucket_type` to be passed in the constructor. This bucket array must +//! have at least the same lifetime as the container. This makes the use of +//! unordered_set more complicated than purely intrusive containers. +//! `bucket_type` is default-constructible, copyable and assignable +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<> +//! \c bucket_traits<>, \c power_2_buckets<> and \c cache_begin<>. +//! +//! unordered_set only provides forward iterators but it provides 4 iterator types: +//! iterator and const_iterator to navigate through the whole container and +//! local_iterator and const_local_iterator to navigate through the values +//! stored in a single bucket. Local iterators are faster and smaller. +//! +//! It's not recommended to use non constant-time size unordered_sets because several +//! key functions, like "empty()", become non-constant time functions. Non +//! constant-time size unordered_sets are mainly provided to support auto-unlink hooks. +//! +//! unordered_set, unlike std::unordered_set, does not make automatic rehashings nor +//! offers functions related to a load factor. Rehashing can be explicitly requested +//! and the user must provide a new bucket array that will be used from that moment. +//! +//! Since no automatic rehashing is done, iterators are never invalidated when +//! inserting or erasing elements. Iterators are only invalidated when rehasing. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class unordered_set_impl +{ + /// @cond + private: + typedef hashtable_impl<Config> table_type; + + //! This class is + //! movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_set_impl) + + typedef table_type implementation_defined; + /// @endcond + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::bucket_traits bucket_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::key_type key_type; + typedef typename implementation_defined::key_equal key_equal; + typedef typename implementation_defined::hasher hasher; + typedef typename implementation_defined::bucket_type bucket_type; + typedef typename implementation_defined::bucket_ptr bucket_ptr; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::local_iterator local_iterator; + typedef typename implementation_defined::const_local_iterator const_local_iterator; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + /// @cond + private: + table_type table_; + /// @endcond + + public: + + //! <b>Requires</b>: buckets must not be being used by any other resource. + //! + //! <b>Effects</b>: Constructs an empty unordered_set_impl, storing a reference + //! to the bucket array and copies of the hasher and equal functors. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor or invocation of Hash or Equal throws. + //! + //! <b>Notes</b>: buckets array must be disposed only after + //! *this is disposed. + unordered_set_impl( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : table_(b_traits, hash_func, equal_func, v_traits) + {} + + //! <b>Requires</b>: buckets must not be being used by any other resource + //! and Dereferencing iterator must yield an lvalue of type value_type. + //! + //! <b>Effects</b>: Constructs an empty unordered_set and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: If N is std::distance(b, e): Average case is O(N) + //! (with a good hash function and with buckets_len >= N),worst case O(N2). + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor or invocation of hasher or key_equal throws. + //! + //! <b>Notes</b>: buckets array must be disposed only after + //! *this is disposed. + template<class Iterator> + unordered_set_impl( Iterator b + , Iterator e + , const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : table_(b_traits, hash_func, equal_func, v_traits) + { table_.insert_unique(b, e); } + + //! <b>Effects</b>: to-do + //! + unordered_set_impl(BOOST_RV_REF(unordered_set_impl) x) + : table_(::boost::move(x.table_)) + {} + + //! <b>Effects</b>: to-do + //! + unordered_set_impl& operator=(BOOST_RV_REF(unordered_set_impl) x) + { table_ = ::boost::move(x.table_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the unordered_set + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements in the unordered_set, if + //! it's a safe-mode or auto-unlink value. Otherwise constant. + //! + //! <b>Throws</b>: Nothing. + ~unordered_set_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the unordered_set. + //! + //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized + //! constant time with worst case (empty unordered_set) O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return table_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning + //! of the unordered_set. + //! + //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized + //! constant time with worst case (empty unordered_set) O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return table_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning + //! of the unordered_set. + //! + //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized + //! constant time with worst case (empty unordered_set) O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return table_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return table_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return table_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return table_.cend(); } + + //! <b>Effects</b>: Returns the hasher object used by the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If hasher copy-constructor throws. + hasher hash_function() const + { return table_.hash_function(); } + + //! <b>Effects</b>: Returns the key_equal object used by the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_equal copy-constructor throws. + key_equal key_eq() const + { return table_.key_eq(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: if constant-time size and cache_last options are disabled, + //! average constant time (worst case, with empty() == true: O(this->bucket_count()). + //! Otherwise constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return table_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the unordered_set. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if + //! constant-time size option is disabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return table_.size(); } + + //! <b>Requires</b>: the hasher and the equality function unqualified swap + //! call should not throw. + //! + //! <b>Effects</b>: Swaps the contents of two unordered_sets. + //! Swaps also the contained bucket array and equality and hasher functors. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison or hash functors + //! found using ADL throw. Basic guarantee. + void swap(unordered_set_impl& other) + { table_.swap(other.table_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes that compare equal and produce the same + //! hash than the original node. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. The hash function and the equality + //! predicate are copied from the source. + //! + //! If store_hash option is true, this method does not use the hash function. + //! + //! If any operation throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner or hasher throw or hash or equality predicate copying + //! throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const unordered_set_impl &src, Cloner cloner, Disposer disposer) + { table_.clone_from(src.table_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Tries to inserts value into the unordered_set. + //! + //! <b>Returns</b>: If the value + //! is not already present inserts it and returns a pair containing the + //! iterator to the new value and true. If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + std::pair<iterator, bool> insert(reference value) + { return table_.insert_unique(value); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Equivalent to this->insert(t) for each element in [b, e). + //! + //! <b>Complexity</b>: Average case O(N), where N is std::distance(b, e). + //! Worst case O(N*this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { table_.insert_unique(b, e); } + + //! <b>Requires</b>: "hasher" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hasher" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Checks if a value can be inserted in the unordered_set, using + //! a user provided key instead of the value itself. + //! + //! <b>Returns</b>: If there is an equivalent value + //! returns a pair containing an iterator to the already present value + //! and false. If the value can be inserted returns true in the returned + //! pair boolean and fills "commit_data" that is meant to be used with + //! the "insert_commit" function. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hasher or key_value_equal throw. Strong guarantee. + //! + //! <b>Notes</b>: This function is used to improve performance when constructing + //! a value_type is expensive: if there is an equivalent value + //! the constructed object must be discarded. Many times, the part of the + //! node that is used to impose the hash or the equality is much cheaper to + //! construct than the value_type and this function offers the possibility to + //! use that the part to check if the insertion will be successful. + //! + //! If the check is successful, the user can construct the value_type and use + //! "insert_commit" to insert the object in constant-time. + //! + //! "commit_data" remains valid for a subsequent "insert_commit" only if no more + //! objects are inserted or erased from the unordered_set. + //! + //! After a successful rehashing insert_commit_data remains valid. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<iterator, bool> insert_check + (const KeyType &key, KeyHasher hasher, KeyValueEqual key_value_equal, insert_commit_data &commit_data) + { return table_.insert_unique_check(key, hasher, key_value_equal, commit_data); } + + //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data + //! must have been obtained from a previous call to "insert_check". + //! No objects should have been inserted or erased from the unordered_set between + //! the "insert_check" that filled "commit_data" and the call to "insert_commit". + //! + //! <b>Effects</b>: Inserts the value in the unordered_set using the information obtained + //! from the "commit_data" that a previous "insert_check" filled. + //! + //! <b>Returns</b>: An iterator to the newly inserted object. + //! + //! <b>Complexity</b>: Constant time. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Notes</b>: This function has only sense if a "insert_check" has been + //! previously executed to fill "commit_data". No value should be inserted or + //! erased between the "insert_check" and "insert_commit" calls. + //! + //! After a successful rehashing insert_commit_data remains valid. + iterator insert_commit(reference value, const insert_commit_data &commit_data) + { return table_.insert_unique_commit(value, commit_data); } + + //! <b>Effects</b>: Erases the element pointed to by i. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased element. No destructors are called. + void erase(const_iterator i) + { table_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average case O(std::distance(b, e)), + //! worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void erase(const_iterator b, const_iterator e) + { table_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return table_.erase(value); } + + //! <b>Requires</b>: "hasher" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hasher" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Erases all the elements that have the same hash and + //! compare equal with the given key. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyHasher, class KeyValueEqual> + size_type erase(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) + { return table_.erase(key, hash_func, equal_func); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by i. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + void erase_and_dispose(const_iterator i, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0 + /// @endcond + ) + { table_.erase_and_dispose(i, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average case O(std::distance(b, e)), + //! worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { table_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return table_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "equal_func". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyHasher, class KeyValueEqual, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func, Disposer disposer) + { return table_.erase_and_dispose(key, hash_func, equal_func, disposer); } + + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return table_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all of the elements. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return table_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given value + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + size_type count(const_reference value) const + { return table_.find(value) != end(); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. + template<class KeyType, class KeyHasher, class KeyValueEqual> + size_type count(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const + { return table_.find(key, hash_func, equal_func) != end(); } + + //! <b>Effects</b>: Finds an iterator to the first element is equal to + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + iterator find(const_reference value) + { return table_.find(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the given hasher and equality functor or end() if + //! that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) + { return table_.find(key, hash_func, equal_func); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + const_iterator find(const_reference value) const + { return table_.find(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the given hasher and equality functor or end() if + //! that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + const_iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const + { return table_.find(key, hash_func, equal_func); } + + //! <b>Effects</b>: Returns a range containing all elements with values equivalent + //! to value. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return table_.equal_range(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns a range containing all elements with equivalent + //! keys. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(key, hash_func, hash_func)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or the equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<iterator,iterator> equal_range(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) + { return table_.equal_range(key, hash_func, equal_func); } + + //! <b>Effects</b>: Returns a range containing all elements with values equivalent + //! to value. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return table_.equal_range(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "equal_func" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "equal_func" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns a range containing all elements with equivalent + //! keys. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the hash_func or equal_func throw. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const + { return table_.equal_range(key, hash_func, equal_func); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the internal hash function throws. + iterator iterator_to(reference value) + { return table_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator belonging to the + //! unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the internal hash function throws. + const_iterator iterator_to(const_reference value) const + { return table_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static local_iterator s_local_iterator_to(reference value) + { return table_type::s_local_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to + //! the unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_local_iterator s_local_iterator_to(const_reference value) + { return table_type::s_local_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + local_iterator local_iterator_to(reference value) + { return table_.local_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to + //! the unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_local_iterator local_iterator_to(const_reference value) const + { return table_.local_iterator_to(value); } + + //! <b>Effects</b>: Returns the number of buckets passed in the constructor + //! or the last rehash function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + size_type bucket_count() const + { return table_.bucket_count(); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns the number of elements in the nth bucket. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + size_type bucket_size(size_type n) const + { return table_.bucket_size(n); } + + //! <b>Effects</b>: Returns the index of the bucket in which elements + //! with keys equivalent to k would be found, if any such element existed. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the hash functor throws. + //! + //! <b>Note</b>: the return value is in the range [0, this->bucket_count()). + size_type bucket(const value_type& k) const + { return table_.bucket(k); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! <b>Effects</b>: Returns the index of the bucket in which elements + //! with keys equivalent to k would be found, if any such element existed. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If hash_func throws. + //! + //! <b>Note</b>: the return value is in the range [0, this->bucket_count()). + template<class KeyType, class KeyHasher> + size_type bucket(const KeyType& k, KeyHasher hash_func) const + { return table_.bucket(k, hash_func); } + + //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor + //! or the last rehash function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bucket_ptr bucket_pointer() const + { return table_.bucket_pointer(); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + local_iterator begin(size_type n) + { return table_.begin(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator begin(size_type n) const + { return table_.begin(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator cbegin(size_type n) const + { return table_.cbegin(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + local_iterator end(size_type n) + { return table_.end(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator end(size_type n) const + { return table_.end(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator cend(size_type n) const + { return table_.cend(n); } + + //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array + //! or the same as the old bucket array. new_size is the length of the + //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer() + //! n can be bigger or smaller than this->bucket_count(). + //! + //! <b>Effects</b>: Updates the internal reference with the new bucket erases + //! the values from the old bucket and inserts then in the new one. + //! + //! If store_hash option is true, this method does not use the hash function. + //! + //! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic. + //! + //! <b>Throws</b>: If the hasher functor throws. Basic guarantee. + void rehash(const bucket_traits &new_bucket_traits) + { table_.rehash(new_bucket_traits); } + + //! <b>Requires</b>: + //! + //! <b>Effects</b>: + //! + //! <b>Complexity</b>: + //! + //! <b>Throws</b>: + //! + //! <b>Note</b>: this method is only available if incremental<true> option is activated. + bool incremental_rehash(bool grow = true) + { return table_.incremental_rehash(grow); } + + //! <b>Note</b>: this method is only available if incremental<true> option is activated. + bool incremental_rehash(const bucket_traits &new_bucket_traits) + { return table_.incremental_rehash(new_bucket_traits); } + + //! <b>Requires</b>: + //! + //! <b>Effects</b>: + //! + //! <b>Complexity</b>: + //! + //! <b>Throws</b>: + size_type split_count() const + { return table_.split_count(); } + + //! <b>Effects</b>: Returns the nearest new bucket count optimized for + //! the container that is bigger than n. This suggestion can be used + //! to create bucket arrays with a size that will usually improve + //! container's performance. If such value does not exist, the + //! higher possible value is returned. + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static size_type suggested_upper_bucket_count(size_type n) + { return table_type::suggested_upper_bucket_count(n); } + + //! <b>Effects</b>: Returns the nearest new bucket count optimized for + //! the container that is smaller than n. This suggestion can be used + //! to create bucket arrays with a size that will usually improve + //! container's performance. If such value does not exist, the + //! lower possible value is returned. + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static size_type suggested_lower_bucket_count(size_type n) + { return table_type::suggested_lower_bucket_count(n); } +}; + +//! Helper metafunction to define an \c unordered_set that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none + , class O5 = none, class O6 = none + , class O7 = none, class O8 = none + , class O9 = none, class O10= none + > +#endif +struct make_unordered_set +{ + /// @cond + typedef unordered_set_impl + < typename make_hashtable_opt + <T, true, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10> +#else +template<class T, class ...Options> +#endif +class unordered_set + : public make_unordered_set<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type +{ + typedef typename make_unordered_set + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type Base; + + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value)); + BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_set) + + public: + typedef typename Base::value_traits value_traits; + typedef typename Base::bucket_traits bucket_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + typedef typename Base::bucket_ptr bucket_ptr; + typedef typename Base::size_type size_type; + typedef typename Base::hasher hasher; + typedef typename Base::key_equal key_equal; + + unordered_set ( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : Base(b_traits, hash_func, equal_func, v_traits) + {} + + template<class Iterator> + unordered_set ( Iterator b + , Iterator e + , const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : Base(b, e, b_traits, hash_func, equal_func, v_traits) + {} + + unordered_set(BOOST_RV_REF(unordered_set) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + unordered_set& operator=(BOOST_RV_REF(unordered_set) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } +}; + +#endif + + +//! The class template unordered_multiset is an intrusive container, that mimics most of +//! the interface of std::tr1::unordered_multiset as described in the C++ TR1. +//! +//! unordered_multiset is a semi-intrusive container: each object to be stored in the +//! container must contain a proper hook, but the container also needs +//! additional auxiliary memory to work: unordered_multiset needs a pointer to an array +//! of type `bucket_type` to be passed in the constructor. This bucket array must +//! have at least the same lifetime as the container. This makes the use of +//! unordered_multiset more complicated than purely intrusive containers. +//! `bucket_type` is default-constructible, copyable and assignable +//! +//! The template parameter \c T is the type to be managed by the container. +//! The user can specify additional options and if no options are provided +//! default options are used. +//! +//! The container supports the following options: +//! \c base_hook<>/member_hook<>/value_traits<>, +//! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<> +//! \c bucket_traits<>, \c power_2_buckets<> and \c cache_begin<>. +//! +//! unordered_multiset only provides forward iterators but it provides 4 iterator types: +//! iterator and const_iterator to navigate through the whole container and +//! local_iterator and const_local_iterator to navigate through the values +//! stored in a single bucket. Local iterators are faster and smaller. +//! +//! It's not recommended to use non constant-time size unordered_multisets because several +//! key functions, like "empty()", become non-constant time functions. Non +//! constant-time size unordered_multisets are mainly provided to support auto-unlink hooks. +//! +//! unordered_multiset, unlike std::unordered_set, does not make automatic rehashings nor +//! offers functions related to a load factor. Rehashing can be explicitly requested +//! and the user must provide a new bucket array that will be used from that moment. +//! +//! Since no automatic rehashing is done, iterators are never invalidated when +//! inserting or erasing elements. Iterators are only invalidated when rehasing. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) +template<class T, class ...Options> +#else +template<class Config> +#endif +class unordered_multiset_impl +{ + /// @cond + private: + typedef hashtable_impl<Config> table_type; + /// @endcond + + //Movable + BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset_impl) + + typedef table_type implementation_defined; + + public: + typedef typename implementation_defined::value_type value_type; + typedef typename implementation_defined::value_traits value_traits; + typedef typename implementation_defined::bucket_traits bucket_traits; + typedef typename implementation_defined::pointer pointer; + typedef typename implementation_defined::const_pointer const_pointer; + typedef typename implementation_defined::reference reference; + typedef typename implementation_defined::const_reference const_reference; + typedef typename implementation_defined::difference_type difference_type; + typedef typename implementation_defined::size_type size_type; + typedef typename implementation_defined::key_type key_type; + typedef typename implementation_defined::key_equal key_equal; + typedef typename implementation_defined::hasher hasher; + typedef typename implementation_defined::bucket_type bucket_type; + typedef typename implementation_defined::bucket_ptr bucket_ptr; + typedef typename implementation_defined::iterator iterator; + typedef typename implementation_defined::const_iterator const_iterator; + typedef typename implementation_defined::insert_commit_data insert_commit_data; + typedef typename implementation_defined::local_iterator local_iterator; + typedef typename implementation_defined::const_local_iterator const_local_iterator; + typedef typename implementation_defined::node_traits node_traits; + typedef typename implementation_defined::node node; + typedef typename implementation_defined::node_ptr node_ptr; + typedef typename implementation_defined::const_node_ptr const_node_ptr; + typedef typename implementation_defined::node_algorithms node_algorithms; + + /// @cond + private: + table_type table_; + /// @endcond + + public: + + //! <b>Requires</b>: buckets must not be being used by any other resource. + //! + //! <b>Effects</b>: Constructs an empty unordered_multiset, storing a reference + //! to the bucket array and copies of the hasher and equal functors. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor or invocation of Hash or Equal throws. + //! + //! <b>Notes</b>: buckets array must be disposed only after + //! *this is disposed. + unordered_multiset_impl ( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : table_(b_traits, hash_func, equal_func, v_traits) + {} + + //! <b>Requires</b>: buckets must not be being used by any other resource + //! and Dereferencing iterator must yield an lvalue of type value_type. + //! + //! <b>Effects</b>: Constructs an empty unordered_multiset and inserts elements from + //! [b, e). + //! + //! <b>Complexity</b>: If N is std::distance(b, e): Average case is O(N) + //! (with a good hash function and with buckets_len >= N),worst case O(N2). + //! + //! <b>Throws</b>: If value_traits::node_traits::node + //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) + //! or the copy constructor or invocation of hasher or key_equal throws. + //! + //! <b>Notes</b>: buckets array must be disposed only after + //! *this is disposed. + template<class Iterator> + unordered_multiset_impl ( Iterator b + , Iterator e + , const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : table_(b_traits, hash_func, equal_func, v_traits) + { table_.insert_equal(b, e); } + + //! <b>Effects</b>: to-do + //! + unordered_multiset_impl(BOOST_RV_REF(unordered_multiset_impl) x) + : table_(::boost::move(x.table_)) + {} + + //! <b>Effects</b>: to-do + //! + unordered_multiset_impl& operator=(BOOST_RV_REF(unordered_multiset_impl) x) + { table_ = ::boost::move(x.table_); return *this; } + + //! <b>Effects</b>: Detaches all elements from this. The objects in the unordered_multiset + //! are not deleted (i.e. no destructors are called). + //! + //! <b>Complexity</b>: Linear to the number of elements in the unordered_multiset, if + //! it's a safe-mode or auto-unlink value. Otherwise constant. + //! + //! <b>Throws</b>: Nothing. + ~unordered_multiset_impl() + {} + + //! <b>Effects</b>: Returns an iterator pointing to the beginning of the unordered_multiset. + //! + //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized + //! constant time with worst case (empty unordered_set) O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + iterator begin() + { return table_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning + //! of the unordered_multiset. + //! + //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized + //! constant time with worst case (empty unordered_set) O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + const_iterator begin() const + { return table_.begin(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the beginning + //! of the unordered_multiset. + //! + //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized + //! constant time with worst case (empty unordered_set) O(this->bucket_count()) + //! + //! <b>Throws</b>: Nothing. + const_iterator cbegin() const + { return table_.cbegin(); } + + //! <b>Effects</b>: Returns an iterator pointing to the end of the unordered_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + iterator end() + { return table_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator end() const + { return table_.end(); } + + //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_iterator cend() const + { return table_.cend(); } + + //! <b>Effects</b>: Returns the hasher object used by the unordered_set. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If hasher copy-constructor throws. + hasher hash_function() const + { return table_.hash_function(); } + + //! <b>Effects</b>: Returns the key_equal object used by the unordered_multiset. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If key_equal copy-constructor throws. + key_equal key_eq() const + { return table_.key_eq(); } + + //! <b>Effects</b>: Returns true if the container is empty. + //! + //! <b>Complexity</b>: if constant-time size and cache_last options are disabled, + //! average constant time (worst case, with empty() == true: O(this->bucket_count()). + //! Otherwise constant. + //! + //! <b>Throws</b>: Nothing. + bool empty() const + { return table_.empty(); } + + //! <b>Effects</b>: Returns the number of elements stored in the unordered_multiset. + //! + //! <b>Complexity</b>: Linear to elements contained in *this if + //! constant-time size option is disabled. Constant-time otherwise. + //! + //! <b>Throws</b>: Nothing. + size_type size() const + { return table_.size(); } + + //! <b>Requires</b>: the hasher and the equality function unqualified swap + //! call should not throw. + //! + //! <b>Effects</b>: Swaps the contents of two unordered_multisets. + //! Swaps also the contained bucket array and equality and hasher functors. + //! + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the swap() call for the comparison or hash functors + //! found using ADL throw. Basic guarantee. + void swap(unordered_multiset_impl& other) + { table_.swap(other.table_); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! Cloner should yield to nodes that compare equal and produce the same + //! hash than the original node. + //! + //! <b>Effects</b>: Erases all the elements from *this + //! calling Disposer::operator()(pointer), clones all the + //! elements from src calling Cloner::operator()(const_reference ) + //! and inserts them on *this. The hash function and the equality + //! predicate are copied from the source. + //! + //! If store_hash option is true, this method does not use the hash function. + //! + //! If any operation throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). + //! + //! <b>Complexity</b>: Linear to erased plus inserted elements. + //! + //! <b>Throws</b>: If cloner or hasher throw or hash or equality predicate copying + //! throws. Basic guarantee. + template <class Cloner, class Disposer> + void clone_from(const unordered_multiset_impl &src, Cloner cloner, Disposer disposer) + { table_.clone_from(src.table_, cloner, disposer); } + + //! <b>Requires</b>: value must be an lvalue + //! + //! <b>Effects</b>: Inserts value into the unordered_multiset. + //! + //! <b>Returns</b>: An iterator to the new inserted value. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + iterator insert(reference value) + { return table_.insert_equal(value); } + + //! <b>Requires</b>: Dereferencing iterator must yield an lvalue + //! of type value_type. + //! + //! <b>Effects</b>: Equivalent to this->insert(t) for each element in [b, e). + //! + //! <b>Complexity</b>: Average case is O(N), where N is the + //! size of the range. + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Does not affect the validity of iterators and references. + //! No copy-constructors are called. + template<class Iterator> + void insert(Iterator b, Iterator e) + { table_.insert_equal(b, e); } + + //! <b>Effects</b>: Erases the element pointed to by i. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased element. No destructors are called. + void erase(const_iterator i) + { table_.erase(i); } + + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! + //! <b>Complexity</b>: Average case O(std::distance(b, e)), + //! worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void erase(const_iterator b, const_iterator e) + { table_.erase(b, e); } + + //! <b>Effects</b>: Erases all the elements with the given value. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + size_type erase(const_reference value) + { return table_.erase(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Erases all the elements that have the same hash and + //! compare equal with the given key. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the hash_func or the equal_func functors throws. + //! Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class KeyType, class KeyHasher, class KeyValueEqual> + size_type erase(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) + { return table_.erase(key, hash_func, equal_func); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the element pointed to by i. + //! Disposer::operator()(pointer) is called for the removed element. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + void erase_and_dispose(const_iterator i, Disposer disposer + /// @cond + , typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0 + /// @endcond + ) + { table_.erase_and_dispose(i, disposer); } + + #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + template<class Disposer> + void erase_and_dispose(const_iterator i, Disposer disposer) + { this->erase_and_dispose(const_iterator(i), disposer); } + #endif + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases the range pointed to by b end e. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Complexity</b>: Average case O(std::distance(b, e)), + //! worst case O(this->size()). + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class Disposer> + void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { table_.erase_and_dispose(b, e, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given value. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return table_.erase_and_dispose(value, disposer); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements with the given key. + //! according to the comparison functor "equal_func". + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Returns</b>: The number of erased elements. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee. + //! + //! <b>Note</b>: Invalidates the iterators + //! to the erased elements. + template<class KeyType, class KeyHasher, class KeyValueEqual, class Disposer> + size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func, Disposer disposer) + { return table_.erase_and_dispose(key, hash_func, equal_func, disposer); } + + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + void clear() + { return table_.clear(); } + + //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. + //! + //! <b>Effects</b>: Erases all the elements of the container. + //! + //! <b>Complexity</b>: Linear to the number of elements on the container. + //! Disposer::operator()(pointer) is called for the removed elements. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: Invalidates the iterators (but not the references) + //! to the erased elements. No destructors are called. + template<class Disposer> + void clear_and_dispose(Disposer disposer) + { return table_.clear_and_dispose(disposer); } + + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + size_type count(const_reference value) const + { return table_.count(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns the number of contained elements with the given key + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + template<class KeyType, class KeyHasher, class KeyValueEqual> + size_type count(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const + { return table_.count(key, hash_func, equal_func); } + + //! <b>Effects</b>: Finds an iterator to the first element whose value is + //! "value" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + iterator find(const_reference value) + { return table_.find(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the given hasher and equality functor or end() if + //! that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) + { return table_.find(key, hash_func, equal_func); } + + //! <b>Effects</b>: Finds a const_iterator to the first element whose key is + //! "key" or end() if that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + const_iterator find(const_reference value) const + { return table_.find(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Finds an iterator to the first element whose key is + //! "key" according to the given hasher and equality functor or end() if + //! that element does not exist. + //! + //! <b>Complexity</b>: Average case O(1), worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + const_iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const + { return table_.find(key, hash_func, equal_func); } + + //! <b>Effects</b>: Returns a range containing all elements with values equivalent + //! to value. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + std::pair<iterator,iterator> equal_range(const_reference value) + { return table_.equal_range(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns a range containing all elements with equivalent + //! keys. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<iterator,iterator> equal_range + (const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) + { return table_.equal_range(key, hash_func, equal_func); } + + //! <b>Effects</b>: Returns a range containing all elements with values equivalent + //! to value. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + std::pair<const_iterator, const_iterator> + equal_range(const_reference value) const + { return table_.equal_range(value); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! "key_value_equal" must be a equality function that induces + //! the same equality as key_equal. The difference is that + //! "key_value_equal" compares an arbitrary key with the contained values. + //! + //! <b>Effects</b>: Returns a range containing all elements with equivalent + //! keys. Returns std::make_pair(this->end(), this->end()) if no such + //! elements exist. + //! + //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)). + //! Worst case O(this->size()). + //! + //! <b>Throws</b>: If the internal hasher or the equality functor throws. + //! + //! <b>Note</b>: This function is used when constructing a value_type + //! is expensive and the value_type can be compared with a cheaper + //! key type. Usually this key is part of the value_type. + template<class KeyType, class KeyHasher, class KeyValueEqual> + std::pair<const_iterator, const_iterator> + equal_range(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const + { return table_.equal_range(key, hash_func, equal_func); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid iterator belonging to the unordered_multiset + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the hash function throws. + iterator iterator_to(reference value) + { return table_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_multiset of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_iterator belonging to the + //! unordered_multiset that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the hash function throws. + const_iterator iterator_to(const_reference value) const + { return table_.iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static local_iterator s_local_iterator_to(reference value) + { return table_type::s_local_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to + //! the unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: This static function is available only if the <i>value traits</i> + //! is stateless. + static const_local_iterator s_local_iterator_to(const_reference value) + { return table_type::s_local_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set + //! that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + local_iterator local_iterator_to(reference value) + { return table_.local_iterator_to(value); } + + //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of + //! appropriate type. Otherwise the behavior is undefined. + //! + //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to + //! the unordered_set that points to the value + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + const_local_iterator local_iterator_to(const_reference value) const + { return table_.local_iterator_to(value); } + + //! <b>Effects</b>: Returns the number of buckets passed in the constructor + //! or the last rehash function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + size_type bucket_count() const + { return table_.bucket_count(); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns the number of elements in the nth bucket. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + size_type bucket_size(size_type n) const + { return table_.bucket_size(n); } + + //! <b>Effects</b>: Returns the index of the bucket in which elements + //! with keys equivalent to k would be found, if any such element existed. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the hash functor throws. + //! + //! <b>Note</b>: the return value is in the range [0, this->bucket_count()). + size_type bucket(const value_type& k) const + { return table_.bucket(k); } + + //! <b>Requires</b>: "hash_func" must be a hash function that induces + //! the same hash values as the stored hasher. The difference is that + //! "hash_func" hashes the given key instead of the value_type. + //! + //! <b>Effects</b>: Returns the index of the bucket in which elements + //! with keys equivalent to k would be found, if any such element existed. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: If the hash functor throws. + //! + //! <b>Note</b>: the return value is in the range [0, this->bucket_count()). + template<class KeyType, class KeyHasher> + size_type bucket(const KeyType& k, const KeyHasher &hash_func) const + { return table_.bucket(k, hash_func); } + + //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor + //! or the last rehash function. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + bucket_ptr bucket_pointer() const + { return table_.bucket_pointer(); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + local_iterator begin(size_type n) + { return table_.begin(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator begin(size_type n) const + { return table_.begin(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator cbegin(size_type n) const + { return table_.cbegin(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + local_iterator end(size_type n) + { return table_.end(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator end(size_type n) const + { return table_.end(n); } + + //! <b>Requires</b>: n is in the range [0, this->bucket_count()). + //! + //! <b>Effects</b>: Returns a const_local_iterator pointing to the end + //! of the sequence stored in the bucket n. + //! + //! <b>Complexity</b>: Constant. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range + //! containing all of the elements in the nth bucket. + const_local_iterator cend(size_type n) const + { return table_.cend(n); } + + //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array + //! or the same as the old bucket array. new_size is the length of the + //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer() + //! n can be bigger or smaller than this->bucket_count(). + //! + //! <b>Effects</b>: Updates the internal reference with the new bucket erases + //! the values from the old bucket and inserts then in the new one. + //! + //! If store_hash option is true, this method does not use the hash function. + //! + //! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic. + //! + //! <b>Throws</b>: If the hasher functor throws. + void rehash(const bucket_traits &new_bucket_traits) + { table_.rehash(new_bucket_traits); } + + //! <b>Requires</b>: + //! + //! <b>Effects</b>: + //! + //! <b>Complexity</b>: + //! + //! <b>Throws</b>: + //! + //! <b>Note</b>: this method is only available if incremental<true> option is activated. + bool incremental_rehash(bool grow = true) + { return table_.incremental_rehash(grow); } + + //! <b>Note</b>: this method is only available if incremental<true> option is activated. + bool incremental_rehash(const bucket_traits &new_bucket_traits) + { return table_.incremental_rehash(new_bucket_traits); } + + //! <b>Requires</b>: + //! + //! <b>Effects</b>: + //! + //! <b>Complexity</b>: + //! + //! <b>Throws</b>: + size_type split_count() const + { return table_.split_count(); } + + //! <b>Effects</b>: Returns the nearest new bucket count optimized for + //! the container that is bigger than n. This suggestion can be used + //! to create bucket arrays with a size that will usually improve + //! container's performance. If such value does not exist, the + //! higher possible value is returned. + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static size_type suggested_upper_bucket_count(size_type n) + { return table_type::suggested_upper_bucket_count(n); } + + //! <b>Effects</b>: Returns the nearest new bucket count optimized for + //! the container that is smaller than n. This suggestion can be used + //! to create bucket arrays with a size that will usually improve + //! container's performance. If such value does not exist, the + //! lower possible value is returned. + //! + //! <b>Complexity</b>: Amortized constant time. + //! + //! <b>Throws</b>: Nothing. + static size_type suggested_lower_bucket_count(size_type n) + { return table_type::suggested_lower_bucket_count(n); } +}; + +//! Helper metafunction to define an \c unordered_multiset that yields to the same type when the +//! same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class ...Options> +#else +template<class T, class O1 = none, class O2 = none + , class O3 = none, class O4 = none + , class O5 = none, class O6 = none + , class O7 = none, class O8 = none + , class O9 = none, class O10= none + > +#endif +struct make_unordered_multiset +{ + /// @cond + typedef unordered_multiset_impl + < typename make_hashtable_opt + <T, false, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED + +#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10> +#else +template<class T, class ...Options> +#endif +class unordered_multiset + : public make_unordered_multiset<T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type +{ + typedef typename make_unordered_multiset + <T, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 + #else + Options... + #endif + >::type Base; + //Assert if passed value traits are compatible with the type + BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value)); + BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset) + + public: + typedef typename Base::value_traits value_traits; + typedef typename Base::bucket_traits bucket_traits; + typedef typename Base::iterator iterator; + typedef typename Base::const_iterator const_iterator; + typedef typename Base::bucket_ptr bucket_ptr; + typedef typename Base::size_type size_type; + typedef typename Base::hasher hasher; + typedef typename Base::key_equal key_equal; + + unordered_multiset( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : Base(b_traits, hash_func, equal_func, v_traits) + {} + + template<class Iterator> + unordered_multiset( Iterator b + , Iterator e + , const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) + : Base(b, e, b_traits, hash_func, equal_func, v_traits) + {} + + unordered_multiset(BOOST_RV_REF(unordered_multiset) x) + : Base(::boost::move(static_cast<Base&>(x))) + {} + + unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x) + { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; } +}; + +#endif + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_UNORDERED_SET_HPP diff --git a/src/third_party/boost/boost/intrusive/unordered_set_hook.hpp b/src/third_party/boost/boost/intrusive/unordered_set_hook.hpp new file mode 100644 index 00000000000..2912d32be74 --- /dev/null +++ b/src/third_party/boost/boost/intrusive/unordered_set_hook.hpp @@ -0,0 +1,434 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP +#define BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP + +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/intrusive_fwd.hpp> +#include <boost/pointer_cast.hpp> +#include <boost/intrusive/detail/utilities.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/slist_hook.hpp> +#include <boost/intrusive/options.hpp> +#include <boost/intrusive/pointer_traits.hpp> +#include <boost/intrusive/detail/generic_hook.hpp> + +namespace boost { +namespace intrusive { + +/// @cond + +template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey> +struct unordered_node + : public slist_node<VoidPointer> +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + < unordered_node<VoidPointer, StoreHash, OptimizeMultiKey> >::type + node_ptr; + node_ptr prev_in_group_; + std::size_t hash_; +}; + +template<class VoidPointer> +struct unordered_node<VoidPointer, false, true> + : public slist_node<VoidPointer> +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + < unordered_node<VoidPointer, false, true> >::type + node_ptr; + node_ptr prev_in_group_; +}; + +template<class VoidPointer> +struct unordered_node<VoidPointer, true, false> + : public slist_node<VoidPointer> +{ + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + < unordered_node<VoidPointer, true, false> >::type + node_ptr; + std::size_t hash_; +}; + +template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey> +struct unordered_node_traits + : public slist_node_traits<VoidPointer> +{ + typedef slist_node_traits<VoidPointer> reduced_slist_node_traits; + typedef unordered_node<VoidPointer, StoreHash, OptimizeMultiKey> node; + + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + < node >::type node_ptr; + typedef typename pointer_traits + <VoidPointer>::template rebind_pointer + < const node >::type const_node_ptr; + + static const bool store_hash = StoreHash; + static const bool optimize_multikey = OptimizeMultiKey; + + static node_ptr get_next(const const_node_ptr & n) + { + return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*n->next_)); + } + + static void set_next(const node_ptr & n, const node_ptr & next) + { n->next_ = next; } + + static node_ptr get_prev_in_group(const const_node_ptr & n) + { return n->prev_in_group_; } + + static void set_prev_in_group(const node_ptr & n, const node_ptr & prev) + { n->prev_in_group_ = prev; } + + static std::size_t get_hash(const const_node_ptr & n) + { return n->hash_; } + + static void set_hash(const node_ptr & n, std::size_t h) + { n->hash_ = h; } +}; + +template<class NodeTraits> +struct unordered_group_adapter +{ + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + + static node_ptr get_next(const const_node_ptr & n) + { return NodeTraits::get_prev_in_group(n); } + + static void set_next(const node_ptr & n, const node_ptr & next) + { NodeTraits::set_prev_in_group(n, next); } +}; + +template<class NodeTraits> +struct unordered_algorithms + : public circular_slist_algorithms<NodeTraits> +{ + typedef circular_slist_algorithms<NodeTraits> base_type; + typedef unordered_group_adapter<NodeTraits> group_traits; + typedef circular_slist_algorithms<group_traits> group_algorithms; + + static void init(typename base_type::node_ptr n) + { + base_type::init(n); + group_algorithms::init(n); + } + + static void init_header(typename base_type::node_ptr n) + { + base_type::init_header(n); + group_algorithms::init_header(n); + } + + static void unlink(typename base_type::node_ptr n) + { + base_type::unlink(n); + group_algorithms::unlink(n); + } +}; + +template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey> +struct get_uset_node_algo +{ + typedef typename detail::if_c + < (StoreHash || OptimizeMultiKey) + , unordered_node_traits<VoidPointer, StoreHash, OptimizeMultiKey> + , slist_node_traits<VoidPointer> + >::type node_traits_type; + typedef typename detail::if_c + < OptimizeMultiKey + , unordered_algorithms<node_traits_type> + , circular_slist_algorithms<node_traits_type> + >::type type; +}; +/// @endcond + +//! Helper metafunction to define a \c unordered_set_base_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none, class O4 = none> +#endif +struct make_unordered_set_base_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_uset_node_algo<typename packed_options::void_pointer + , packed_options::store_hash + , packed_options::optimize_multikey + > + , typename packed_options::tag + , packed_options::link_mode + , detail::UsetBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Derive a class from unordered_set_base_hook in order to store objects in +//! in an unordered_set/unordered_multi_set. unordered_set_base_hook holds the data necessary to maintain +//! the unordered_set/unordered_multi_set and provides an appropriate value_traits class for unordered_set/unordered_multi_set. +//! +//! The hook admits the following options: \c tag<>, \c void_pointer<>, +//! \c link_mode<>, \c store_hash<> and \c optimize_multikey<>. +//! +//! \c tag<> defines a tag to identify the node. +//! The same tag value can be used in different classes, but if a class is +//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its +//! unique tag. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c store_hash<> will tell the hook to store the hash of the value +//! to speed up rehashings. +//! +//! \c optimize_multikey<> will tell the hook to store a link to form a group +//! with other value with the same value to speed up searches and insertions +//! in unordered_multisets with a great number of with equivalent keys. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3, class O4> +#endif +class unordered_set_base_hook + : public make_unordered_set_base_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + unordered_set_base_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + unordered_set_base_hook(const unordered_set_base_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + unordered_set_base_hook& operator=(const unordered_set_base_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in an unordered_set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~unordered_set_base_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(unordered_set_base_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c unordered_set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + + +//! Helper metafunction to define a \c unordered_set_member_hook that yields to the same +//! type when the same options (either explicitly or implicitly) are used. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1 = none, class O2 = none, class O3 = none, class O4 = none> +#endif +struct make_unordered_set_member_hook +{ + /// @cond + typedef typename pack_options + < hook_defaults, + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type packed_options; + + typedef detail::generic_hook + < get_uset_node_algo< typename packed_options::void_pointer + , packed_options::store_hash + , packed_options::optimize_multikey + > + , member_tag + , packed_options::link_mode + , detail::NoBaseHook + > implementation_defined; + /// @endcond + typedef implementation_defined type; +}; + +//! Put a public data member unordered_set_member_hook in order to store objects of this class in +//! an unordered_set/unordered_multi_set. unordered_set_member_hook holds the data necessary for maintaining the +//! unordered_set/unordered_multi_set and provides an appropriate value_traits class for unordered_set/unordered_multi_set. +//! +//! The hook admits the following options: \c void_pointer<>, +//! \c link_mode<> and \c store_hash<>. +//! +//! \c void_pointer<> is the pointer type that will be used internally in the hook +//! and the the container configured to use this hook. +//! +//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, +//! \c auto_unlink or \c safe_link). +//! +//! \c store_hash<> will tell the hook to store the hash of the value +//! to speed up rehashings. +#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template<class ...Options> +#else +template<class O1, class O2, class O3, class O4> +#endif +class unordered_set_member_hook + : public make_unordered_set_member_hook< + #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) + O1, O2, O3, O4 + #else + Options... + #endif + >::type +{ + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) + public: + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. + //! + //! <b>Throws</b>: Nothing. + unordered_set_member_hook(); + + //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link + //! initializes the node to an unlinked state. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing a copy-constructor + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + unordered_set_member_hook(const unordered_set_member_hook& ); + + //! <b>Effects</b>: Empty function. The argument is ignored. + //! + //! <b>Throws</b>: Nothing. + //! + //! <b>Rationale</b>: Providing an assignment operator + //! makes classes using the hook STL-compliant without forcing the + //! user to do some additional work. \c swap can be used to emulate + //! move-semantics. + unordered_set_member_hook& operator=(const unordered_set_member_hook& ); + + //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does + //! nothing (ie. no code is generated). If link_mode is \c safe_link and the + //! object is stored in an unordered_set an assertion is raised. If link_mode is + //! \c auto_unlink and \c is_linked() is true, the node is unlinked. + //! + //! <b>Throws</b>: Nothing. + ~unordered_set_member_hook(); + + //! <b>Effects</b>: Swapping two nodes swaps the position of the elements + //! related to those nodes in one or two containers. That is, if the node + //! this is part of the element e1, the node x is part of the element e2 + //! and both elements are included in the containers s1 and s2, then after + //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 + //! at the position of e1. If one element is not in a container, then + //! after the swap-operation the other element is not in a container. + //! Iterators to e1 and e2 related to those nodes are invalidated. + //! + //! <b>Complexity</b>: Constant + //! + //! <b>Throws</b>: Nothing. + void swap_nodes(unordered_set_member_hook &other); + + //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. + //! + //! <b>Returns</b>: true, if the node belongs to a container, false + //! otherwise. This function can be used to test whether \c unordered_set::iterator_to + //! will return a valid iterator. + //! + //! <b>Complexity</b>: Constant + bool is_linked() const; + + //! <b>Effects</b>: Removes the node if it's inserted in a container. + //! This function is only allowed if link_mode is \c auto_unlink. + //! + //! <b>Throws</b>: Nothing. + void unlink(); + #endif +}; + +} //namespace intrusive +} //namespace boost + +#include <boost/intrusive/detail/config_end.hpp> + +#endif //BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP diff --git a/src/third_party/boost/boost/move/move_helpers.hpp b/src/third_party/boost/boost/move/move_helpers.hpp new file mode 100644 index 00000000000..eaf51d651f7 --- /dev/null +++ b/src/third_party/boost/boost/move/move_helpers.hpp @@ -0,0 +1,173 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2010-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/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_MOVE_MOVE_HELPERS_HPP +#define BOOST_MOVE_MOVE_HELPERS_HPP + +#include <boost/move/move.hpp> +#include <boost/type_traits/is_class.hpp> + +#if defined(BOOST_NO_RVALUE_REFERENCES) || (defined(_MSC_VER) && (_MSC_VER == 1600)) +#include <boost/type_traits/is_same.hpp> +#include <boost/utility/enable_if.hpp> +#endif +#if defined(BOOST_NO_RVALUE_REFERENCES) +#include <boost/mpl/if.hpp> +#endif + + +#if defined(BOOST_NO_RVALUE_REFERENCES) +struct not_a_type; +#define BOOST_MOVE_CATCH_CONST(U) \ + typename ::boost::mpl::if_< ::boost::is_class<U>, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type +#define BOOST_MOVE_CATCH_RVALUE(U)\ + typename ::boost::mpl::if_< ::boost::is_class<U>, BOOST_RV_REF(U), not_a_type>::type +#define BOOST_MOVE_CATCH_FWD(U) BOOST_FWD_REF(U) +#else +#define BOOST_MOVE_CATCH_CONST(U) const U & +#define BOOST_MOVE_CATCH_RVALUE(U) U && +#define BOOST_MOVE_CATCH_FWD(U) U && +#endif + +#ifdef BOOST_NO_RVALUE_REFERENCES + +#define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(::boost::move(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(TYPE &x)\ + { return FWD_FUNCTION(const_cast<const TYPE &>(x)); }\ +\ + template<class BOOST_MOVE_TEMPL_PARAM>\ + typename ::boost::enable_if_c\ + < ::boost::is_class<TYPE>::value &&\ + ::boost::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value &&\ + !::boost::has_move_emulation_enabled<BOOST_MOVE_TEMPL_PARAM>::value\ + , RETURN_VALUE >::type\ + PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ + { return FWD_FUNCTION(u); }\ +\ + template<class BOOST_MOVE_TEMPL_PARAM>\ + typename ::boost::enable_if_c\ + < (!::boost::is_class<BOOST_MOVE_TEMPL_PARAM>::value || \ + !::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value) && \ + !::boost::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value \ + , RETURN_VALUE >::type\ + PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(::boost::move(t));\ + }\ +// + +#elif (defined(_MSC_VER) && (_MSC_VER == 1600)) + +#define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(::boost::move(x)); }\ +\ + template<class BOOST_MOVE_TEMPL_PARAM>\ + typename ::boost::enable_if_c\ + < !::boost::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value\ + , RETURN_VALUE >::type\ + PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(::boost::move(t));\ + }\ +// + +#else + +#define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(::boost::move(x)); }\ +// + +#endif + + +#ifdef BOOST_NO_RVALUE_REFERENCES + +#define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1)\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, TYPE &x)\ + { return FWD_FUNCTION(arg1, const_cast<const TYPE &>(x)); }\ +\ + template<class BOOST_MOVE_TEMPL_PARAM>\ + typename ::boost::enable_if_c\ + < ::boost::is_class<TYPE>::value &&\ + ::boost::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value &&\ + !::boost::has_move_emulation_enabled<BOOST_MOVE_TEMPL_PARAM>::value\ + , RETURN_VALUE >::type\ + PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ + { return FWD_FUNCTION(arg1, u); }\ +\ + template<class BOOST_MOVE_TEMPL_PARAM>\ + typename ::boost::enable_if_c\ + < (!::boost::is_class<BOOST_MOVE_TEMPL_PARAM>::value || \ + !::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value) && \ + !::boost::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value \ + , RETURN_VALUE >::type\ + PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(arg1, ::boost::move(t));\ + }\ +// + +#elif (defined(_MSC_VER) && (_MSC_VER == 1600)) + +#define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1)\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ +\ + template<class BOOST_MOVE_TEMPL_PARAM>\ + typename ::boost::enable_if_c\ + < !::boost::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value\ + , RETURN_VALUE >::type\ + PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(arg1, ::boost::move(t));\ + }\ +// + +#else + +#define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1)\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\ +\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ +// + +#endif + +#endif //#ifndef BOOST_MOVE_MOVE_HELPERS_HPP diff --git a/src/third_party/boost/boost/preprocessor.textClipping b/src/third_party/boost/boost/preprocessor.textClipping new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/src/third_party/boost/boost/preprocessor.textClipping diff --git a/src/third_party/boost/boost/preprocessor/arithmetic.hpp b/src/third_party/boost/boost/preprocessor/arithmetic.hpp new file mode 100644 index 00000000000..b1be7814e42 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/arithmetic.hpp @@ -0,0 +1,25 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARITHMETIC_HPP +# define BOOST_PREPROCESSOR_ARITHMETIC_HPP +# +# include <boost/preprocessor/arithmetic/add.hpp> +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/arithmetic/div.hpp> +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/arithmetic/mod.hpp> +# include <boost/preprocessor/arithmetic/mul.hpp> +# include <boost/preprocessor/arithmetic/sub.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/arithmetic/div.hpp b/src/third_party/boost/boost/preprocessor/arithmetic/div.hpp new file mode 100644 index 00000000000..277596cea91 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/arithmetic/div.hpp @@ -0,0 +1,39 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARITHMETIC_DIV_HPP +# define BOOST_PREPROCESSOR_ARITHMETIC_DIV_HPP +# +# include <boost/preprocessor/arithmetic/detail/div_base.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# +# /* BOOST_PP_DIV */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_DIV(x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_DIV_BASE(x, y)) +# else +# define BOOST_PP_DIV(x, y) BOOST_PP_DIV_I(x, y) +# define BOOST_PP_DIV_I(x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_DIV_BASE(x, y)) +# endif +# +# /* BOOST_PP_DIV_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_DIV_D(d, x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_DIV_BASE_D(d, x, y)) +# else +# define BOOST_PP_DIV_D(d, x, y) BOOST_PP_DIV_D_I(d, x, y) +# define BOOST_PP_DIV_D_I(d, x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_DIV_BASE_D(d, x, y)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/arithmetic/mul.hpp b/src/third_party/boost/boost/preprocessor/arithmetic/mul.hpp new file mode 100644 index 00000000000..f3d9ffcf568 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/arithmetic/mul.hpp @@ -0,0 +1,53 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARITHMETIC_MUL_HPP +# define BOOST_PREPROCESSOR_ARITHMETIC_MUL_HPP +# +# include <boost/preprocessor/arithmetic/add.hpp> +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_MUL */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_MUL(x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE(BOOST_PP_MUL_P, BOOST_PP_MUL_O, (0, x, y))) +# else +# define BOOST_PP_MUL(x, y) BOOST_PP_MUL_I(x, y) +# define BOOST_PP_MUL_I(x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE(BOOST_PP_MUL_P, BOOST_PP_MUL_O, (0, x, y))) +# endif +# +# define BOOST_PP_MUL_P(d, rxy) BOOST_PP_TUPLE_ELEM(3, 2, rxy) +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_MUL_O(d, rxy) BOOST_PP_MUL_O_IM(d, BOOST_PP_TUPLE_REM_3 rxy) +# define BOOST_PP_MUL_O_IM(d, im) BOOST_PP_MUL_O_I(d, im) +# else +# define BOOST_PP_MUL_O(d, rxy) BOOST_PP_MUL_O_I(d, BOOST_PP_TUPLE_ELEM(3, 0, rxy), BOOST_PP_TUPLE_ELEM(3, 1, rxy), BOOST_PP_TUPLE_ELEM(3, 2, rxy)) +# endif +# +# define BOOST_PP_MUL_O_I(d, r, x, y) (BOOST_PP_ADD_D(d, r, x), x, BOOST_PP_DEC(y)) +# +# /* BOOST_PP_MUL_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_MUL_D(d, x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_MUL_P, BOOST_PP_MUL_O, (0, x, y))) +# else +# define BOOST_PP_MUL_D(d, x, y) BOOST_PP_MUL_D_I(d, x, y) +# define BOOST_PP_MUL_D_I(d, x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_MUL_P, BOOST_PP_MUL_O, (0, x, y))) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array.hpp b/src/third_party/boost/boost/preprocessor/array.hpp new file mode 100644 index 00000000000..3b6a77199b1 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array.hpp @@ -0,0 +1,32 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002-2011. * +# * (C) Copyright Edward Diener 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_HPP +# define BOOST_PREPROCESSOR_ARRAY_HPP +# +# include <boost/preprocessor/array/data.hpp> +# include <boost/preprocessor/array/elem.hpp> +# include <boost/preprocessor/array/enum.hpp> +# include <boost/preprocessor/array/insert.hpp> +# include <boost/preprocessor/array/pop_back.hpp> +# include <boost/preprocessor/array/pop_front.hpp> +# include <boost/preprocessor/array/push_back.hpp> +# include <boost/preprocessor/array/push_front.hpp> +# include <boost/preprocessor/array/remove.hpp> +# include <boost/preprocessor/array/replace.hpp> +# include <boost/preprocessor/array/reverse.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/array/to_list.hpp> +# include <boost/preprocessor/array/to_seq.hpp> +# include <boost/preprocessor/array/to_tuple.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/enum.hpp b/src/third_party/boost/boost/preprocessor/array/enum.hpp new file mode 100644 index 00000000000..9710f9cb852 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/enum.hpp @@ -0,0 +1,33 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_ENUM_HPP +# define BOOST_PREPROCESSOR_ARRAY_ENUM_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_ARRAY_ENUM */ +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_ARRAY_ENUM(array) BOOST_PP_ARRAY_ENUM_I(BOOST_PP_TUPLE_REM_CTOR, array) +# define BOOST_PP_ARRAY_ENUM_I(m, args) BOOST_PP_ARRAY_ENUM_II(m, args) +# define BOOST_PP_ARRAY_ENUM_II(m, args) BOOST_PP_CAT(m ## args,) +# elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_ARRAY_ENUM(array) BOOST_PP_ARRAY_ENUM_I(array) +# define BOOST_PP_ARRAY_ENUM_I(array) BOOST_PP_TUPLE_REM_CTOR ## array +# else +# define BOOST_PP_ARRAY_ENUM(array) BOOST_PP_TUPLE_REM_CTOR array +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/insert.hpp b/src/third_party/boost/boost/preprocessor/array/insert.hpp new file mode 100644 index 00000000000..b8fe5b8f8a8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/insert.hpp @@ -0,0 +1,55 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_INSERT_HPP +# define BOOST_PREPROCESSOR_ARRAY_INSERT_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/array/elem.hpp> +# include <boost/preprocessor/array/push_back.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/comparison/not_equal.hpp> +# include <boost/preprocessor/control/deduce_d.hpp> +# include <boost/preprocessor/control/iif.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# +# /* BOOST_PP_ARRAY_INSERT */ +# +# define BOOST_PP_ARRAY_INSERT(array, i, elem) BOOST_PP_ARRAY_INSERT_I(BOOST_PP_DEDUCE_D(), array, i, elem) +# define BOOST_PP_ARRAY_INSERT_I(d, array, i, elem) BOOST_PP_ARRAY_INSERT_D(d, array, i, elem) +# +# /* BOOST_PP_ARRAY_INSERT_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_INSERT_D(d, array, i, elem) BOOST_PP_TUPLE_ELEM(5, 3, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_INSERT_P, BOOST_PP_ARRAY_INSERT_O, (0, i, elem, (0, ()), array))) +# else +# define BOOST_PP_ARRAY_INSERT_D(d, array, i, elem) BOOST_PP_ARRAY_INSERT_D_I(d, array, i, elem) +# define BOOST_PP_ARRAY_INSERT_D_I(d, array, i, elem) BOOST_PP_TUPLE_ELEM(5, 3, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_INSERT_P, BOOST_PP_ARRAY_INSERT_O, (0, i, elem, (0, ()), array))) +# endif +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_ARRAY_INSERT_P(d, state) BOOST_PP_ARRAY_INSERT_P_I state +# else +# define BOOST_PP_ARRAY_INSERT_P(d, state) BOOST_PP_ARRAY_INSERT_P_I(nil, nil, nil, BOOST_PP_TUPLE_ELEM(5, 3, state), BOOST_PP_TUPLE_ELEM(5, 4, state)) +# endif +# +# define BOOST_PP_ARRAY_INSERT_P_I(_i, _ii, _iii, res, arr) BOOST_PP_NOT_EQUAL(BOOST_PP_ARRAY_SIZE(res), BOOST_PP_INC(BOOST_PP_ARRAY_SIZE(arr))) +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_ARRAY_INSERT_O(d, state) BOOST_PP_ARRAY_INSERT_O_I state +# else +# define BOOST_PP_ARRAY_INSERT_O(d, state) BOOST_PP_ARRAY_INSERT_O_I(BOOST_PP_TUPLE_ELEM(5, 0, state), BOOST_PP_TUPLE_ELEM(5, 1, state), BOOST_PP_TUPLE_ELEM(5, 2, state), BOOST_PP_TUPLE_ELEM(5, 3, state), BOOST_PP_TUPLE_ELEM(5, 4, state)) +# endif +# +# define BOOST_PP_ARRAY_INSERT_O_I(n, i, elem, res, arr) (BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(BOOST_PP_ARRAY_SIZE(res), i), BOOST_PP_INC(n), n), i, elem, BOOST_PP_ARRAY_PUSH_BACK(res, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(BOOST_PP_ARRAY_SIZE(res), i), BOOST_PP_ARRAY_ELEM(n, arr), elem)), arr) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/pop_back.hpp b/src/third_party/boost/boost/preprocessor/array/pop_back.hpp new file mode 100644 index 00000000000..29d2a45b756 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/pop_back.hpp @@ -0,0 +1,37 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_POP_BACK_HPP +# define BOOST_PREPROCESSOR_ARRAY_POP_BACK_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/array/elem.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/repetition/enum.hpp> +# include <boost/preprocessor/repetition/deduce_z.hpp> +# +# /* BOOST_PP_ARRAY_POP_BACK */ +# +# define BOOST_PP_ARRAY_POP_BACK(array) BOOST_PP_ARRAY_POP_BACK_Z(BOOST_PP_DEDUCE_Z(), array) +# +# /* BOOST_PP_ARRAY_POP_BACK_Z */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_POP_BACK_Z(z, array) BOOST_PP_ARRAY_POP_BACK_I(z, BOOST_PP_ARRAY_SIZE(array), array) +# else +# define BOOST_PP_ARRAY_POP_BACK_Z(z, array) BOOST_PP_ARRAY_POP_BACK_Z_D(z, array) +# define BOOST_PP_ARRAY_POP_BACK_Z_D(z, array) BOOST_PP_ARRAY_POP_BACK_I(z, BOOST_PP_ARRAY_SIZE(array), array) +# endif +# +# define BOOST_PP_ARRAY_POP_BACK_I(z, size, array) (BOOST_PP_DEC(size), (BOOST_PP_ENUM_ ## z(BOOST_PP_DEC(size), BOOST_PP_ARRAY_POP_BACK_M, array))) +# define BOOST_PP_ARRAY_POP_BACK_M(z, n, data) BOOST_PP_ARRAY_ELEM(n, data) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/pop_front.hpp b/src/third_party/boost/boost/preprocessor/array/pop_front.hpp new file mode 100644 index 00000000000..7d9069c5aae --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/pop_front.hpp @@ -0,0 +1,38 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_POP_FRONT_HPP +# define BOOST_PREPROCESSOR_ARRAY_POP_FRONT_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/array/elem.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/repetition/enum.hpp> +# include <boost/preprocessor/repetition/deduce_z.hpp> +# +# /* BOOST_PP_ARRAY_POP_FRONT */ +# +# define BOOST_PP_ARRAY_POP_FRONT(array) BOOST_PP_ARRAY_POP_FRONT_Z(BOOST_PP_DEDUCE_Z(), array) +# +# /* BOOST_PP_ARRAY_POP_FRONT_Z */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_POP_FRONT_Z(z, array) BOOST_PP_ARRAY_POP_FRONT_I(z, BOOST_PP_ARRAY_SIZE(array), array) +# else +# define BOOST_PP_ARRAY_POP_FRONT_Z(z, array) BOOST_PP_ARRAY_POP_FRONT_Z_D(z, array) +# define BOOST_PP_ARRAY_POP_FRONT_Z_D(z, array) BOOST_PP_ARRAY_POP_FRONT_I(z, BOOST_PP_ARRAY_SIZE(array), array) +# endif +# +# define BOOST_PP_ARRAY_POP_FRONT_I(z, size, array) (BOOST_PP_DEC(size), (BOOST_PP_ENUM_ ## z(BOOST_PP_DEC(size), BOOST_PP_ARRAY_POP_FRONT_M, array))) +# define BOOST_PP_ARRAY_POP_FRONT_M(z, n, data) BOOST_PP_ARRAY_ELEM(BOOST_PP_INC(n), data) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/push_back.hpp b/src/third_party/boost/boost/preprocessor/array/push_back.hpp new file mode 100644 index 00000000000..6d98d8ee4e9 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/push_back.hpp @@ -0,0 +1,33 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_PUSH_BACK_HPP +# define BOOST_PREPROCESSOR_ARRAY_PUSH_BACK_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/array/data.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/punctuation/comma_if.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_ARRAY_PUSH_BACK */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_PUSH_BACK(array, elem) BOOST_PP_ARRAY_PUSH_BACK_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem) +# else +# define BOOST_PP_ARRAY_PUSH_BACK(array, elem) BOOST_PP_ARRAY_PUSH_BACK_D(array, elem) +# define BOOST_PP_ARRAY_PUSH_BACK_D(array, elem) BOOST_PP_ARRAY_PUSH_BACK_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem) +# endif +# +# define BOOST_PP_ARRAY_PUSH_BACK_I(size, data, elem) (BOOST_PP_INC(size), (BOOST_PP_TUPLE_REM(size) data BOOST_PP_COMMA_IF(size) elem)) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/push_front.hpp b/src/third_party/boost/boost/preprocessor/array/push_front.hpp new file mode 100644 index 00000000000..59344c312f6 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/push_front.hpp @@ -0,0 +1,33 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_PUSH_FRONT_HPP +# define BOOST_PREPROCESSOR_ARRAY_PUSH_FRONT_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/array/data.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/punctuation/comma_if.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_ARRAY_PUSH_FRONT */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_PUSH_FRONT(array, elem) BOOST_PP_ARRAY_PUSH_FRONT_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem) +# else +# define BOOST_PP_ARRAY_PUSH_FRONT(array, elem) BOOST_PP_ARRAY_PUSH_FRONT_D(array, elem) +# define BOOST_PP_ARRAY_PUSH_FRONT_D(array, elem) BOOST_PP_ARRAY_PUSH_FRONT_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem) +# endif +# +# define BOOST_PP_ARRAY_PUSH_FRONT_I(size, data, elem) (BOOST_PP_INC(size), (elem BOOST_PP_COMMA_IF(size) BOOST_PP_TUPLE_REM(size) data)) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/remove.hpp b/src/third_party/boost/boost/preprocessor/array/remove.hpp new file mode 100644 index 00000000000..02609000ba8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/remove.hpp @@ -0,0 +1,54 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_REMOVE_HPP +# define BOOST_PREPROCESSOR_ARRAY_REMOVE_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/array/elem.hpp> +# include <boost/preprocessor/array/push_back.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/comparison/not_equal.hpp> +# include <boost/preprocessor/control/deduce_d.hpp> +# include <boost/preprocessor/control/iif.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/tuple/eat.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# +# /* BOOST_PP_ARRAY_REMOVE */ +# +# define BOOST_PP_ARRAY_REMOVE(array, i) BOOST_PP_ARRAY_REMOVE_I(BOOST_PP_DEDUCE_D(), array, i) +# define BOOST_PP_ARRAY_REMOVE_I(d, array, i) BOOST_PP_ARRAY_REMOVE_D(d, array, i) +# +# /* BOOST_PP_ARRAY_REMOVE_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_REMOVE_D(d, array, i) BOOST_PP_TUPLE_ELEM(4, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REMOVE_P, BOOST_PP_ARRAY_REMOVE_O, (0, i, (0, ()), array))) +# else +# define BOOST_PP_ARRAY_REMOVE_D(d, array, i) BOOST_PP_ARRAY_REMOVE_D_I(d, array, i) +# define BOOST_PP_ARRAY_REMOVE_D_I(d, array, i) BOOST_PP_TUPLE_ELEM(4, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REMOVE_P, BOOST_PP_ARRAY_REMOVE_O, (0, i, (0, ()), array))) +# endif +# +# define BOOST_PP_ARRAY_REMOVE_P(d, st) BOOST_PP_NOT_EQUAL(BOOST_PP_TUPLE_ELEM(4, 0, st), BOOST_PP_ARRAY_SIZE(BOOST_PP_TUPLE_ELEM(4, 3, st))) +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_ARRAY_REMOVE_O(d, st) BOOST_PP_ARRAY_REMOVE_O_I st +# else +# define BOOST_PP_ARRAY_REMOVE_O(d, st) BOOST_PP_ARRAY_REMOVE_O_I(BOOST_PP_TUPLE_ELEM(4, 0, st), BOOST_PP_TUPLE_ELEM(4, 1, st), BOOST_PP_TUPLE_ELEM(4, 2, st), BOOST_PP_TUPLE_ELEM(4, 3, st)) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() +# define BOOST_PP_ARRAY_REMOVE_O_I(n, i, res, arr) (BOOST_PP_INC(n), i, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(n, i), BOOST_PP_ARRAY_PUSH_BACK, res BOOST_PP_TUPLE_EAT_2)(res, BOOST_PP_ARRAY_ELEM(n, arr)), arr) +# else +# define BOOST_PP_ARRAY_REMOVE_O_I(n, i, res, arr) (BOOST_PP_INC(n), i, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(n, i), BOOST_PP_ARRAY_PUSH_BACK, BOOST_PP_TUPLE_ELEM_2_0)(res, BOOST_PP_ARRAY_ELEM(n, arr)), arr) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/replace.hpp b/src/third_party/boost/boost/preprocessor/array/replace.hpp new file mode 100644 index 00000000000..10a1f097675 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/replace.hpp @@ -0,0 +1,49 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_REPLACE_HPP +# define BOOST_PREPROCESSOR_ARRAY_REPLACE_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/array/elem.hpp> +# include <boost/preprocessor/array/push_back.hpp> +# include <boost/preprocessor/comparison/not_equal.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/deduce_d.hpp> +# include <boost/preprocessor/control/iif.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# +# /* BOOST_PP_ARRAY_REPLACE */ +# +# define BOOST_PP_ARRAY_REPLACE(array, i, elem) BOOST_PP_ARRAY_REPLACE_I(BOOST_PP_DEDUCE_D(), array, i, elem) +# define BOOST_PP_ARRAY_REPLACE_I(d, array, i, elem) BOOST_PP_ARRAY_REPLACE_D(d, array, i, elem) +# +# /* BOOST_PP_ARRAY_REPLACE_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_REPLACE_D(d, array, i, elem) BOOST_PP_TUPLE_ELEM(5, 3, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REPLACE_P, BOOST_PP_ARRAY_REPLACE_O, (0, i, elem, (0, ()), array))) +# else +# define BOOST_PP_ARRAY_REPLACE_D(d, array, i, elem) BOOST_PP_ARRAY_REPLACE_D_I(d, array, i, elem) +# define BOOST_PP_ARRAY_REPLACE_D_I(d, array, i, elem) BOOST_PP_TUPLE_ELEM(5, 3, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REPLACE_P, BOOST_PP_ARRAY_REPLACE_O, (0, i, elem, (0, ()), array))) +# endif +# +# define BOOST_PP_ARRAY_REPLACE_P(d, state) BOOST_PP_NOT_EQUAL(BOOST_PP_TUPLE_ELEM(5, 0, state), BOOST_PP_ARRAY_SIZE(BOOST_PP_TUPLE_ELEM(5, 4, state))) +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_ARRAY_REPLACE_O(d, state) BOOST_PP_ARRAY_REPLACE_O_I state +# else +# define BOOST_PP_ARRAY_REPLACE_O(d, state) BOOST_PP_ARRAY_REPLACE_O_I(BOOST_PP_TUPLE_ELEM(5, 0, state), BOOST_PP_TUPLE_ELEM(5, 1, state), BOOST_PP_TUPLE_ELEM(5, 2, state), BOOST_PP_TUPLE_ELEM(5, 3, state), BOOST_PP_TUPLE_ELEM(5, 4, state)) +# endif +# +# define BOOST_PP_ARRAY_REPLACE_O_I(n, i, elem, res, arr) (BOOST_PP_INC(n), i, elem, BOOST_PP_ARRAY_PUSH_BACK(res, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(n, i), BOOST_PP_ARRAY_ELEM(n, arr), elem)), arr) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/reverse.hpp b/src/third_party/boost/boost/preprocessor/array/reverse.hpp new file mode 100644 index 00000000000..a6a4f75c706 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/reverse.hpp @@ -0,0 +1,29 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_REVERSE_HPP +# define BOOST_PREPROCESSOR_ARRAY_REVERSE_HPP +# +# include <boost/preprocessor/array/data.hpp> +# include <boost/preprocessor/array/size.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/reverse.hpp> +# +# /* BOOST_PP_ARRAY_REVERSE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ARRAY_REVERSE(array) (BOOST_PP_ARRAY_SIZE(array), BOOST_PP_TUPLE_REVERSE(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array))) +# else +# define BOOST_PP_ARRAY_REVERSE(array) BOOST_PP_ARRAY_REVERSE_I(array) +# define BOOST_PP_ARRAY_REVERSE_I(array) (BOOST_PP_ARRAY_SIZE(array), BOOST_PP_TUPLE_REVERSE(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array))) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/to_list.hpp b/src/third_party/boost/boost/preprocessor/array/to_list.hpp new file mode 100644 index 00000000000..919856158df --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/to_list.hpp @@ -0,0 +1,33 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_TO_LIST_HPP +# define BOOST_PREPROCESSOR_ARRAY_TO_LIST_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/to_list.hpp> +# +# /* BOOST_PP_ARRAY_TO_LIST */ +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_ARRAY_TO_LIST(array) BOOST_PP_ARRAY_TO_LIST_I(BOOST_PP_TUPLE_TO_LIST, array) +# define BOOST_PP_ARRAY_TO_LIST_I(m, args) BOOST_PP_ARRAY_TO_LIST_II(m, args) +# define BOOST_PP_ARRAY_TO_LIST_II(m, args) BOOST_PP_CAT(m ## args,) +# elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_ARRAY_TO_LIST(array) BOOST_PP_ARRAY_TO_LIST_I(array) +# define BOOST_PP_ARRAY_TO_LIST_I(array) BOOST_PP_TUPLE_TO_LIST ## array +# else +# define BOOST_PP_ARRAY_TO_LIST(array) BOOST_PP_TUPLE_TO_LIST array +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/to_seq.hpp b/src/third_party/boost/boost/preprocessor/array/to_seq.hpp new file mode 100644 index 00000000000..ebcae53bede --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/to_seq.hpp @@ -0,0 +1,33 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_TO_SEQ_HPP +# define BOOST_PREPROCESSOR_ARRAY_TO_SEQ_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/to_seq.hpp> +# +# /* BOOST_PP_ARRAY_TO_SEQ */ +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_ARRAY_TO_SEQ(array) BOOST_PP_ARRAY_TO_SEQ_I(BOOST_PP_TUPLE_TO_SEQ, array) +# define BOOST_PP_ARRAY_TO_SEQ_I(m, args) BOOST_PP_ARRAY_TO_SEQ_II(m, args) +# define BOOST_PP_ARRAY_TO_SEQ_II(m, args) BOOST_PP_CAT(m ## args,) +# elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_ARRAY_TO_SEQ(array) BOOST_PP_ARRAY_TO_SEQ_I(array) +# define BOOST_PP_ARRAY_TO_SEQ_I(array) BOOST_PP_TUPLE_TO_SEQ ## array +# else +# define BOOST_PP_ARRAY_TO_SEQ(array) BOOST_PP_TUPLE_TO_SEQ array +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/array/to_tuple.hpp b/src/third_party/boost/boost/preprocessor/array/to_tuple.hpp new file mode 100644 index 00000000000..eb83274f7f3 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/array/to_tuple.hpp @@ -0,0 +1,22 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_TO_TUPLE_HPP +# define BOOST_PREPROCESSOR_ARRAY_TO_TUPLE_HPP +# +# include <boost/preprocessor/array/data.hpp> +# +# /* BOOST_PP_ARRAY_TO_TUPLE */ +# +# define BOOST_PP_ARRAY_TO_TUPLE BOOST_PP_ARRAY_DATA +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/assert_msg.hpp b/src/third_party/boost/boost/preprocessor/assert_msg.hpp new file mode 100644 index 00000000000..924dba1d9f8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/assert_msg.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ASSERT_MSG_HPP +# define BOOST_PREPROCESSOR_ASSERT_MSG_HPP +# +# include <boost/preprocessor/debug/assert.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/comma.hpp b/src/third_party/boost/boost/preprocessor/comma.hpp new file mode 100644 index 00000000000..6e02fb6131a --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/comma.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_COMMA_HPP +# define BOOST_PREPROCESSOR_COMMA_HPP +# +# include <boost/preprocessor/punctuation/comma.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/comparison.hpp b/src/third_party/boost/boost/preprocessor/comparison.hpp new file mode 100644 index 00000000000..b09ac8f97b1 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/comparison.hpp @@ -0,0 +1,24 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_COMPARISON_HPP +# define BOOST_PREPROCESSOR_COMPARISON_HPP +# +# include <boost/preprocessor/comparison/equal.hpp> +# include <boost/preprocessor/comparison/greater.hpp> +# include <boost/preprocessor/comparison/greater_equal.hpp> +# include <boost/preprocessor/comparison/less.hpp> +# include <boost/preprocessor/comparison/less_equal.hpp> +# include <boost/preprocessor/comparison/not_equal.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/comparison/equal.hpp b/src/third_party/boost/boost/preprocessor/comparison/equal.hpp new file mode 100644 index 00000000000..d299efe5869 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/comparison/equal.hpp @@ -0,0 +1,34 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_COMPARISON_EQUAL_HPP +# define BOOST_PREPROCESSOR_COMPARISON_EQUAL_HPP +# +# include <boost/preprocessor/comparison/not_equal.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/logical/compl.hpp> +# +# /* BOOST_PP_EQUAL */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_EQUAL(x, y) BOOST_PP_COMPL(BOOST_PP_NOT_EQUAL(x, y)) +# else +# define BOOST_PP_EQUAL(x, y) BOOST_PP_EQUAL_I(x, y) +# define BOOST_PP_EQUAL_I(x, y) BOOST_PP_COMPL(BOOST_PP_NOT_EQUAL(x, y)) +# endif +# +# /* BOOST_PP_EQUAL_D */ +# +# define BOOST_PP_EQUAL_D(d, x, y) BOOST_PP_EQUAL(x, y) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/comparison/greater.hpp b/src/third_party/boost/boost/preprocessor/comparison/greater.hpp new file mode 100644 index 00000000000..83d2fcf2376 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/comparison/greater.hpp @@ -0,0 +1,38 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_COMPARISON_GREATER_HPP +# define BOOST_PREPROCESSOR_COMPARISON_GREATER_HPP +# +# include <boost/preprocessor/comparison/less.hpp> +# include <boost/preprocessor/config/config.hpp> +# +# /* BOOST_PP_GREATER */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_GREATER(x, y) BOOST_PP_LESS(y, x) +# else +# define BOOST_PP_GREATER(x, y) BOOST_PP_GREATER_I(x, y) +# define BOOST_PP_GREATER_I(x, y) BOOST_PP_LESS(y, x) +# endif +# +# /* BOOST_PP_GREATER_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_GREATER_D(d, x, y) BOOST_PP_LESS_D(d, y, x) +# else +# define BOOST_PP_GREATER_D(d, x, y) BOOST_PP_GREATER_D_I(d, x, y) +# define BOOST_PP_GREATER_D_I(d, x, y) BOOST_PP_LESS_D(d, y, x) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/comparison/greater_equal.hpp b/src/third_party/boost/boost/preprocessor/comparison/greater_equal.hpp new file mode 100644 index 00000000000..beaeaff6bf1 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/comparison/greater_equal.hpp @@ -0,0 +1,38 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_COMPARISON_GREATER_EQUAL_HPP +# define BOOST_PREPROCESSOR_COMPARISON_GREATER_EQUAL_HPP +# +# include <boost/preprocessor/comparison/less_equal.hpp> +# include <boost/preprocessor/config/config.hpp> +# +# /* BOOST_PP_GREATER_EQUAL */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_GREATER_EQUAL(x, y) BOOST_PP_LESS_EQUAL(y, x) +# else +# define BOOST_PP_GREATER_EQUAL(x, y) BOOST_PP_GREATER_EQUAL_I(x, y) +# define BOOST_PP_GREATER_EQUAL_I(x, y) BOOST_PP_LESS_EQUAL(y, x) +# endif +# +# /* BOOST_PP_GREATER_EQUAL_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_GREATER_EQUAL_D(d, x, y) BOOST_PP_LESS_EQUAL_D(d, y, x) +# else +# define BOOST_PP_GREATER_EQUAL_D(d, x, y) BOOST_PP_GREATER_EQUAL_D_I(d, x, y) +# define BOOST_PP_GREATER_EQUAL_D_I(d, x, y) BOOST_PP_LESS_EQUAL_D(d, y, x) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/comparison/less.hpp b/src/third_party/boost/boost/preprocessor/comparison/less.hpp new file mode 100644 index 00000000000..d91ea3d02e1 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/comparison/less.hpp @@ -0,0 +1,46 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_COMPARISON_LESS_HPP +# define BOOST_PREPROCESSOR_COMPARISON_LESS_HPP +# +# include <boost/preprocessor/comparison/less_equal.hpp> +# include <boost/preprocessor/comparison/not_equal.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/iif.hpp> +# include <boost/preprocessor/logical/bitand.hpp> +# include <boost/preprocessor/tuple/eat.hpp> +# +# /* BOOST_PP_LESS */ +# +# if BOOST_PP_CONFIG_FLAGS() & (BOOST_PP_CONFIG_MWCC() | BOOST_PP_CONFIG_DMC()) +# define BOOST_PP_LESS(x, y) BOOST_PP_BITAND(BOOST_PP_NOT_EQUAL(x, y), BOOST_PP_LESS_EQUAL(x, y)) +# elif ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LESS(x, y) BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(x, y), BOOST_PP_LESS_EQUAL, 0 BOOST_PP_TUPLE_EAT_2)(x, y) +# else +# define BOOST_PP_LESS(x, y) BOOST_PP_LESS_I(x, y) +# define BOOST_PP_LESS_I(x, y) BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(x, y), BOOST_PP_LESS_EQUAL, 0 BOOST_PP_TUPLE_EAT_2)(x, y) +# endif +# +# /* BOOST_PP_LESS_D */ +# +# if BOOST_PP_CONFIG_FLAGS() & (BOOST_PP_CONFIG_MWCC() | BOOST_PP_CONFIG_DMC()) +# define BOOST_PP_LESS_D(d, x, y) BOOST_PP_BITAND(BOOST_PP_NOT_EQUAL(x, y), BOOST_PP_LESS_EQUAL_D(d, x, y)) +# elif ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LESS_D(d, x, y) BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(x, y), BOOST_PP_LESS_EQUAL_D, 0 BOOST_PP_TUPLE_EAT_3)(d, x, y) +# else +# define BOOST_PP_LESS_D(d, x, y) BOOST_PP_LESS_D_I(d, x, y) +# define BOOST_PP_LESS_D_I(d, x, y) BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(x, y), BOOST_PP_LESS_EQUAL_D, 0 BOOST_PP_TUPLE_EAT_3)(d, x, y) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/comparison/not_equal.hpp b/src/third_party/boost/boost/preprocessor/comparison/not_equal.hpp new file mode 100644 index 00000000000..b4b0eae129d --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/comparison/not_equal.hpp @@ -0,0 +1,814 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_COMPARISON_NOT_EQUAL_HPP +# define BOOST_PREPROCESSOR_COMPARISON_NOT_EQUAL_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/iif.hpp> +# +# /* BOOST_PP_NOT_EQUAL */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_NOT_EQUAL(x, y) BOOST_PP_NOT_EQUAL_I(x, y) +# else +# define BOOST_PP_NOT_EQUAL(x, y) BOOST_PP_NOT_EQUAL_OO((x, y)) +# define BOOST_PP_NOT_EQUAL_OO(par) BOOST_PP_NOT_EQUAL_I ## par +# endif +# +# define BOOST_PP_NOT_EQUAL_I(x, y) BOOST_PP_CAT(BOOST_PP_NOT_EQUAL_CHECK_, BOOST_PP_NOT_EQUAL_ ## x(0, BOOST_PP_NOT_EQUAL_ ## y)) +# +# /* BOOST_PP_NOT_EQUAL_D */ +# +# define BOOST_PP_NOT_EQUAL_D(d, x, y) BOOST_PP_NOT_EQUAL(x, y) +# +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NIL 1 +# +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_0(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_1(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_2(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_3(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_4(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_5(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_6(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_7(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_8(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_9(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_10(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_11(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_12(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_13(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_14(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_15(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_16(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_17(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_18(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_19(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_20(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_21(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_22(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_23(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_24(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_25(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_26(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_27(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_28(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_29(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_30(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_31(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_32(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_33(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_34(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_35(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_36(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_37(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_38(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_39(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_40(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_41(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_42(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_43(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_44(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_45(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_46(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_47(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_48(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_49(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_50(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_51(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_52(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_53(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_54(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_55(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_56(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_57(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_58(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_59(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_60(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_61(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_62(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_63(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_64(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_65(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_66(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_67(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_68(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_69(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_70(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_71(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_72(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_73(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_74(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_75(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_76(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_77(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_78(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_79(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_80(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_81(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_82(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_83(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_84(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_85(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_86(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_87(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_88(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_89(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_90(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_91(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_92(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_93(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_94(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_95(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_96(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_97(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_98(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_99(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_100(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_101(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_102(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_103(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_104(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_105(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_106(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_107(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_108(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_109(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_110(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_111(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_112(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_113(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_114(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_115(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_116(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_117(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_118(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_119(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_120(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_121(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_122(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_123(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_124(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_125(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_126(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_127(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_128(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_129(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_130(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_131(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_132(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_133(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_134(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_135(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_136(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_137(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_138(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_139(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_140(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_141(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_142(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_143(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_144(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_145(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_146(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_147(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_148(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_149(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_150(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_151(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_152(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_153(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_154(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_155(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_156(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_157(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_158(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_159(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_160(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_161(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_162(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_163(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_164(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_165(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_166(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_167(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_168(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_169(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_170(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_171(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_172(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_173(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_174(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_175(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_176(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_177(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_178(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_179(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_180(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_181(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_182(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_183(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_184(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_185(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_186(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_187(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_188(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_189(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_190(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_191(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_192(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_193(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_194(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_195(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_196(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_197(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_198(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_199(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_200(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_201(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_202(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_203(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_204(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_205(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_206(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_207(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_208(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_209(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_210(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_211(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_212(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_213(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_214(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_215(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_216(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_217(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_218(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_219(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_220(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_221(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_222(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_223(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_224(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_225(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_226(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_227(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_228(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_229(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_230(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_231(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_232(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_233(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_234(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_235(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_236(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_237(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_238(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_239(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_240(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_241(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_242(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_243(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_244(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_245(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_246(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_247(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_248(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_249(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_250(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_251(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_252(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_253(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_254(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_255(c, y) 0 +# define BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_256(c, y) 0 +# +#if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() +# define BOOST_PP_NOT_EQUAL_0(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_1(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_2(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_3(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_4(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_5(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_6(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_7(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_8(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_9(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_10(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_11(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_12(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_13(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_14(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_15(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_16(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_17(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_18(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_19(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_20(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_21(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_22(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_23(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_24(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_25(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_26(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_27(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_28(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_29(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_30(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_31(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_32(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_33(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_34(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_35(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_36(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_37(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_38(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_39(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_40(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_41(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_42(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_43(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_44(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_45(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_46(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_47(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_48(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_49(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_50(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_51(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_52(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_53(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_54(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_55(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_56(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_57(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_58(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_59(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_60(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_61(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_62(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_63(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_64(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_65(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_66(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_67(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_68(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_69(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_70(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_71(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_72(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_73(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_74(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_75(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_76(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_77(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_78(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_79(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_80(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_81(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_82(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_83(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_84(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_85(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_86(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_87(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_88(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_89(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_90(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_91(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_92(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_93(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_94(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_95(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_96(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_97(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_98(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_99(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_100(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_101(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_102(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_103(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_104(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_105(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_106(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_107(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_108(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_109(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_110(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_111(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_112(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_113(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_114(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_115(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_116(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_117(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_118(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_119(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_120(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_121(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_122(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_123(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_124(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_125(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_126(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_127(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_128(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_129(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_130(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_131(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_132(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_133(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_134(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_135(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_136(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_137(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_138(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_139(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_140(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_141(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_142(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_143(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_144(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_145(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_146(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_147(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_148(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_149(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_150(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_151(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_152(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_153(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_154(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_155(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_156(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_157(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_158(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_159(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_160(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_161(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_162(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_163(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_164(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_165(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_166(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_167(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_168(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_169(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_170(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_171(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_172(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_173(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_174(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_175(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_176(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_177(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_178(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_179(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_180(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_181(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_182(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_183(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_184(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_185(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_186(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_187(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_188(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_189(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_190(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_191(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_192(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_193(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_194(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_195(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_196(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_197(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_198(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_199(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_200(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_201(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_202(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_203(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_204(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_205(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_206(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_207(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_208(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_209(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_210(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_211(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_212(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_213(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_214(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_215(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_216(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_217(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_218(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_219(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_220(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_221(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_222(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_223(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_224(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_225(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_226(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_227(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_228(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_229(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_230(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_231(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_232(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_233(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_234(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_235(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_236(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_237(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_238(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_239(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_240(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_241(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_242(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_243(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_244(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_245(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_246(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_247(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_248(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_249(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_250(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_251(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_252(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_253(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_254(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_255(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_256(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y(1, BOOST_PP_NIL)) +# else +# define BOOST_PP_NOT_EQUAL_0(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_1(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_2(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_3(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_4(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_5(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_6(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_7(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_8(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_9(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_10(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_11(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_12(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_13(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_14(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_15(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_16(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_17(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_18(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_19(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_20(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_21(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_22(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_23(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_24(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_25(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_26(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_27(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_28(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_29(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_30(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_31(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_32(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_33(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_34(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_35(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_36(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_37(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_38(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_39(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_40(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_41(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_42(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_43(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_44(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_45(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_46(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_47(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_48(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_49(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_50(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_51(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_52(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_53(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_54(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_55(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_56(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_57(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_58(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_59(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_60(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_61(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_62(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_63(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_64(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_65(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_66(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_67(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_68(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_69(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_70(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_71(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_72(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_73(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_74(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_75(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_76(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_77(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_78(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_79(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_80(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_81(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_82(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_83(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_84(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_85(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_86(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_87(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_88(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_89(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_90(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_91(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_92(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_93(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_94(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_95(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_96(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_97(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_98(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_99(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_100(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_101(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_102(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_103(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_104(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_105(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_106(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_107(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_108(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_109(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_110(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_111(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_112(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_113(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_114(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_115(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_116(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_117(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_118(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_119(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_120(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_121(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_122(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_123(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_124(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_125(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_126(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_127(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_128(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_129(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_130(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_131(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_132(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_133(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_134(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_135(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_136(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_137(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_138(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_139(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_140(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_141(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_142(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_143(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_144(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_145(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_146(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_147(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_148(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_149(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_150(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_151(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_152(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_153(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_154(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_155(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_156(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_157(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_158(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_159(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_160(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_161(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_162(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_163(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_164(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_165(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_166(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_167(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_168(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_169(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_170(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_171(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_172(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_173(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_174(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_175(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_176(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_177(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_178(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_179(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_180(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_181(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_182(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_183(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_184(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_185(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_186(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_187(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_188(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_189(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_190(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_191(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_192(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_193(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_194(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_195(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_196(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_197(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_198(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_199(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_200(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_201(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_202(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_203(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_204(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_205(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_206(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_207(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_208(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_209(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_210(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_211(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_212(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_213(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_214(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_215(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_216(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_217(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_218(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_219(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_220(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_221(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_222(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_223(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_224(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_225(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_226(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_227(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_228(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_229(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_230(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_231(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_232(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_233(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_234(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_235(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_236(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_237(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_238(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_239(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_240(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_241(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_242(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_243(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_244(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_245(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_246(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_247(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_248(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_249(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_250(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_251(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_252(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_253(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_254(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_255(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# define BOOST_PP_NOT_EQUAL_256(c, y) BOOST_PP_IIF(c, BOOST_PP_NIL, y##(1, BOOST_PP_NIL)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/config/limits.hpp b/src/third_party/boost/boost/preprocessor/config/limits.hpp new file mode 100644 index 00000000000..f312f299041 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/config/limits.hpp @@ -0,0 +1,30 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# /* Revised by Edward Diener (2011) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_CONFIG_LIMITS_HPP +# define BOOST_PREPROCESSOR_CONFIG_LIMITS_HPP +# +# define BOOST_PP_LIMIT_MAG 256 +# define BOOST_PP_LIMIT_TUPLE 64 +# define BOOST_PP_LIMIT_DIM 3 +# define BOOST_PP_LIMIT_REPEAT 256 +# define BOOST_PP_LIMIT_WHILE 256 +# define BOOST_PP_LIMIT_FOR 256 +# define BOOST_PP_LIMIT_ITERATION 256 +# define BOOST_PP_LIMIT_ITERATION_DIM 3 +# define BOOST_PP_LIMIT_SEQ 256 +# define BOOST_PP_LIMIT_SLOT_SIG 10 +# define BOOST_PP_LIMIT_SLOT_COUNT 5 +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/control.hpp b/src/third_party/boost/boost/preprocessor/control.hpp new file mode 100644 index 00000000000..809fbd9e237 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/control.hpp @@ -0,0 +1,22 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_CONTROL_HPP +# define BOOST_PREPROCESSOR_CONTROL_HPP +# +# include <boost/preprocessor/control/deduce_d.hpp> +# include <boost/preprocessor/control/expr_if.hpp> +# include <boost/preprocessor/control/expr_iif.hpp> +# include <boost/preprocessor/control/if.hpp> +# include <boost/preprocessor/control/iif.hpp> +# include <boost/preprocessor/control/while.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/debug.hpp b/src/third_party/boost/boost/preprocessor/debug.hpp new file mode 100644 index 00000000000..d09983e032f --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/debug.hpp @@ -0,0 +1,18 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_DEBUG_HPP +# define BOOST_PREPROCESSOR_DEBUG_HPP +# +# include <boost/preprocessor/debug/assert.hpp> +# include <boost/preprocessor/debug/line.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/debug/assert.hpp b/src/third_party/boost/boost/preprocessor/debug/assert.hpp new file mode 100644 index 00000000000..3380c7028a5 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/debug/assert.hpp @@ -0,0 +1,44 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_DEBUG_ASSERT_HPP +# define BOOST_PREPROCESSOR_DEBUG_ASSERT_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/expr_iif.hpp> +# include <boost/preprocessor/control/iif.hpp> +# include <boost/preprocessor/logical/not.hpp> +# include <boost/preprocessor/tuple/eat.hpp> +# +# /* BOOST_PP_ASSERT */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ASSERT BOOST_PP_ASSERT_D +# else +# define BOOST_PP_ASSERT(cond) BOOST_PP_ASSERT_D(cond) +# endif +# +# define BOOST_PP_ASSERT_D(cond) BOOST_PP_IIF(BOOST_PP_NOT(cond), BOOST_PP_ASSERT_ERROR, BOOST_PP_TUPLE_EAT_1)(...) +# define BOOST_PP_ASSERT_ERROR(x, y, z) +# +# /* BOOST_PP_ASSERT_MSG */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ASSERT_MSG BOOST_PP_ASSERT_MSG_D +# else +# define BOOST_PP_ASSERT_MSG(cond, msg) BOOST_PP_ASSERT_MSG_D(cond, msg) +# endif +# +# define BOOST_PP_ASSERT_MSG_D(cond, msg) BOOST_PP_EXPR_IIF(BOOST_PP_NOT(cond), msg) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/debug/line.hpp b/src/third_party/boost/boost/preprocessor/debug/line.hpp new file mode 100644 index 00000000000..4dd1013c1a8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/debug/line.hpp @@ -0,0 +1,35 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_DEBUG_LINE_HPP +# define BOOST_PREPROCESSOR_DEBUG_LINE_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/iteration/iterate.hpp> +# include <boost/preprocessor/stringize.hpp> +# +# /* BOOST_PP_LINE */ +# +# if BOOST_PP_CONFIG_EXTENDED_LINE_INFO +# define BOOST_PP_LINE(line, file) line BOOST_PP_CAT(BOOST_PP_LINE_, BOOST_PP_IS_ITERATING)(file) +# define BOOST_PP_LINE_BOOST_PP_IS_ITERATING(file) #file +# define BOOST_PP_LINE_1(file) BOOST_PP_STRINGIZE(file BOOST_PP_CAT(BOOST_PP_LINE_I_, BOOST_PP_ITERATION_DEPTH())()) +# define BOOST_PP_LINE_I_1() [BOOST_PP_FRAME_ITERATION(1)] +# define BOOST_PP_LINE_I_2() BOOST_PP_LINE_I_1()[BOOST_PP_FRAME_ITERATION(2)] +# define BOOST_PP_LINE_I_3() BOOST_PP_LINE_I_2()[BOOST_PP_FRAME_ITERATION(3)] +# define BOOST_PP_LINE_I_4() BOOST_PP_LINE_I_3()[BOOST_PP_FRAME_ITERATION(4)] +# define BOOST_PP_LINE_I_5() BOOST_PP_LINE_I_4()[BOOST_PP_FRAME_ITERATION(5)] +# else +# define BOOST_PP_LINE(line, file) line __FILE__ +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/detail/is_nullary.hpp b/src/third_party/boost/boost/preprocessor/detail/is_nullary.hpp new file mode 100644 index 00000000000..dee4075adb3 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/detail/is_nullary.hpp @@ -0,0 +1,30 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_DETAIL_IS_NULLARY_HPP +# define BOOST_PREPROCESSOR_DETAIL_IS_NULLARY_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/detail/check.hpp> +# +# /* BOOST_PP_IS_NULLARY */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_IS_NULLARY(x) BOOST_PP_CHECK(x, BOOST_PP_IS_NULLARY_CHECK) +# else +# define BOOST_PP_IS_NULLARY(x) BOOST_PP_IS_NULLARY_I(x) +# define BOOST_PP_IS_NULLARY_I(x) BOOST_PP_CHECK(x, BOOST_PP_IS_NULLARY_CHECK) +# endif +# +# define BOOST_PP_IS_NULLARY_CHECK() 1 +# define BOOST_PP_CHECK_RESULT_BOOST_PP_IS_NULLARY_CHECK 0, BOOST_PP_NIL +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/detail/null.hpp b/src/third_party/boost/boost/preprocessor/detail/null.hpp new file mode 100644 index 00000000000..5eb0bd4ca9a --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/detail/null.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_DETAIL_NULL_HPP +# define BOOST_PREPROCESSOR_DETAIL_NULL_HPP +# +# /* empty file */ +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/detail/split.hpp b/src/third_party/boost/boost/preprocessor/detail/split.hpp new file mode 100644 index 00000000000..f28a72375d8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/detail/split.hpp @@ -0,0 +1,35 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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) +# * * +# ************************************************************************** */ +# +# ifndef BOOST_PREPROCESSOR_DETAIL_SPLIT_HPP +# define BOOST_PREPROCESSOR_DETAIL_SPLIT_HPP +# +# include <boost/preprocessor/config/config.hpp> +# +# /* BOOST_PP_SPLIT */ +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_SPLIT(n, im) BOOST_PP_SPLIT_I((n, im)) +# define BOOST_PP_SPLIT_I(par) BOOST_PP_SPLIT_II ## par +# define BOOST_PP_SPLIT_II(n, a, b) BOOST_PP_SPLIT_ ## n(a, b) +# elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_SPLIT(n, im) BOOST_PP_SPLIT_I(n((im))) +# define BOOST_PP_SPLIT_I(n) BOOST_PP_SPLIT_ID(BOOST_PP_SPLIT_II_ ## n) +# define BOOST_PP_SPLIT_II_0(s) BOOST_PP_SPLIT_ID(BOOST_PP_SPLIT_0 s) +# define BOOST_PP_SPLIT_II_1(s) BOOST_PP_SPLIT_ID(BOOST_PP_SPLIT_1 s) +# define BOOST_PP_SPLIT_ID(id) id +# else +# define BOOST_PP_SPLIT(n, im) BOOST_PP_SPLIT_I(n)(im) +# define BOOST_PP_SPLIT_I(n) BOOST_PP_SPLIT_ ## n +# endif +# +# define BOOST_PP_SPLIT_0(a, b) a +# define BOOST_PP_SPLIT_1(a, b) b +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/enum_shifted.hpp b/src/third_party/boost/boost/preprocessor/enum_shifted.hpp new file mode 100644 index 00000000000..aa6a698d52e --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/enum_shifted.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ENUM_SHIFTED_HPP +# define BOOST_PREPROCESSOR_ENUM_SHIFTED_HPP +# +# include <boost/preprocessor/repetition/enum_shifted.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/expand.hpp b/src/third_party/boost/boost/preprocessor/expand.hpp new file mode 100644 index 00000000000..8c5d972d2f2 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/expand.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_EXPAND_HPP +# define BOOST_PREPROCESSOR_EXPAND_HPP +# +# include <boost/preprocessor/facilities/expand.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/facilities.hpp b/src/third_party/boost/boost/preprocessor/facilities.hpp new file mode 100644 index 00000000000..c20547cb73b --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/facilities.hpp @@ -0,0 +1,23 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002-2011. * +# * (C) Copyright Edward Diener 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FACILITIES_HPP +# define BOOST_PREPROCESSOR_FACILITIES_HPP +# +# include <boost/preprocessor/facilities/apply.hpp> +# include <boost/preprocessor/facilities/empty.hpp> +# include <boost/preprocessor/facilities/expand.hpp> +# include <boost/preprocessor/facilities/identity.hpp> +# include <boost/preprocessor/facilities/intercept.hpp> +# include <boost/preprocessor/facilities/overload.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/facilities/apply.hpp b/src/third_party/boost/boost/preprocessor/facilities/apply.hpp new file mode 100644 index 00000000000..e7d8c36bd5d --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/facilities/apply.hpp @@ -0,0 +1,34 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FACILITIES_APPLY_HPP +# define BOOST_PREPROCESSOR_FACILITIES_APPLY_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/expr_iif.hpp> +# include <boost/preprocessor/detail/is_unary.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_APPLY */ +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_APPLY(x) BOOST_PP_APPLY_I(x) +# define BOOST_PP_APPLY_I(x) BOOST_PP_EXPR_IIF(BOOST_PP_IS_UNARY(x), BOOST_PP_TUPLE_REM_1 x) +# elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_BCC() +# define BOOST_PP_APPLY(x) BOOST_PP_APPLY_I(x) +# define BOOST_PP_APPLY_I(x) BOOST_PP_APPLY_ ## x +# define BOOST_PP_APPLY_(x) x +# define BOOST_PP_APPLY_BOOST_PP_NIL +# else +# define BOOST_PP_APPLY(x) BOOST_PP_EXPR_IIF(BOOST_PP_IS_UNARY(x), BOOST_PP_TUPLE_REM_1 x) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/facilities/expand.hpp b/src/third_party/boost/boost/preprocessor/facilities/expand.hpp new file mode 100644 index 00000000000..c8661a1c221 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/facilities/expand.hpp @@ -0,0 +1,28 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FACILITIES_EXPAND_HPP +# define BOOST_PREPROCESSOR_FACILITIES_EXPAND_HPP +# +# include <boost/preprocessor/config/config.hpp> +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() +# define BOOST_PP_EXPAND(x) BOOST_PP_EXPAND_I(x) +# else +# define BOOST_PP_EXPAND(x) BOOST_PP_EXPAND_OO((x)) +# define BOOST_PP_EXPAND_OO(par) BOOST_PP_EXPAND_I ## par +# endif +# +# define BOOST_PP_EXPAND_I(x) x +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/facilities/is_1.hpp b/src/third_party/boost/boost/preprocessor/facilities/is_1.hpp new file mode 100644 index 00000000000..f286dcdd19b --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/facilities/is_1.hpp @@ -0,0 +1,23 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2003. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FACILITIES_IS_1_HPP +# define BOOST_PREPROCESSOR_FACILITIES_IS_1_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/facilities/is_empty.hpp> +# +# /* BOOST_PP_IS_1 */ +# +# define BOOST_PP_IS_1(x) BOOST_PP_IS_EMPTY(BOOST_PP_CAT(BOOST_PP_IS_1_HELPER_, x)) +# define BOOST_PP_IS_1_HELPER_1 +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/facilities/is_empty.hpp b/src/third_party/boost/boost/preprocessor/facilities/is_empty.hpp new file mode 100644 index 00000000000..638265c57f8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/facilities/is_empty.hpp @@ -0,0 +1,43 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2003. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP +# define BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/facilities/empty.hpp> +# include <boost/preprocessor/detail/split.hpp> +# +# /* BOOST_PP_IS_EMPTY */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_IS_EMPTY(x) BOOST_PP_IS_EMPTY_I(x BOOST_PP_IS_EMPTY_HELPER) +# define BOOST_PP_IS_EMPTY_I(contents) BOOST_PP_TUPLE_ELEM(2, 1, (BOOST_PP_IS_EMPTY_DEF_ ## contents())) +# define BOOST_PP_IS_EMPTY_DEF_BOOST_PP_IS_EMPTY_HELPER 1, 1 BOOST_PP_EMPTY +# define BOOST_PP_IS_EMPTY_HELPER() , 0 +# else +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_IS_EMPTY(x) BOOST_PP_IS_EMPTY_I(BOOST_PP_IS_EMPTY_HELPER x ()) +# define BOOST_PP_IS_EMPTY_I(test) BOOST_PP_IS_EMPTY_II(BOOST_PP_SPLIT(0, BOOST_PP_CAT(BOOST_PP_IS_EMPTY_DEF_, test))) +# define BOOST_PP_IS_EMPTY_II(id) id +# else +# define BOOST_PP_IS_EMPTY(x) BOOST_PP_IS_EMPTY_I((BOOST_PP_IS_EMPTY_HELPER x ())) +# define BOOST_PP_IS_EMPTY_I(par) BOOST_PP_IS_EMPTY_II ## par +# define BOOST_PP_IS_EMPTY_II(test) BOOST_PP_SPLIT(0, BOOST_PP_CAT(BOOST_PP_IS_EMPTY_DEF_, test)) +# endif +# define BOOST_PP_IS_EMPTY_HELPER() 1 +# define BOOST_PP_IS_EMPTY_DEF_1 1, BOOST_PP_NIL +# define BOOST_PP_IS_EMPTY_DEF_BOOST_PP_IS_EMPTY_HELPER 0, BOOST_PP_NIL +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/facilities/is_empty_or_1.hpp b/src/third_party/boost/boost/preprocessor/facilities/is_empty_or_1.hpp new file mode 100644 index 00000000000..baa5da9a656 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/facilities/is_empty_or_1.hpp @@ -0,0 +1,30 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2003. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_OR_1_HPP +# define BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_OR_1_HPP +# +# include <boost/preprocessor/control/iif.hpp> +# include <boost/preprocessor/facilities/empty.hpp> +# include <boost/preprocessor/facilities/is_1.hpp> +# include <boost/preprocessor/facilities/is_empty.hpp> +# +# /* BOOST_PP_IS_EMPTY_OR_1 */ +# +# define BOOST_PP_IS_EMPTY_OR_1(x) \ + BOOST_PP_IIF( \ + BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()), \ + 1 BOOST_PP_EMPTY, \ + BOOST_PP_IS_1 \ + )(x) \ + /**/ +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/for.hpp b/src/third_party/boost/boost/preprocessor/for.hpp new file mode 100644 index 00000000000..9ec9cee67a0 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/for.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FOR_HPP +# define BOOST_PREPROCESSOR_FOR_HPP +# +# include <boost/preprocessor/repetition/for.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/iteration.hpp b/src/third_party/boost/boost/preprocessor/iteration.hpp new file mode 100644 index 00000000000..1055ac00a9c --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/iteration.hpp @@ -0,0 +1,19 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ITERATION_HPP +# define BOOST_PREPROCESSOR_ITERATION_HPP +# +# include <boost/preprocessor/iteration/iterate.hpp> +# include <boost/preprocessor/iteration/local.hpp> +# include <boost/preprocessor/iteration/self.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/library.hpp b/src/third_party/boost/boost/preprocessor/library.hpp new file mode 100644 index 00000000000..aa5b7778498 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/library.hpp @@ -0,0 +1,36 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002-2011. * +# * (C) Copyright Edward Diener 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIBRARY_HPP +# define BOOST_PREPROCESSOR_LIBRARY_HPP +# +# include <boost/preprocessor/arithmetic.hpp> +# include <boost/preprocessor/array.hpp> +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/comparison.hpp> +# include <boost/preprocessor/config/limits.hpp> +# include <boost/preprocessor/control.hpp> +# include <boost/preprocessor/debug.hpp> +# include <boost/preprocessor/facilities.hpp> +# include <boost/preprocessor/iteration.hpp> +# include <boost/preprocessor/list.hpp> +# include <boost/preprocessor/logical.hpp> +# include <boost/preprocessor/punctuation.hpp> +# include <boost/preprocessor/repetition.hpp> +# include <boost/preprocessor/selection.hpp> +# include <boost/preprocessor/seq.hpp> +# include <boost/preprocessor/slot.hpp> +# include <boost/preprocessor/stringize.hpp> +# include <boost/preprocessor/tuple.hpp> +# include <boost/preprocessor/variadic.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/limits.hpp b/src/third_party/boost/boost/preprocessor/limits.hpp new file mode 100644 index 00000000000..e264cc3c83a --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/limits.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIMITS_HPP +# define BOOST_PREPROCESSOR_LIMITS_HPP +# +# include <boost/preprocessor/config/limits.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list.hpp b/src/third_party/boost/boost/preprocessor/list.hpp new file mode 100644 index 00000000000..ef592c21879 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list.hpp @@ -0,0 +1,37 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_HPP +# define BOOST_PREPROCESSOR_LIST_HPP +# +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/list/append.hpp> +# include <boost/preprocessor/list/at.hpp> +# include <boost/preprocessor/list/cat.hpp> +# include <boost/preprocessor/list/enum.hpp> +# include <boost/preprocessor/list/filter.hpp> +# include <boost/preprocessor/list/first_n.hpp> +# include <boost/preprocessor/list/fold_left.hpp> +# include <boost/preprocessor/list/fold_right.hpp> +# include <boost/preprocessor/list/for_each.hpp> +# include <boost/preprocessor/list/for_each_i.hpp> +# include <boost/preprocessor/list/for_each_product.hpp> +# include <boost/preprocessor/list/rest_n.hpp> +# include <boost/preprocessor/list/reverse.hpp> +# include <boost/preprocessor/list/size.hpp> +# include <boost/preprocessor/list/to_array.hpp> +# include <boost/preprocessor/list/to_seq.hpp> +# include <boost/preprocessor/list/to_tuple.hpp> +# include <boost/preprocessor/list/transform.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/at.hpp b/src/third_party/boost/boost/preprocessor/list/at.hpp new file mode 100644 index 00000000000..125669b38af --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/at.hpp @@ -0,0 +1,39 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_AT_HPP +# define BOOST_PREPROCESSOR_LIST_AT_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/list/rest_n.hpp> +# +# /* BOOST_PP_LIST_AT */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_AT(list, index) BOOST_PP_LIST_FIRST(BOOST_PP_LIST_REST_N(index, list)) +# else +# define BOOST_PP_LIST_AT(list, index) BOOST_PP_LIST_AT_I(list, index) +# define BOOST_PP_LIST_AT_I(list, index) BOOST_PP_LIST_FIRST(BOOST_PP_LIST_REST_N(index, list)) +# endif +# +# /* BOOST_PP_LIST_AT_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_AT_D(d, list, index) BOOST_PP_LIST_FIRST(BOOST_PP_LIST_REST_N_D(d, index, list)) +# else +# define BOOST_PP_LIST_AT_D(d, list, index) BOOST_PP_LIST_AT_D_I(d, list, index) +# define BOOST_PP_LIST_AT_D_I(d, list, index) BOOST_PP_LIST_FIRST(BOOST_PP_LIST_REST_N_D(d, index, list)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/cat.hpp b/src/third_party/boost/boost/preprocessor/list/cat.hpp new file mode 100644 index 00000000000..1ef74bf1518 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/cat.hpp @@ -0,0 +1,42 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_CAT_HPP +# define BOOST_PREPROCESSOR_LIST_CAT_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/list/fold_left.hpp> +# +# /* BOOST_PP_LIST_CAT */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_CAT(list) BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list)) +# else +# define BOOST_PP_LIST_CAT(list) BOOST_PP_LIST_CAT_I(list) +# define BOOST_PP_LIST_CAT_I(list) BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list)) +# endif +# +# define BOOST_PP_LIST_CAT_O(d, s, x) BOOST_PP_CAT(s, x) +# +# /* BOOST_PP_LIST_CAT_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_CAT_D(d, list) BOOST_PP_LIST_FOLD_LEFT_ ## d(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list)) +# else +# define BOOST_PP_LIST_CAT_D(d, list) BOOST_PP_LIST_CAT_D_I(d, list) +# define BOOST_PP_LIST_CAT_D_I(d, list) BOOST_PP_LIST_FOLD_LEFT_ ## d(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/enum.hpp b/src/third_party/boost/boost/preprocessor/list/enum.hpp new file mode 100644 index 00000000000..1eabea6ef81 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/enum.hpp @@ -0,0 +1,41 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_ENUM_HPP +# define BOOST_PREPROCESSOR_LIST_ENUM_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/list/for_each_i.hpp> +# include <boost/preprocessor/punctuation/comma_if.hpp> +# +# /* BOOST_PP_LIST_ENUM */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_ENUM(list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list) +# else +# define BOOST_PP_LIST_ENUM(list) BOOST_PP_LIST_ENUM_I(list) +# define BOOST_PP_LIST_ENUM_I(list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list) +# endif +# +# define BOOST_PP_LIST_ENUM_O(r, _, i, elem) BOOST_PP_COMMA_IF(i) elem +# +# /* BOOST_PP_LIST_ENUM_R */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_ENUM_R(r, list) BOOST_PP_LIST_FOR_EACH_I_R(r, BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list) +# else +# define BOOST_PP_LIST_ENUM_R(r, list) BOOST_PP_LIST_ENUM_R_I(r, list) +# define BOOST_PP_LIST_ENUM_R_I(r, list) BOOST_PP_LIST_FOR_EACH_I_R(r, BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/filter.hpp b/src/third_party/boost/boost/preprocessor/list/filter.hpp new file mode 100644 index 00000000000..9e0faab6c5d --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/filter.hpp @@ -0,0 +1,54 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_FILTER_HPP +# define BOOST_PREPROCESSOR_LIST_FILTER_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/if.hpp> +# include <boost/preprocessor/list/fold_right.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_LIST_FILTER */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FILTER(pred, data, list) BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_LIST_FOLD_RIGHT(BOOST_PP_LIST_FILTER_O, (pred, data, BOOST_PP_NIL), list)) +# else +# define BOOST_PP_LIST_FILTER(pred, data, list) BOOST_PP_LIST_FILTER_I(pred, data, list) +# define BOOST_PP_LIST_FILTER_I(pred, data, list) BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_LIST_FOLD_RIGHT(BOOST_PP_LIST_FILTER_O, (pred, data, BOOST_PP_NIL), list)) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FILTER_O(d, pdr, elem) BOOST_PP_LIST_FILTER_O_D(d, BOOST_PP_TUPLE_ELEM(3, 0, pdr), BOOST_PP_TUPLE_ELEM(3, 1, pdr), BOOST_PP_TUPLE_ELEM(3, 2, pdr), elem) +# else +# define BOOST_PP_LIST_FILTER_O(d, pdr, elem) BOOST_PP_LIST_FILTER_O_I(d, BOOST_PP_TUPLE_REM_3 pdr, elem) +# define BOOST_PP_LIST_FILTER_O_I(d, im, elem) BOOST_PP_LIST_FILTER_O_D(d, im, elem) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() +# define BOOST_PP_LIST_FILTER_O_D(d, pred, data, res, elem) (pred, data, BOOST_PP_IF(pred(d, data, elem), (elem, res), res)) +# else +# define BOOST_PP_LIST_FILTER_O_D(d, pred, data, res, elem) (pred, data, BOOST_PP_IF(pred##(d, data, elem), (elem, res), res)) +# endif +# +# /* BOOST_PP_LIST_FILTER_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FILTER_D(d, pred, data, list) BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_LIST_FOLD_RIGHT_ ## d(BOOST_PP_LIST_FILTER_O, (pred, data, BOOST_PP_NIL), list)) +# else +# define BOOST_PP_LIST_FILTER_D(d, pred, data, list) BOOST_PP_LIST_FILTER_D_I(d, pred, data, list) +# define BOOST_PP_LIST_FILTER_D_I(d, pred, data, list) BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_LIST_FOLD_RIGHT_ ## d(BOOST_PP_LIST_FILTER_O, (pred, data, BOOST_PP_NIL), list)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/first_n.hpp b/src/third_party/boost/boost/preprocessor/list/first_n.hpp new file mode 100644 index 00000000000..5e60c502c8e --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/first_n.hpp @@ -0,0 +1,58 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_FIRST_N_HPP +# define BOOST_PREPROCESSOR_LIST_FIRST_N_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/list/reverse.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_LIST_FIRST_N */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FIRST_N(count, list) BOOST_PP_LIST_REVERSE(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL)))) +# else +# define BOOST_PP_LIST_FIRST_N(count, list) BOOST_PP_LIST_FIRST_N_I(count, list) +# define BOOST_PP_LIST_FIRST_N_I(count, list) BOOST_PP_LIST_REVERSE(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL)))) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FIRST_N_P(d, data) BOOST_PP_TUPLE_ELEM(3, 0, data) +# else +# define BOOST_PP_LIST_FIRST_N_P(d, data) BOOST_PP_LIST_FIRST_N_P_I data +# define BOOST_PP_LIST_FIRST_N_P_I(c, l, nl) c +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_LIST_FIRST_N_O(d, data) BOOST_PP_LIST_FIRST_N_O_D data +# else +# define BOOST_PP_LIST_FIRST_N_O(d, data) BOOST_PP_LIST_FIRST_N_O_D(BOOST_PP_TUPLE_ELEM(3, 0, data), BOOST_PP_TUPLE_ELEM(3, 1, data), BOOST_PP_TUPLE_ELEM(3, 2, data)) +# endif +# +# define BOOST_PP_LIST_FIRST_N_O_D(c, l, nl) (BOOST_PP_DEC(c), BOOST_PP_LIST_REST(l), (BOOST_PP_LIST_FIRST(l), nl)) +# +# /* BOOST_PP_LIST_FIRST_N_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FIRST_N_D(d, count, list) BOOST_PP_LIST_REVERSE_D(d, BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL)))) +# else +# define BOOST_PP_LIST_FIRST_N_D(d, count, list) BOOST_PP_LIST_FIRST_N_D_I(d, count, list) +# define BOOST_PP_LIST_FIRST_N_D_I(d, count, list) BOOST_PP_LIST_REVERSE_D(d, BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL)))) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/for_each.hpp b/src/third_party/boost/boost/preprocessor/list/for_each.hpp new file mode 100644 index 00000000000..dd04eaa5df5 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/for_each.hpp @@ -0,0 +1,49 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_FOR_EACH_HPP +# define BOOST_PREPROCESSOR_LIST_FOR_EACH_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/list/for_each_i.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_LIST_FOR_EACH */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FOR_EACH(macro, data, list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_FOR_EACH_O, (macro, data), list) +# else +# define BOOST_PP_LIST_FOR_EACH(macro, data, list) BOOST_PP_LIST_FOR_EACH_X(macro, data, list) +# define BOOST_PP_LIST_FOR_EACH_X(macro, data, list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_FOR_EACH_O, (macro, data), list) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FOR_EACH_O(r, md, i, elem) BOOST_PP_LIST_FOR_EACH_O_D(r, BOOST_PP_TUPLE_ELEM(2, 0, md), BOOST_PP_TUPLE_ELEM(2, 1, md), elem) +# else +# define BOOST_PP_LIST_FOR_EACH_O(r, md, i, elem) BOOST_PP_LIST_FOR_EACH_O_I(r, BOOST_PP_TUPLE_REM_2 md, elem) +# define BOOST_PP_LIST_FOR_EACH_O_I(r, im, elem) BOOST_PP_LIST_FOR_EACH_O_D(r, im, elem) +# endif +# +# define BOOST_PP_LIST_FOR_EACH_O_D(r, m, d, elem) m(r, d, elem) +# +# /* BOOST_PP_LIST_FOR_EACH_R */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FOR_EACH_R(r, macro, data, list) BOOST_PP_LIST_FOR_EACH_I_R(r, BOOST_PP_LIST_FOR_EACH_O, (macro, data), list) +# else +# define BOOST_PP_LIST_FOR_EACH_R(r, macro, data, list) BOOST_PP_LIST_FOR_EACH_R_X(r, macro, data, list) +# define BOOST_PP_LIST_FOR_EACH_R_X(r, macro, data, list) BOOST_PP_LIST_FOR_EACH_I_R(r, BOOST_PP_LIST_FOR_EACH_O, (macro, data), list) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/for_each_product.hpp b/src/third_party/boost/boost/preprocessor/list/for_each_product.hpp new file mode 100644 index 00000000000..6d5319b06d0 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/for_each_product.hpp @@ -0,0 +1,141 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_FOR_EACH_PRODUCT_HPP +# define BOOST_PREPROCESSOR_LIST_FOR_EACH_PRODUCT_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/if.hpp> +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/list/to_tuple.hpp> +# include <boost/preprocessor/repetition/for.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/to_list.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# include <boost/preprocessor/tuple/reverse.hpp> +# +# /* BOOST_PP_LIST_FOR_EACH_PRODUCT */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FOR_EACH_PRODUCT(macro, size, tuple) BOOST_PP_LIST_FOR_EACH_PRODUCT_E(BOOST_PP_FOR, macro, size, BOOST_PP_TUPLE_TO_LIST(size, tuple)) +# else +# define BOOST_PP_LIST_FOR_EACH_PRODUCT(macro, size, tuple) BOOST_PP_LIST_FOR_EACH_PRODUCT_Q(macro, size, tuple) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_Q(macro, size, tuple) BOOST_PP_LIST_FOR_EACH_PRODUCT_E(BOOST_PP_FOR, macro, size, BOOST_PP_TUPLE_TO_LIST(size, tuple)) +# endif +# +# /* BOOST_PP_LIST_FOR_EACH_PRODUCT_R */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_R(r, macro, size, tuple) BOOST_PP_LIST_FOR_EACH_PRODUCT_E(BOOST_PP_FOR_ ## r, macro, size, BOOST_PP_TUPLE_TO_LIST(size, tuple)) +# else +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_R(r, macro, size, tuple) BOOST_PP_LIST_FOR_EACH_PRODUCT_R_Q(r, macro, size, tuple) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_R_Q(r, macro, size, tuple) BOOST_PP_LIST_FOR_EACH_PRODUCT_E(BOOST_PP_FOR_ ## r, macro, size, BOOST_PP_TUPLE_TO_LIST(size, tuple)) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_E(impl, macro, size, lists) impl((BOOST_PP_LIST_FIRST(lists), BOOST_PP_LIST_REST(lists), BOOST_PP_NIL, macro, size), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_0) +# else +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_E(impl, macro, size, lists) BOOST_PP_LIST_FOR_EACH_PRODUCT_E_D(impl, macro, size, lists) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_E_D(impl, macro, size, lists) impl((BOOST_PP_LIST_FIRST(lists), BOOST_PP_LIST_REST(lists), BOOST_PP_NIL, macro, size), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_0) +# endif +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_P(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_P_I data +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_P_I(a, b, res, macro, size) BOOST_PP_LIST_IS_CONS(a) +# else +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_P(r, data) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(5, 0, data)) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_O(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_O_I data +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_O_I(a, b, res, macro, size) (BOOST_PP_LIST_REST(a), b, res, macro, size) +# else +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_O(r, data) (BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(5, 0, data)), BOOST_PP_TUPLE_ELEM(5, 1, data), BOOST_PP_TUPLE_ELEM(5, 2, data), BOOST_PP_TUPLE_ELEM(5, 3, data), BOOST_PP_TUPLE_ELEM(5, 4, data)) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_I(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_I_I(r, BOOST_PP_TUPLE_ELEM(5, 0, data), BOOST_PP_TUPLE_ELEM(5, 1, data), BOOST_PP_TUPLE_ELEM(5, 2, data), BOOST_PP_TUPLE_ELEM(5, 3, data), BOOST_PP_TUPLE_ELEM(5, 4, data)) +# else +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_I(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_I_D(r, BOOST_PP_TUPLE_REM_5 data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_I_D(r, data_e) BOOST_PP_LIST_FOR_EACH_PRODUCT_I_I(r, data_e) +# endif +# +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_I_I(r, a, b, res, macro, size) BOOST_PP_LIST_FOR_EACH_PRODUCT_I_II(r, macro, BOOST_PP_LIST_TO_TUPLE_R(r, (BOOST_PP_LIST_FIRST(a), res)), size) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_I_II(r, macro, args, size) BOOST_PP_LIST_FOR_EACH_PRODUCT_I_III(r, macro, args, size) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_I_III(r, macro, args, size) macro(r, BOOST_PP_TUPLE_REVERSE(size, args)) +# +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, i) BOOST_PP_IF(BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(5, 1, data)), BOOST_PP_LIST_FOR_EACH_PRODUCT_N_ ## i, BOOST_PP_LIST_FOR_EACH_PRODUCT_I) +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data) BOOST_PP_LIST_FOR_EACH_PRODUCT_H_I data +# else +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data) BOOST_PP_LIST_FOR_EACH_PRODUCT_H_I(BOOST_PP_TUPLE_ELEM(5, 0, data), BOOST_PP_TUPLE_ELEM(5, 1, data), BOOST_PP_TUPLE_ELEM(5, 2, data), BOOST_PP_TUPLE_ELEM(5, 3, data), BOOST_PP_TUPLE_ELEM(5, 4, data)) +# endif +# +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_H_I(a, b, res, macro, size) (BOOST_PP_LIST_FIRST(b), BOOST_PP_LIST_REST(b), (BOOST_PP_LIST_FIRST(a), res), macro, size) +# +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_0(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 0)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_1(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 1)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_2(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 2)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_3(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 3)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_4(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 4)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_5(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 5)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_6(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 6)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_7(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 7)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_8(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 8)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_9(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 9)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_10(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 10)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_11(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 11)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_12(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 12)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_13(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 13)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_14(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 14)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_15(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 15)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_16(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 16)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_17(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 17)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_18(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 18)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_19(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 19)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_20(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 20)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_21(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 21)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_22(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 22)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_23(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 23)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_24(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 24)(r, data) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_M_25(r, data) BOOST_PP_LIST_FOR_EACH_PRODUCT_C(data, 25)(r, data) +# +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_0(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_1) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_1(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_2) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_2(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_3) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_3(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_4) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_4(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_5) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_5(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_6) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_6(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_7) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_7(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_8) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_8(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_9) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_9(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_10) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_10(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_11) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_11(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_12) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_12(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_13) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_13(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_14) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_14(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_15) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_15(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_16) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_16(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_17) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_17(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_18) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_18(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_19) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_19(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_20) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_20(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_21) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_21(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_22) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_22(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_23) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_23(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_24) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_24(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_25) +# define BOOST_PP_LIST_FOR_EACH_PRODUCT_N_25(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_LIST_FOR_EACH_PRODUCT_H(data), BOOST_PP_LIST_FOR_EACH_PRODUCT_P, BOOST_PP_LIST_FOR_EACH_PRODUCT_O, BOOST_PP_LIST_FOR_EACH_PRODUCT_M_26) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/rest_n.hpp b/src/third_party/boost/boost/preprocessor/list/rest_n.hpp new file mode 100644 index 00000000000..b42ee5fe421 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/rest_n.hpp @@ -0,0 +1,55 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_REST_N_HPP +# define BOOST_PREPROCESSOR_LIST_REST_N_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# +# /* BOOST_PP_LIST_REST_N */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_REST_N(count, list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_LIST_REST_N_P, BOOST_PP_LIST_REST_N_O, (list, count))) +# else +# define BOOST_PP_LIST_REST_N(count, list) BOOST_PP_LIST_REST_N_I(count, list) +# define BOOST_PP_LIST_REST_N_I(count, list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_LIST_REST_N_P, BOOST_PP_LIST_REST_N_O, (list, count))) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_REST_N_P(d, lc) BOOST_PP_TUPLE_ELEM(2, 1, lc) +# else +# define BOOST_PP_LIST_REST_N_P(d, lc) BOOST_PP_LIST_REST_N_P_I lc +# define BOOST_PP_LIST_REST_N_P_I(list, count) count +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_REST_N_O(d, lc) (BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(2, 0, lc)), BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2, 1, lc))) +# else +# define BOOST_PP_LIST_REST_N_O(d, lc) BOOST_PP_LIST_REST_N_O_I lc +# define BOOST_PP_LIST_REST_N_O_I(list, count) (BOOST_PP_LIST_REST(list), BOOST_PP_DEC(count)) +# endif +# +# /* BOOST_PP_LIST_REST_N_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_REST_N_D(d, count, list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_REST_N_P, BOOST_PP_LIST_REST_N_O, (list, count))) +# else +# define BOOST_PP_LIST_REST_N_D(d, count, list) BOOST_PP_LIST_REST_N_D_I(d, count, list) +# define BOOST_PP_LIST_REST_N_D_I(d, count, list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_REST_N_P, BOOST_PP_LIST_REST_N_O, (list, count))) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/size.hpp b/src/third_party/boost/boost/preprocessor/list/size.hpp new file mode 100644 index 00000000000..0757fba80d3 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/size.hpp @@ -0,0 +1,58 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_SIZE_HPP +# define BOOST_PREPROCESSOR_LIST_SIZE_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_LIST_SIZE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_SIZE(list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_LIST_SIZE_P, BOOST_PP_LIST_SIZE_O, (0, list))) +# else +# define BOOST_PP_LIST_SIZE(list) BOOST_PP_LIST_SIZE_I(list) +# define BOOST_PP_LIST_SIZE_I(list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_LIST_SIZE_P, BOOST_PP_LIST_SIZE_O, (0, list))) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_SIZE_P(d, rl) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(2, 1, rl)) +# else +# define BOOST_PP_LIST_SIZE_P(d, rl) BOOST_PP_LIST_SIZE_P_I(BOOST_PP_TUPLE_REM_2 rl) +# define BOOST_PP_LIST_SIZE_P_I(im) BOOST_PP_LIST_SIZE_P_II(im) +# define BOOST_PP_LIST_SIZE_P_II(r, l) BOOST_PP_LIST_IS_CONS(l) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_SIZE_O(d, rl) (BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(2, 0, rl)), BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(2, 1, rl))) +# else +# define BOOST_PP_LIST_SIZE_O(d, rl) BOOST_PP_LIST_SIZE_O_I(BOOST_PP_TUPLE_REM_2 rl) +# define BOOST_PP_LIST_SIZE_O_I(im) BOOST_PP_LIST_SIZE_O_II(im) +# define BOOST_PP_LIST_SIZE_O_II(r, l) (BOOST_PP_INC(r), BOOST_PP_LIST_REST(l)) +# endif +# +# /* BOOST_PP_LIST_SIZE_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_SIZE_D(d, list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_SIZE_P, BOOST_PP_LIST_SIZE_O, (0, list))) +# else +# define BOOST_PP_LIST_SIZE_D(d, list) BOOST_PP_LIST_SIZE_D_I(d, list) +# define BOOST_PP_LIST_SIZE_D_I(d, list) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_SIZE_P, BOOST_PP_LIST_SIZE_O, (0, list))) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/list/to_array.hpp b/src/third_party/boost/boost/preprocessor/list/to_array.hpp new file mode 100644 index 00000000000..83f8a63c625 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/to_array.hpp @@ -0,0 +1,123 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_TO_ARRAY_HPP +# define BOOST_PREPROCESSOR_LIST_TO_ARRAY_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/while.hpp> +# include <boost/preprocessor/list/adt.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_LIST_TO_ARRAY */ +# +# define BOOST_PP_LIST_TO_ARRAY(list) BOOST_PP_LIST_TO_ARRAY_I(BOOST_PP_WHILE, list) + +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_LIST_TO_ARRAY_I(w, list) \ + BOOST_PP_LIST_TO_ARRAY_II(((BOOST_PP_TUPLE_REM_CTOR( \ + 3, \ + w(BOOST_PP_LIST_TO_ARRAY_P, BOOST_PP_LIST_TO_ARRAY_O, (list, 1, (~))) \ + )))) \ + /**/ +# define BOOST_PP_LIST_TO_ARRAY_II(p) BOOST_PP_LIST_TO_ARRAY_II_B(p) +# define BOOST_PP_LIST_TO_ARRAY_II_B(p) BOOST_PP_LIST_TO_ARRAY_II_C ## p +# define BOOST_PP_LIST_TO_ARRAY_II_C(p) BOOST_PP_LIST_TO_ARRAY_III p +# else +# define BOOST_PP_LIST_TO_ARRAY_I(w, list) \ + BOOST_PP_LIST_TO_ARRAY_II(BOOST_PP_TUPLE_REM_CTOR( \ + 3, \ + w(BOOST_PP_LIST_TO_ARRAY_P, BOOST_PP_LIST_TO_ARRAY_O, (list, 1, (~))) \ + )) \ + /**/ +# define BOOST_PP_LIST_TO_ARRAY_II(im) BOOST_PP_LIST_TO_ARRAY_III(im) +# endif +# if BOOST_PP_VARIADICS +# define BOOST_PP_LIST_TO_ARRAY_III(list, size, tuple) (BOOST_PP_DEC(size), BOOST_PP_LIST_TO_ARRAY_IV tuple) +# define BOOST_PP_LIST_TO_ARRAY_IV(_, ...) (__VA_ARGS__) +# else +# define BOOST_PP_LIST_TO_ARRAY_III(list, size, tuple) (BOOST_PP_DEC(size), BOOST_PP_LIST_TO_ARRAY_IV_ ## size tuple) +# define BOOST_PP_LIST_TO_ARRAY_IV_2(_, e0) (e0) +# define BOOST_PP_LIST_TO_ARRAY_IV_3(_, e0, e1) (e0, e1) +# define BOOST_PP_LIST_TO_ARRAY_IV_4(_, e0, e1, e2) (e0, e1, e2) +# define BOOST_PP_LIST_TO_ARRAY_IV_5(_, e0, e1, e2, e3) (e0, e1, e2, e3) +# define BOOST_PP_LIST_TO_ARRAY_IV_6(_, e0, e1, e2, e3, e4) (e0, e1, e2, e3, e4) +# define BOOST_PP_LIST_TO_ARRAY_IV_7(_, e0, e1, e2, e3, e4, e5) (e0, e1, e2, e3, e4, e5) +# define BOOST_PP_LIST_TO_ARRAY_IV_8(_, e0, e1, e2, e3, e4, e5, e6) (e0, e1, e2, e3, e4, e5, e6) +# define BOOST_PP_LIST_TO_ARRAY_IV_9(_, e0, e1, e2, e3, e4, e5, e6, e7) (e0, e1, e2, e3, e4, e5, e6, e7) +# define BOOST_PP_LIST_TO_ARRAY_IV_10(_, e0, e1, e2, e3, e4, e5, e6, e7, e8) (e0, e1, e2, e3, e4, e5, e6, e7, e8) +# define BOOST_PP_LIST_TO_ARRAY_IV_11(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9) +# define BOOST_PP_LIST_TO_ARRAY_IV_12(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10) +# define BOOST_PP_LIST_TO_ARRAY_IV_13(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11) +# define BOOST_PP_LIST_TO_ARRAY_IV_14(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12) +# define BOOST_PP_LIST_TO_ARRAY_IV_15(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13) +# define BOOST_PP_LIST_TO_ARRAY_IV_16(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14) +# define BOOST_PP_LIST_TO_ARRAY_IV_17(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15) +# define BOOST_PP_LIST_TO_ARRAY_IV_18(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16) +# define BOOST_PP_LIST_TO_ARRAY_IV_19(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17) +# define BOOST_PP_LIST_TO_ARRAY_IV_20(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18) +# define BOOST_PP_LIST_TO_ARRAY_IV_21(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19) +# define BOOST_PP_LIST_TO_ARRAY_IV_22(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20) +# define BOOST_PP_LIST_TO_ARRAY_IV_23(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21) +# define BOOST_PP_LIST_TO_ARRAY_IV_24(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22) +# define BOOST_PP_LIST_TO_ARRAY_IV_25(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23) +# define BOOST_PP_LIST_TO_ARRAY_IV_26(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24) +# define BOOST_PP_LIST_TO_ARRAY_IV_27(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25) +# define BOOST_PP_LIST_TO_ARRAY_IV_28(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26) +# define BOOST_PP_LIST_TO_ARRAY_IV_29(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27) +# define BOOST_PP_LIST_TO_ARRAY_IV_30(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28) +# define BOOST_PP_LIST_TO_ARRAY_IV_31(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29) +# define BOOST_PP_LIST_TO_ARRAY_IV_32(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30) +# define BOOST_PP_LIST_TO_ARRAY_IV_33(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31) +# define BOOST_PP_LIST_TO_ARRAY_IV_34(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32) +# define BOOST_PP_LIST_TO_ARRAY_IV_35(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33) +# define BOOST_PP_LIST_TO_ARRAY_IV_36(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34) +# define BOOST_PP_LIST_TO_ARRAY_IV_37(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35) +# define BOOST_PP_LIST_TO_ARRAY_IV_38(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36) +# define BOOST_PP_LIST_TO_ARRAY_IV_39(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37) +# define BOOST_PP_LIST_TO_ARRAY_IV_40(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38) +# define BOOST_PP_LIST_TO_ARRAY_IV_41(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39) +# define BOOST_PP_LIST_TO_ARRAY_IV_42(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40) +# define BOOST_PP_LIST_TO_ARRAY_IV_43(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41) +# define BOOST_PP_LIST_TO_ARRAY_IV_44(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42) +# define BOOST_PP_LIST_TO_ARRAY_IV_45(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43) +# define BOOST_PP_LIST_TO_ARRAY_IV_46(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44) +# define BOOST_PP_LIST_TO_ARRAY_IV_47(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45) +# define BOOST_PP_LIST_TO_ARRAY_IV_48(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46) +# define BOOST_PP_LIST_TO_ARRAY_IV_49(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47) +# define BOOST_PP_LIST_TO_ARRAY_IV_50(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48) +# define BOOST_PP_LIST_TO_ARRAY_IV_51(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49) +# define BOOST_PP_LIST_TO_ARRAY_IV_52(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50) +# define BOOST_PP_LIST_TO_ARRAY_IV_53(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51) +# define BOOST_PP_LIST_TO_ARRAY_IV_54(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52) +# define BOOST_PP_LIST_TO_ARRAY_IV_55(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53) +# define BOOST_PP_LIST_TO_ARRAY_IV_56(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54) +# define BOOST_PP_LIST_TO_ARRAY_IV_57(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55) +# define BOOST_PP_LIST_TO_ARRAY_IV_58(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56) +# define BOOST_PP_LIST_TO_ARRAY_IV_59(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57) +# define BOOST_PP_LIST_TO_ARRAY_IV_60(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58) +# define BOOST_PP_LIST_TO_ARRAY_IV_61(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59) +# define BOOST_PP_LIST_TO_ARRAY_IV_62(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60) +# define BOOST_PP_LIST_TO_ARRAY_IV_63(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61) +# define BOOST_PP_LIST_TO_ARRAY_IV_64(_, e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62) +# endif +# define BOOST_PP_LIST_TO_ARRAY_P(d, state) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(3, 0, state)) +# define BOOST_PP_LIST_TO_ARRAY_O(d, state) BOOST_PP_LIST_TO_ARRAY_O_I state +# define BOOST_PP_LIST_TO_ARRAY_O_I(list, size, tuple) (BOOST_PP_LIST_REST(list), BOOST_PP_INC(size), (BOOST_PP_TUPLE_REM(size) tuple, BOOST_PP_LIST_FIRST(list))) +# +# /* BOOST_PP_LIST_TO_ARRAY_D */ +# +# define BOOST_PP_LIST_TO_ARRAY_D(d, list) BOOST_PP_LIST_TO_ARRAY_I(BOOST_PP_WHILE_ ## d, list) +# +# endif /* BOOST_PREPROCESSOR_LIST_TO_ARRAY_HPP */ diff --git a/src/third_party/boost/boost/preprocessor/list/to_seq.hpp b/src/third_party/boost/boost/preprocessor/list/to_seq.hpp new file mode 100644 index 00000000000..7425907c6d4 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/to_seq.hpp @@ -0,0 +1,32 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 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) +# * * +# ************************************************************************** */ +# +# /* Revised by Paul Mensonides (2011) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_TO_SEQ_HPP +# define BOOST_PREPROCESSOR_LIST_TO_SEQ_HPP +# +# include <boost/preprocessor/list/for_each.hpp> +# +# /* BOOST_PP_LIST_TO_SEQ */ +# +# define BOOST_PP_LIST_TO_SEQ(list) \ + BOOST_PP_LIST_FOR_EACH(BOOST_PP_LIST_TO_SEQ_MACRO, ~, list) \ + /**/ +# define BOOST_PP_LIST_TO_SEQ_MACRO(r, data, elem) (elem) +# +# /* BOOST_PP_LIST_TO_SEQ_R */ +# +# define BOOST_PP_LIST_TO_SEQ_R(r, list) \ + BOOST_PP_LIST_FOR_EACH_R(r, BOOST_PP_LIST_TO_SEQ_MACRO, ~, list) \ + /**/ +# +# endif /* BOOST_PREPROCESSOR_LIST_TO_SEQ_HPP */ diff --git a/src/third_party/boost/boost/preprocessor/list/to_tuple.hpp b/src/third_party/boost/boost/preprocessor/list/to_tuple.hpp new file mode 100644 index 00000000000..557de36e179 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/list/to_tuple.hpp @@ -0,0 +1,38 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LIST_TO_TUPLE_HPP +# define BOOST_PREPROCESSOR_LIST_TO_TUPLE_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/list/enum.hpp> +# +# /* BOOST_PP_LIST_TO_TUPLE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_TO_TUPLE(list) (BOOST_PP_LIST_ENUM(list)) +# else +# define BOOST_PP_LIST_TO_TUPLE(list) BOOST_PP_LIST_TO_TUPLE_I(list) +# define BOOST_PP_LIST_TO_TUPLE_I(list) (BOOST_PP_LIST_ENUM(list)) +# endif +# +# /* BOOST_PP_LIST_TO_TUPLE_R */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LIST_TO_TUPLE_R(r, list) (BOOST_PP_LIST_ENUM_R(r, list)) +# else +# define BOOST_PP_LIST_TO_TUPLE_R(r, list) BOOST_PP_LIST_TO_TUPLE_R_I(r, list) +# define BOOST_PP_LIST_TO_TUPLE_R_I(r, list) (BOOST_PP_LIST_ENUM_R(r, list)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/logical.hpp b/src/third_party/boost/boost/preprocessor/logical.hpp new file mode 100644 index 00000000000..040edeb7268 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/logical.hpp @@ -0,0 +1,29 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LOGICAL_HPP +# define BOOST_PREPROCESSOR_LOGICAL_HPP +# +# include <boost/preprocessor/logical/and.hpp> +# include <boost/preprocessor/logical/bitand.hpp> +# include <boost/preprocessor/logical/bitnor.hpp> +# include <boost/preprocessor/logical/bitor.hpp> +# include <boost/preprocessor/logical/bitxor.hpp> +# include <boost/preprocessor/logical/bool.hpp> +# include <boost/preprocessor/logical/compl.hpp> +# include <boost/preprocessor/logical/nor.hpp> +# include <boost/preprocessor/logical/not.hpp> +# include <boost/preprocessor/logical/or.hpp> +# include <boost/preprocessor/logical/xor.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/logical/bitnor.hpp b/src/third_party/boost/boost/preprocessor/logical/bitnor.hpp new file mode 100644 index 00000000000..110fba8b3a2 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/logical/bitnor.hpp @@ -0,0 +1,38 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LOGICAL_BITNOR_HPP +# define BOOST_PREPROCESSOR_LOGICAL_BITNOR_HPP +# +# include <boost/preprocessor/config/config.hpp> +# +# /* BOOST_PP_BITNOR */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_BITNOR(x, y) BOOST_PP_BITNOR_I(x, y) +# else +# define BOOST_PP_BITNOR(x, y) BOOST_PP_BITNOR_OO((x, y)) +# define BOOST_PP_BITNOR_OO(par) BOOST_PP_BITNOR_I ## par +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_BITNOR_I(x, y) BOOST_PP_BITNOR_ ## x ## y +# else +# define BOOST_PP_BITNOR_I(x, y) BOOST_PP_BITNOR_ID(BOOST_PP_BITNOR_ ## x ## y) +# define BOOST_PP_BITNOR_ID(id) id +# endif +# +# define BOOST_PP_BITNOR_00 1 +# define BOOST_PP_BITNOR_01 0 +# define BOOST_PP_BITNOR_10 0 +# define BOOST_PP_BITNOR_11 0 +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/logical/bitxor.hpp b/src/third_party/boost/boost/preprocessor/logical/bitxor.hpp new file mode 100644 index 00000000000..0488aca9164 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/logical/bitxor.hpp @@ -0,0 +1,38 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LOGICAL_BITXOR_HPP +# define BOOST_PREPROCESSOR_LOGICAL_BITXOR_HPP +# +# include <boost/preprocessor/config/config.hpp> +# +# /* BOOST_PP_BITXOR */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_BITXOR(x, y) BOOST_PP_BITXOR_I(x, y) +# else +# define BOOST_PP_BITXOR(x, y) BOOST_PP_BITXOR_OO((x, y)) +# define BOOST_PP_BITXOR_OO(par) BOOST_PP_BITXOR_I ## par +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_BITXOR_I(x, y) BOOST_PP_BITXOR_ ## x ## y +# else +# define BOOST_PP_BITXOR_I(x, y) BOOST_PP_BITXOR_ID(BOOST_PP_BITXOR_ ## x ## y) +# define BOOST_PP_BITXOR_ID(id) id +# endif +# +# define BOOST_PP_BITXOR_00 0 +# define BOOST_PP_BITXOR_01 1 +# define BOOST_PP_BITXOR_10 1 +# define BOOST_PP_BITXOR_11 0 +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/logical/nor.hpp b/src/third_party/boost/boost/preprocessor/logical/nor.hpp new file mode 100644 index 00000000000..2c0df4bb077 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/logical/nor.hpp @@ -0,0 +1,30 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LOGICAL_NOR_HPP +# define BOOST_PREPROCESSOR_LOGICAL_NOR_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/logical/bool.hpp> +# include <boost/preprocessor/logical/bitnor.hpp> +# +# /* BOOST_PP_NOR */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_NOR(p, q) BOOST_PP_BITNOR(BOOST_PP_BOOL(p), BOOST_PP_BOOL(q)) +# else +# define BOOST_PP_NOR(p, q) BOOST_PP_NOR_I(p, q) +# define BOOST_PP_NOR_I(p, q) BOOST_PP_BITNOR(BOOST_PP_BOOL(p), BOOST_PP_BOOL(q)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/logical/xor.hpp b/src/third_party/boost/boost/preprocessor/logical/xor.hpp new file mode 100644 index 00000000000..34c00e0f417 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/logical/xor.hpp @@ -0,0 +1,30 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_LOGICAL_XOR_HPP +# define BOOST_PREPROCESSOR_LOGICAL_XOR_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/logical/bool.hpp> +# include <boost/preprocessor/logical/bitxor.hpp> +# +# /* BOOST_PP_XOR */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_XOR(p, q) BOOST_PP_BITXOR(BOOST_PP_BOOL(p), BOOST_PP_BOOL(q)) +# else +# define BOOST_PP_XOR(p, q) BOOST_PP_XOR_I(p, q) +# define BOOST_PP_XOR_I(p, q) BOOST_PP_BITXOR(BOOST_PP_BOOL(p), BOOST_PP_BOOL(q)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/max.hpp b/src/third_party/boost/boost/preprocessor/max.hpp new file mode 100644 index 00000000000..3a46ed924b7 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/max.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_MAX_HPP +# define BOOST_PREPROCESSOR_MAX_HPP +# +# include <boost/preprocessor/selection/max.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/min.hpp b/src/third_party/boost/boost/preprocessor/min.hpp new file mode 100644 index 00000000000..8d8e9af2cc7 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/min.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_MIN_HPP +# define BOOST_PREPROCESSOR_MIN_HPP +# +# include <boost/preprocessor/selection/min.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/punctuation.hpp b/src/third_party/boost/boost/preprocessor/punctuation.hpp new file mode 100644 index 00000000000..72da73e8b7e --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/punctuation.hpp @@ -0,0 +1,20 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_PUNCTUATION_HPP +# define BOOST_PREPROCESSOR_PUNCTUATION_HPP +# +# include <boost/preprocessor/punctuation/comma.hpp> +# include <boost/preprocessor/punctuation/comma_if.hpp> +# include <boost/preprocessor/punctuation/paren.hpp> +# include <boost/preprocessor/punctuation/paren_if.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/punctuation/paren_if.hpp b/src/third_party/boost/boost/preprocessor/punctuation/paren_if.hpp new file mode 100644 index 00000000000..1239ec18add --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/punctuation/paren_if.hpp @@ -0,0 +1,38 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_PUNCTUATION_PAREN_IF_HPP +# define BOOST_PREPROCESSOR_PUNCTUATION_PAREN_IF_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/if.hpp> +# include <boost/preprocessor/facilities/empty.hpp> +# include <boost/preprocessor/punctuation/paren.hpp> +# +# /* BOOST_PP_LPAREN_IF */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_LPAREN_IF(cond) BOOST_PP_IF(cond, BOOST_PP_LPAREN, BOOST_PP_EMPTY)() +# else +# define BOOST_PP_LPAREN_IF(cond) BOOST_PP_LPAREN_IF_I(cond) +# define BOOST_PP_LPAREN_IF_I(cond) BOOST_PP_IF(cond, BOOST_PP_LPAREN, BOOST_PP_EMPTY)() +# endif +# +# /* BOOST_PP_RPAREN_IF */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_RPAREN_IF(cond) BOOST_PP_IF(cond, BOOST_PP_RPAREN, BOOST_PP_EMPTY)() +# else +# define BOOST_PP_RPAREN_IF(cond) BOOST_PP_RPAREN_IF_I(cond) +# define BOOST_PP_RPAREN_IF_I(cond) BOOST_PP_IF(cond, BOOST_PP_RPAREN, BOOST_PP_EMPTY)() +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repeat_2nd.hpp b/src/third_party/boost/boost/preprocessor/repeat_2nd.hpp new file mode 100644 index 00000000000..030c4324c2c --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repeat_2nd.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPEAT_2ND_HPP +# define BOOST_PREPROCESSOR_REPEAT_2ND_HPP +# +# include <boost/preprocessor/repetition/repeat.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repeat_3rd.hpp b/src/third_party/boost/boost/preprocessor/repeat_3rd.hpp new file mode 100644 index 00000000000..9ab36a5aeac --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repeat_3rd.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPEAT_3RD_HPP +# define BOOST_PREPROCESSOR_REPEAT_3RD_HPP +# +# include <boost/preprocessor/repetition/repeat.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repeat_from_to_2nd.hpp b/src/third_party/boost/boost/preprocessor/repeat_from_to_2nd.hpp new file mode 100644 index 00000000000..b833fb5c832 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repeat_from_to_2nd.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPEAT_FROM_TO_2ND_HPP +# define BOOST_PREPROCESSOR_REPEAT_FROM_TO_2ND_HPP +# +# include <boost/preprocessor/repetition/repeat_from_to.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repeat_from_to_3rd.hpp b/src/third_party/boost/boost/preprocessor/repeat_from_to_3rd.hpp new file mode 100644 index 00000000000..8cd776fb99b --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repeat_from_to_3rd.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPEAT_FROM_TO_3RD_HPP +# define BOOST_PREPROCESSOR_REPEAT_FROM_TO_3RD_HPP +# +# include <boost/preprocessor/repetition/repeat_from_to.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repetition.hpp b/src/third_party/boost/boost/preprocessor/repetition.hpp new file mode 100644 index 00000000000..efcd60a27df --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repetition.hpp @@ -0,0 +1,32 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPETITION_HPP +# define BOOST_PREPROCESSOR_REPETITION_HPP +# +# include <boost/preprocessor/repetition/deduce_r.hpp> +# include <boost/preprocessor/repetition/deduce_z.hpp> +# include <boost/preprocessor/repetition/enum.hpp> +# include <boost/preprocessor/repetition/enum_binary_params.hpp> +# include <boost/preprocessor/repetition/enum_params.hpp> +# include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +# include <boost/preprocessor/repetition/enum_params_with_defaults.hpp> +# include <boost/preprocessor/repetition/enum_shifted.hpp> +# include <boost/preprocessor/repetition/enum_shifted_binary_params.hpp> +# include <boost/preprocessor/repetition/enum_shifted_params.hpp> +# include <boost/preprocessor/repetition/enum_trailing.hpp> +# include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> +# include <boost/preprocessor/repetition/enum_trailing_params.hpp> +# include <boost/preprocessor/repetition/for.hpp> +# include <boost/preprocessor/repetition/repeat.hpp> +# include <boost/preprocessor/repetition/repeat_from_to.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repetition/deduce_r.hpp b/src/third_party/boost/boost/preprocessor/repetition/deduce_r.hpp new file mode 100644 index 00000000000..e49296aebcc --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repetition/deduce_r.hpp @@ -0,0 +1,22 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPETITION_DEDUCE_R_HPP +# define BOOST_PREPROCESSOR_REPETITION_DEDUCE_R_HPP +# +# include <boost/preprocessor/detail/auto_rec.hpp> +# include <boost/preprocessor/repetition/for.hpp> +# +# /* BOOST_PP_DEDUCE_R */ +# +# define BOOST_PP_DEDUCE_R() BOOST_PP_AUTO_REC(BOOST_PP_FOR_P, 256) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repetition/deduce_z.hpp b/src/third_party/boost/boost/preprocessor/repetition/deduce_z.hpp new file mode 100644 index 00000000000..14dedc2665c --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repetition/deduce_z.hpp @@ -0,0 +1,22 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPETITION_DEDUCE_Z_HPP +# define BOOST_PREPROCESSOR_REPETITION_DEDUCE_Z_HPP +# +# include <boost/preprocessor/detail/auto_rec.hpp> +# include <boost/preprocessor/repetition/repeat.hpp> +# +# /* BOOST_PP_DEDUCE_Z */ +# +# define BOOST_PP_DEDUCE_Z() BOOST_PP_AUTO_REC(BOOST_PP_REPEAT_P, 4) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repetition/enum_shifted.hpp b/src/third_party/boost/boost/preprocessor/repetition/enum_shifted.hpp new file mode 100644 index 00000000000..d5b006f4d0f --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repetition/enum_shifted.hpp @@ -0,0 +1,68 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPETITION_ENUM_SHIFTED_HPP +# define BOOST_PREPROCESSOR_REPETITION_ENUM_SHIFTED_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/debug/error.hpp> +# include <boost/preprocessor/detail/auto_rec.hpp> +# include <boost/preprocessor/punctuation/comma_if.hpp> +# include <boost/preprocessor/repetition/repeat.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_ENUM_SHIFTED */ +# +# if 0 +# define BOOST_PP_ENUM_SHIFTED(count, macro, data) +# endif +# +# define BOOST_PP_ENUM_SHIFTED BOOST_PP_CAT(BOOST_PP_ENUM_SHIFTED_, BOOST_PP_AUTO_REC(BOOST_PP_REPEAT_P, 4)) +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ENUM_SHIFTED_1(c, m, d) BOOST_PP_REPEAT_1(BOOST_PP_DEC(c), BOOST_PP_ENUM_SHIFTED_M_1, (m, d)) +# define BOOST_PP_ENUM_SHIFTED_2(c, m, d) BOOST_PP_REPEAT_2(BOOST_PP_DEC(c), BOOST_PP_ENUM_SHIFTED_M_2, (m, d)) +# define BOOST_PP_ENUM_SHIFTED_3(c, m, d) BOOST_PP_REPEAT_3(BOOST_PP_DEC(c), BOOST_PP_ENUM_SHIFTED_M_3, (m, d)) +# else +# define BOOST_PP_ENUM_SHIFTED_1(c, m, d) BOOST_PP_ENUM_SHIFTED_1_I(c, m, d) +# define BOOST_PP_ENUM_SHIFTED_2(c, m, d) BOOST_PP_ENUM_SHIFTED_1_2(c, m, d) +# define BOOST_PP_ENUM_SHIFTED_3(c, m, d) BOOST_PP_ENUM_SHIFTED_1_3(c, m, d) +# define BOOST_PP_ENUM_SHIFTED_1_I(c, m, d) BOOST_PP_REPEAT_1(BOOST_PP_DEC(c), BOOST_PP_ENUM_SHIFTED_M_1, (m, d)) +# define BOOST_PP_ENUM_SHIFTED_2_I(c, m, d) BOOST_PP_REPEAT_2(BOOST_PP_DEC(c), BOOST_PP_ENUM_SHIFTED_M_2, (m, d)) +# define BOOST_PP_ENUM_SHIFTED_3_I(c, m, d) BOOST_PP_REPEAT_3(BOOST_PP_DEC(c), BOOST_PP_ENUM_SHIFTED_M_3, (m, d)) +# endif +# +# define BOOST_PP_ENUM_SHIFTED_4(c, m, d) BOOST_PP_ERROR(0x0003) +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_ENUM_SHIFTED_M_1(z, n, md) BOOST_PP_ENUM_SHIFTED_M_1_IM(z, n, BOOST_PP_TUPLE_REM_2 md) +# define BOOST_PP_ENUM_SHIFTED_M_2(z, n, md) BOOST_PP_ENUM_SHIFTED_M_2_IM(z, n, BOOST_PP_TUPLE_REM_2 md) +# define BOOST_PP_ENUM_SHIFTED_M_3(z, n, md) BOOST_PP_ENUM_SHIFTED_M_3_IM(z, n, BOOST_PP_TUPLE_REM_2 md) +# define BOOST_PP_ENUM_SHIFTED_M_1_IM(z, n, im) BOOST_PP_ENUM_SHIFTED_M_1_I(z, n, im) +# define BOOST_PP_ENUM_SHIFTED_M_2_IM(z, n, im) BOOST_PP_ENUM_SHIFTED_M_2_I(z, n, im) +# define BOOST_PP_ENUM_SHIFTED_M_3_IM(z, n, im) BOOST_PP_ENUM_SHIFTED_M_3_I(z, n, im) +# else +# define BOOST_PP_ENUM_SHIFTED_M_1(z, n, md) BOOST_PP_ENUM_SHIFTED_M_1_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, md), BOOST_PP_TUPLE_ELEM(2, 1, md)) +# define BOOST_PP_ENUM_SHIFTED_M_2(z, n, md) BOOST_PP_ENUM_SHIFTED_M_2_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, md), BOOST_PP_TUPLE_ELEM(2, 1, md)) +# define BOOST_PP_ENUM_SHIFTED_M_3(z, n, md) BOOST_PP_ENUM_SHIFTED_M_3_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, md), BOOST_PP_TUPLE_ELEM(2, 1, md)) +# endif +# +# define BOOST_PP_ENUM_SHIFTED_M_1_I(z, n, m, d) BOOST_PP_COMMA_IF(n) m(z, BOOST_PP_INC(n), d) +# define BOOST_PP_ENUM_SHIFTED_M_2_I(z, n, m, d) BOOST_PP_COMMA_IF(n) m(z, BOOST_PP_INC(n), d) +# define BOOST_PP_ENUM_SHIFTED_M_3_I(z, n, m, d) BOOST_PP_COMMA_IF(n) m(z, BOOST_PP_INC(n), d) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repetition/enum_shifted_binary_params.hpp b/src/third_party/boost/boost/preprocessor/repetition/enum_shifted_binary_params.hpp new file mode 100644 index 00000000000..f3d20fc7b47 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repetition/enum_shifted_binary_params.hpp @@ -0,0 +1,51 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2005. * +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPETITION_ENUM_SHIFTED_BINARY_PARAMS_HPP +# define BOOST_PREPROCESSOR_REPETITION_ENUM_SHIFTED_BINARY_PARAMS_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/punctuation/comma_if.hpp> +# include <boost/preprocessor/repetition/repeat.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(count, p1, p2) BOOST_PP_REPEAT(BOOST_PP_DEC(count), BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M, (p1, p2)) +# else +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(count, p1, p2) BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_I(count, p1, p2) +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_I(count, p1, p2) BOOST_PP_REPEAT(BOOST_PP_DEC(count), BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M, (p1, p2)) +# endif +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M(z, n, pp) BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M_IM(z, n, BOOST_PP_TUPLE_REM_2 pp) +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M_IM(z, n, im) BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M_I(z, n, im) +# else +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M(z, n, pp) BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, pp), BOOST_PP_TUPLE_ELEM(2, 1, pp)) +# endif +# +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M_I(z, n, p1, p2) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(p1, BOOST_PP_INC(n)) BOOST_PP_CAT(p2, BOOST_PP_INC(n)) +# +# /* BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_Z */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_Z(z, count, p1, p2) BOOST_PP_REPEAT_ ## z(BOOST_PP_DEC(count), BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M, (p1, p2)) +# else +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_Z(z, count, p1, p2) BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_Z_I(z, count, p1, p2) +# define BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_Z_I(z, count, p1, p2) BOOST_PP_REPEAT_ ## z(BOOST_PP_DEC(count), BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS_M, (p1, p2)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/repetition/enum_trailing_binary_params.hpp b/src/third_party/boost/boost/preprocessor/repetition/enum_trailing_binary_params.hpp new file mode 100644 index 00000000000..e201b69917d --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/repetition/enum_trailing_binary_params.hpp @@ -0,0 +1,53 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_REPETITION_ENUM_TRAILING_BINARY_PARAMS_HPP +# define BOOST_PREPROCESSOR_REPETITION_ENUM_TRAILING_BINARY_PARAMS_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/repetition/repeat.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_ENUM_TRAILING_BINARY_PARAMS */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(count, p1, p2) BOOST_PP_REPEAT(count, BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M, (p1, p2)) +# else +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(count, p1, p2) BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_I(count, p1, p2) +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_I(count, p1, p2) BOOST_PP_REPEAT(count, BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M, (p1, p2)) +# endif +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M(z, n, pp) BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_IM(z, n, BOOST_PP_TUPLE_REM_2 pp) +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_IM(z, n, im) BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_I(z, n, im) +# else +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M(z, n, pp) BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, pp), BOOST_PP_TUPLE_ELEM(2, 1, pp)) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_I(z, n, p1, p2) BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_II(z, n, p1, p2) +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_II(z, n, p1, p2) , p1 ## n p2 ## n +# else +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M_I(z, n, p1, p2) , BOOST_PP_CAT(p1, n) BOOST_PP_CAT(p2, n) +# endif +# +# /* BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, count, p1, p2) BOOST_PP_REPEAT_ ## z(count, BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M, (p1, p2)) +# else +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, count, p1, p2) BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z_I(z, count, p1, p2) +# define BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z_I(z, count, p1, p2) BOOST_PP_REPEAT_ ## z(count, BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_M, (p1, p2)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/selection.hpp b/src/third_party/boost/boost/preprocessor/selection.hpp new file mode 100644 index 00000000000..3b67fad4e38 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/selection.hpp @@ -0,0 +1,18 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SELECTION_HPP +# define BOOST_PREPROCESSOR_SELECTION_HPP +# +# include <boost/preprocessor/selection/max.hpp> +# include <boost/preprocessor/selection/min.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/selection/max.hpp b/src/third_party/boost/boost/preprocessor/selection/max.hpp new file mode 100644 index 00000000000..407d70205f8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/selection/max.hpp @@ -0,0 +1,39 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SELECTION_MAX_HPP +# define BOOST_PREPROCESSOR_SELECTION_MAX_HPP +# +# include <boost/preprocessor/comparison/less_equal.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/iif.hpp> +# +# /* BOOST_PP_MAX */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_MAX(x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL(x, y), y, x) +# else +# define BOOST_PP_MAX(x, y) BOOST_PP_MAX_I(x, y) +# define BOOST_PP_MAX_I(x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL(x, y), y, x) +# endif +# +# /* BOOST_PP_MAX_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_MAX_D(d, x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL_D(d, x, y), y, x) +# else +# define BOOST_PP_MAX_D(d, x, y) BOOST_PP_MAX_D_I(d, x, y) +# define BOOST_PP_MAX_D_I(d, x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL_D(d, x, y), y, x) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/selection/min.hpp b/src/third_party/boost/boost/preprocessor/selection/min.hpp new file mode 100644 index 00000000000..ee05588bd77 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/selection/min.hpp @@ -0,0 +1,39 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SELECTION_MIN_HPP +# define BOOST_PREPROCESSOR_SELECTION_MIN_HPP +# +# include <boost/preprocessor/comparison/less_equal.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/iif.hpp> +# +# /* BOOST_PP_MIN */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_MIN(x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL(y, x), y, x) +# else +# define BOOST_PP_MIN(x, y) BOOST_PP_MIN_I(x, y) +# define BOOST_PP_MIN_I(x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL(y, x), y, x) +# endif +# +# /* BOOST_PP_MIN_D */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_MIN_D(d, x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL_D(d, y, x), y, x) +# else +# define BOOST_PP_MIN_D(d, x, y) BOOST_PP_MIN_D_I(d, x, y) +# define BOOST_PP_MIN_D_I(d, x, y) BOOST_PP_IIF(BOOST_PP_LESS_EQUAL_D(d, y, x), y, x) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq.hpp b/src/third_party/boost/boost/preprocessor/seq.hpp new file mode 100644 index 00000000000..6d78f4319cf --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq.hpp @@ -0,0 +1,43 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002-2011. * +# * (C) Copyright Edward Diener 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_HPP +# define BOOST_PREPROCESSOR_SEQ_HPP +# +# include <boost/preprocessor/seq/cat.hpp> +# include <boost/preprocessor/seq/elem.hpp> +# include <boost/preprocessor/seq/enum.hpp> +# include <boost/preprocessor/seq/filter.hpp> +# include <boost/preprocessor/seq/first_n.hpp> +# include <boost/preprocessor/seq/fold_left.hpp> +# include <boost/preprocessor/seq/fold_right.hpp> +# include <boost/preprocessor/seq/for_each.hpp> +# include <boost/preprocessor/seq/for_each_i.hpp> +# include <boost/preprocessor/seq/for_each_product.hpp> +# include <boost/preprocessor/seq/insert.hpp> +# include <boost/preprocessor/seq/pop_back.hpp> +# include <boost/preprocessor/seq/pop_front.hpp> +# include <boost/preprocessor/seq/push_back.hpp> +# include <boost/preprocessor/seq/push_front.hpp> +# include <boost/preprocessor/seq/remove.hpp> +# include <boost/preprocessor/seq/replace.hpp> +# include <boost/preprocessor/seq/rest_n.hpp> +# include <boost/preprocessor/seq/reverse.hpp> +# include <boost/preprocessor/seq/seq.hpp> +# include <boost/preprocessor/seq/size.hpp> +# include <boost/preprocessor/seq/subseq.hpp> +# include <boost/preprocessor/seq/to_array.hpp> +# include <boost/preprocessor/seq/to_list.hpp> +# include <boost/preprocessor/seq/to_tuple.hpp> +# include <boost/preprocessor/seq/transform.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/detail/binary_transform.hpp b/src/third_party/boost/boost/preprocessor/seq/detail/binary_transform.hpp new file mode 100644 index 00000000000..373e8a53c99 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/detail/binary_transform.hpp @@ -0,0 +1,40 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_DETAIL_BINARY_TRANSFORM_HPP +# define BOOST_PREPROCESSOR_SEQ_DETAIL_BINARY_TRANSFORM_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/eat.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_SEQ_BINARY_TRANSFORM */ +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_SEQ_BINARY_TRANSFORM(seq) BOOST_PP_SEQ_BINARY_TRANSFORM_I(, seq) +# define BOOST_PP_SEQ_BINARY_TRANSFORM_I(p, seq) BOOST_PP_SEQ_BINARY_TRANSFORM_II(p ## seq) +# define BOOST_PP_SEQ_BINARY_TRANSFORM_II(seq) BOOST_PP_SEQ_BINARY_TRANSFORM_III(seq) +# define BOOST_PP_SEQ_BINARY_TRANSFORM_III(seq) BOOST_PP_CAT(BOOST_PP_SEQ_BINARY_TRANSFORM_A seq, 0) +# else +# define BOOST_PP_SEQ_BINARY_TRANSFORM(seq) BOOST_PP_CAT(BOOST_PP_SEQ_BINARY_TRANSFORM_A seq, 0) +# endif +# if BOOST_PP_VARIADICS +# define BOOST_PP_SEQ_BINARY_TRANSFORM_A(...) (BOOST_PP_REM, __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_B +# define BOOST_PP_SEQ_BINARY_TRANSFORM_B(...) (BOOST_PP_REM, __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_A +# else +# define BOOST_PP_SEQ_BINARY_TRANSFORM_A(e) (BOOST_PP_REM, e)() BOOST_PP_SEQ_BINARY_TRANSFORM_B +# define BOOST_PP_SEQ_BINARY_TRANSFORM_B(e) (BOOST_PP_REM, e)() BOOST_PP_SEQ_BINARY_TRANSFORM_A +# endif +# define BOOST_PP_SEQ_BINARY_TRANSFORM_A0 (BOOST_PP_EAT, ?) +# define BOOST_PP_SEQ_BINARY_TRANSFORM_B0 (BOOST_PP_EAT, ?) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/filter.hpp b/src/third_party/boost/boost/preprocessor/seq/filter.hpp new file mode 100644 index 00000000000..4596bfe59b4 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/filter.hpp @@ -0,0 +1,54 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_FILTER_HPP +# define BOOST_PREPROCESSOR_SEQ_FILTER_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/expr_if.hpp> +# include <boost/preprocessor/facilities/empty.hpp> +# include <boost/preprocessor/seq/fold_left.hpp> +# include <boost/preprocessor/seq/seq.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_SEQ_FILTER */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_FILTER(pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) +# else +# define BOOST_PP_SEQ_FILTER(pred, data, seq) BOOST_PP_SEQ_FILTER_I(pred, data, seq) +# define BOOST_PP_SEQ_FILTER_I(pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) +# endif +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_SEQ_FILTER_O(s, st, elem) BOOST_PP_SEQ_FILTER_O_IM(s, BOOST_PP_TUPLE_REM_3 st, elem) +# define BOOST_PP_SEQ_FILTER_O_IM(s, im, elem) BOOST_PP_SEQ_FILTER_O_I(s, im, elem) +# else +# define BOOST_PP_SEQ_FILTER_O(s, st, elem) BOOST_PP_SEQ_FILTER_O_I(s, BOOST_PP_TUPLE_ELEM(3, 0, st), BOOST_PP_TUPLE_ELEM(3, 1, st), BOOST_PP_TUPLE_ELEM(3, 2, st), elem) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() +# define BOOST_PP_SEQ_FILTER_O_I(s, pred, data, res, elem) (pred, data, res BOOST_PP_EXPR_IF(pred(s, data, elem), (elem))) +# else +# define BOOST_PP_SEQ_FILTER_O_I(s, pred, data, res, elem) (pred, data, res BOOST_PP_EXPR_IF(pred##(s, data, elem), (elem))) +# endif +# +# /* BOOST_PP_SEQ_FILTER_S */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_FILTER_S(s, pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) +# else +# define BOOST_PP_SEQ_FILTER_S(s, pred, data, seq) BOOST_PP_SEQ_FILTER_S_I(s, pred, data, seq) +# define BOOST_PP_SEQ_FILTER_S_I(s, pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/fold_right.hpp b/src/third_party/boost/boost/preprocessor/seq/fold_right.hpp new file mode 100644 index 00000000000..c2c365b29ad --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/fold_right.hpp @@ -0,0 +1,288 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_FOLD_RIGHT_HPP +# define BOOST_PREPROCESSOR_SEQ_FOLD_RIGHT_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/detail/auto_rec.hpp> +# include <boost/preprocessor/seq/fold_left.hpp> +# include <boost/preprocessor/seq/reverse.hpp> +# include <boost/preprocessor/seq/seq.hpp> +# +# /* BOOST_PP_SEQ_FOLD_RIGHT */ +# +# if 0 +# define BOOST_PP_SEQ_FOLD_RIGHT(op, state, seq) ... +# endif +# +# define BOOST_PP_SEQ_FOLD_RIGHT BOOST_PP_CAT(BOOST_PP_SEQ_FOLD_RIGHT_, BOOST_PP_AUTO_REC(BOOST_PP_SEQ_FOLD_LEFT_P, 256)) +# +# define BOOST_PP_SEQ_FOLD_RIGHT_257(op, st, ss) BOOST_PP_ERROR(0x0005) +# +# define BOOST_PP_SEQ_FOLD_RIGHT_1(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_1(op, st, BOOST_PP_SEQ_REVERSE_S(2, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_2(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_2(op, st, BOOST_PP_SEQ_REVERSE_S(3, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_3(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_3(op, st, BOOST_PP_SEQ_REVERSE_S(4, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_4(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_4(op, st, BOOST_PP_SEQ_REVERSE_S(5, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_5(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_5(op, st, BOOST_PP_SEQ_REVERSE_S(6, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_6(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_6(op, st, BOOST_PP_SEQ_REVERSE_S(7, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_7(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_7(op, st, BOOST_PP_SEQ_REVERSE_S(8, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_8(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_8(op, st, BOOST_PP_SEQ_REVERSE_S(9, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_9(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_9(op, st, BOOST_PP_SEQ_REVERSE_S(10, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_10(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_10(op, st, BOOST_PP_SEQ_REVERSE_S(11, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_11(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_11(op, st, BOOST_PP_SEQ_REVERSE_S(12, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_12(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_12(op, st, BOOST_PP_SEQ_REVERSE_S(13, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_13(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_13(op, st, BOOST_PP_SEQ_REVERSE_S(14, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_14(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_14(op, st, BOOST_PP_SEQ_REVERSE_S(15, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_15(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_15(op, st, BOOST_PP_SEQ_REVERSE_S(16, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_16(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_16(op, st, BOOST_PP_SEQ_REVERSE_S(17, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_17(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_17(op, st, BOOST_PP_SEQ_REVERSE_S(18, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_18(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_18(op, st, BOOST_PP_SEQ_REVERSE_S(19, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_19(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_19(op, st, BOOST_PP_SEQ_REVERSE_S(20, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_20(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_20(op, st, BOOST_PP_SEQ_REVERSE_S(21, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_21(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_21(op, st, BOOST_PP_SEQ_REVERSE_S(22, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_22(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_22(op, st, BOOST_PP_SEQ_REVERSE_S(23, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_23(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_23(op, st, BOOST_PP_SEQ_REVERSE_S(24, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_24(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_24(op, st, BOOST_PP_SEQ_REVERSE_S(25, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_25(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_25(op, st, BOOST_PP_SEQ_REVERSE_S(26, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_26(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_26(op, st, BOOST_PP_SEQ_REVERSE_S(27, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_27(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_27(op, st, BOOST_PP_SEQ_REVERSE_S(28, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_28(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_28(op, st, BOOST_PP_SEQ_REVERSE_S(29, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_29(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_29(op, st, BOOST_PP_SEQ_REVERSE_S(30, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_30(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_30(op, st, BOOST_PP_SEQ_REVERSE_S(31, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_31(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_31(op, st, BOOST_PP_SEQ_REVERSE_S(32, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_32(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_32(op, st, BOOST_PP_SEQ_REVERSE_S(33, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_33(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_33(op, st, BOOST_PP_SEQ_REVERSE_S(34, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_34(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_34(op, st, BOOST_PP_SEQ_REVERSE_S(35, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_35(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_35(op, st, BOOST_PP_SEQ_REVERSE_S(36, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_36(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_36(op, st, BOOST_PP_SEQ_REVERSE_S(37, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_37(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_37(op, st, BOOST_PP_SEQ_REVERSE_S(38, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_38(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_38(op, st, BOOST_PP_SEQ_REVERSE_S(39, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_39(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_39(op, st, BOOST_PP_SEQ_REVERSE_S(40, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_40(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_40(op, st, BOOST_PP_SEQ_REVERSE_S(41, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_41(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_41(op, st, BOOST_PP_SEQ_REVERSE_S(42, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_42(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_42(op, st, BOOST_PP_SEQ_REVERSE_S(43, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_43(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_43(op, st, BOOST_PP_SEQ_REVERSE_S(44, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_44(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_44(op, st, BOOST_PP_SEQ_REVERSE_S(45, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_45(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_45(op, st, BOOST_PP_SEQ_REVERSE_S(46, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_46(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_46(op, st, BOOST_PP_SEQ_REVERSE_S(47, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_47(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_47(op, st, BOOST_PP_SEQ_REVERSE_S(48, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_48(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_48(op, st, BOOST_PP_SEQ_REVERSE_S(49, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_49(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_49(op, st, BOOST_PP_SEQ_REVERSE_S(50, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_50(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_50(op, st, BOOST_PP_SEQ_REVERSE_S(51, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_51(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_51(op, st, BOOST_PP_SEQ_REVERSE_S(52, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_52(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_52(op, st, BOOST_PP_SEQ_REVERSE_S(53, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_53(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_53(op, st, BOOST_PP_SEQ_REVERSE_S(54, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_54(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_54(op, st, BOOST_PP_SEQ_REVERSE_S(55, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_55(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_55(op, st, BOOST_PP_SEQ_REVERSE_S(56, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_56(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_56(op, st, BOOST_PP_SEQ_REVERSE_S(57, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_57(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_57(op, st, BOOST_PP_SEQ_REVERSE_S(58, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_58(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_58(op, st, BOOST_PP_SEQ_REVERSE_S(59, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_59(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_59(op, st, BOOST_PP_SEQ_REVERSE_S(60, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_60(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_60(op, st, BOOST_PP_SEQ_REVERSE_S(61, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_61(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_61(op, st, BOOST_PP_SEQ_REVERSE_S(62, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_62(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_62(op, st, BOOST_PP_SEQ_REVERSE_S(63, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_63(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_63(op, st, BOOST_PP_SEQ_REVERSE_S(64, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_64(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_64(op, st, BOOST_PP_SEQ_REVERSE_S(65, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_65(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_65(op, st, BOOST_PP_SEQ_REVERSE_S(66, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_66(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_66(op, st, BOOST_PP_SEQ_REVERSE_S(67, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_67(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_67(op, st, BOOST_PP_SEQ_REVERSE_S(68, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_68(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_68(op, st, BOOST_PP_SEQ_REVERSE_S(69, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_69(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_69(op, st, BOOST_PP_SEQ_REVERSE_S(70, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_70(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_70(op, st, BOOST_PP_SEQ_REVERSE_S(71, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_71(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_71(op, st, BOOST_PP_SEQ_REVERSE_S(72, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_72(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_72(op, st, BOOST_PP_SEQ_REVERSE_S(73, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_73(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_73(op, st, BOOST_PP_SEQ_REVERSE_S(74, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_74(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_74(op, st, BOOST_PP_SEQ_REVERSE_S(75, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_75(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_75(op, st, BOOST_PP_SEQ_REVERSE_S(76, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_76(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_76(op, st, BOOST_PP_SEQ_REVERSE_S(77, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_77(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_77(op, st, BOOST_PP_SEQ_REVERSE_S(78, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_78(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_78(op, st, BOOST_PP_SEQ_REVERSE_S(79, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_79(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_79(op, st, BOOST_PP_SEQ_REVERSE_S(80, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_80(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_80(op, st, BOOST_PP_SEQ_REVERSE_S(81, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_81(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_81(op, st, BOOST_PP_SEQ_REVERSE_S(82, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_82(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_82(op, st, BOOST_PP_SEQ_REVERSE_S(83, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_83(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_83(op, st, BOOST_PP_SEQ_REVERSE_S(84, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_84(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_84(op, st, BOOST_PP_SEQ_REVERSE_S(85, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_85(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_85(op, st, BOOST_PP_SEQ_REVERSE_S(86, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_86(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_86(op, st, BOOST_PP_SEQ_REVERSE_S(87, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_87(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_87(op, st, BOOST_PP_SEQ_REVERSE_S(88, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_88(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_88(op, st, BOOST_PP_SEQ_REVERSE_S(89, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_89(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_89(op, st, BOOST_PP_SEQ_REVERSE_S(90, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_90(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_90(op, st, BOOST_PP_SEQ_REVERSE_S(91, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_91(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_91(op, st, BOOST_PP_SEQ_REVERSE_S(92, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_92(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_92(op, st, BOOST_PP_SEQ_REVERSE_S(93, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_93(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_93(op, st, BOOST_PP_SEQ_REVERSE_S(94, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_94(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_94(op, st, BOOST_PP_SEQ_REVERSE_S(95, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_95(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_95(op, st, BOOST_PP_SEQ_REVERSE_S(96, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_96(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_96(op, st, BOOST_PP_SEQ_REVERSE_S(97, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_97(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_97(op, st, BOOST_PP_SEQ_REVERSE_S(98, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_98(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_98(op, st, BOOST_PP_SEQ_REVERSE_S(99, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_99(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_99(op, st, BOOST_PP_SEQ_REVERSE_S(100, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_100(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_100(op, st, BOOST_PP_SEQ_REVERSE_S(101, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_101(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_101(op, st, BOOST_PP_SEQ_REVERSE_S(102, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_102(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_102(op, st, BOOST_PP_SEQ_REVERSE_S(103, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_103(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_103(op, st, BOOST_PP_SEQ_REVERSE_S(104, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_104(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_104(op, st, BOOST_PP_SEQ_REVERSE_S(105, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_105(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_105(op, st, BOOST_PP_SEQ_REVERSE_S(106, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_106(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_106(op, st, BOOST_PP_SEQ_REVERSE_S(107, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_107(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_107(op, st, BOOST_PP_SEQ_REVERSE_S(108, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_108(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_108(op, st, BOOST_PP_SEQ_REVERSE_S(109, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_109(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_109(op, st, BOOST_PP_SEQ_REVERSE_S(110, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_110(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_110(op, st, BOOST_PP_SEQ_REVERSE_S(111, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_111(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_111(op, st, BOOST_PP_SEQ_REVERSE_S(112, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_112(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_112(op, st, BOOST_PP_SEQ_REVERSE_S(113, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_113(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_113(op, st, BOOST_PP_SEQ_REVERSE_S(114, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_114(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_114(op, st, BOOST_PP_SEQ_REVERSE_S(115, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_115(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_115(op, st, BOOST_PP_SEQ_REVERSE_S(116, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_116(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_116(op, st, BOOST_PP_SEQ_REVERSE_S(117, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_117(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_117(op, st, BOOST_PP_SEQ_REVERSE_S(118, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_118(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_118(op, st, BOOST_PP_SEQ_REVERSE_S(119, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_119(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_119(op, st, BOOST_PP_SEQ_REVERSE_S(120, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_120(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_120(op, st, BOOST_PP_SEQ_REVERSE_S(121, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_121(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_121(op, st, BOOST_PP_SEQ_REVERSE_S(122, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_122(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_122(op, st, BOOST_PP_SEQ_REVERSE_S(123, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_123(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_123(op, st, BOOST_PP_SEQ_REVERSE_S(124, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_124(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_124(op, st, BOOST_PP_SEQ_REVERSE_S(125, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_125(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_125(op, st, BOOST_PP_SEQ_REVERSE_S(126, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_126(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_126(op, st, BOOST_PP_SEQ_REVERSE_S(127, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_127(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_127(op, st, BOOST_PP_SEQ_REVERSE_S(128, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_128(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_128(op, st, BOOST_PP_SEQ_REVERSE_S(129, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_129(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_129(op, st, BOOST_PP_SEQ_REVERSE_S(130, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_130(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_130(op, st, BOOST_PP_SEQ_REVERSE_S(131, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_131(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_131(op, st, BOOST_PP_SEQ_REVERSE_S(132, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_132(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_132(op, st, BOOST_PP_SEQ_REVERSE_S(133, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_133(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_133(op, st, BOOST_PP_SEQ_REVERSE_S(134, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_134(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_134(op, st, BOOST_PP_SEQ_REVERSE_S(135, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_135(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_135(op, st, BOOST_PP_SEQ_REVERSE_S(136, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_136(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_136(op, st, BOOST_PP_SEQ_REVERSE_S(137, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_137(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_137(op, st, BOOST_PP_SEQ_REVERSE_S(138, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_138(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_138(op, st, BOOST_PP_SEQ_REVERSE_S(139, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_139(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_139(op, st, BOOST_PP_SEQ_REVERSE_S(140, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_140(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_140(op, st, BOOST_PP_SEQ_REVERSE_S(141, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_141(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_141(op, st, BOOST_PP_SEQ_REVERSE_S(142, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_142(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_142(op, st, BOOST_PP_SEQ_REVERSE_S(143, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_143(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_143(op, st, BOOST_PP_SEQ_REVERSE_S(144, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_144(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_144(op, st, BOOST_PP_SEQ_REVERSE_S(145, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_145(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_145(op, st, BOOST_PP_SEQ_REVERSE_S(146, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_146(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_146(op, st, BOOST_PP_SEQ_REVERSE_S(147, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_147(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_147(op, st, BOOST_PP_SEQ_REVERSE_S(148, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_148(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_148(op, st, BOOST_PP_SEQ_REVERSE_S(149, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_149(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_149(op, st, BOOST_PP_SEQ_REVERSE_S(150, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_150(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_150(op, st, BOOST_PP_SEQ_REVERSE_S(151, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_151(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_151(op, st, BOOST_PP_SEQ_REVERSE_S(152, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_152(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_152(op, st, BOOST_PP_SEQ_REVERSE_S(153, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_153(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_153(op, st, BOOST_PP_SEQ_REVERSE_S(154, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_154(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_154(op, st, BOOST_PP_SEQ_REVERSE_S(155, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_155(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_155(op, st, BOOST_PP_SEQ_REVERSE_S(156, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_156(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_156(op, st, BOOST_PP_SEQ_REVERSE_S(157, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_157(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_157(op, st, BOOST_PP_SEQ_REVERSE_S(158, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_158(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_158(op, st, BOOST_PP_SEQ_REVERSE_S(159, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_159(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_159(op, st, BOOST_PP_SEQ_REVERSE_S(160, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_160(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_160(op, st, BOOST_PP_SEQ_REVERSE_S(161, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_161(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_161(op, st, BOOST_PP_SEQ_REVERSE_S(162, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_162(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_162(op, st, BOOST_PP_SEQ_REVERSE_S(163, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_163(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_163(op, st, BOOST_PP_SEQ_REVERSE_S(164, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_164(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_164(op, st, BOOST_PP_SEQ_REVERSE_S(165, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_165(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_165(op, st, BOOST_PP_SEQ_REVERSE_S(166, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_166(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_166(op, st, BOOST_PP_SEQ_REVERSE_S(167, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_167(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_167(op, st, BOOST_PP_SEQ_REVERSE_S(168, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_168(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_168(op, st, BOOST_PP_SEQ_REVERSE_S(169, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_169(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_169(op, st, BOOST_PP_SEQ_REVERSE_S(170, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_170(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_170(op, st, BOOST_PP_SEQ_REVERSE_S(171, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_171(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_171(op, st, BOOST_PP_SEQ_REVERSE_S(172, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_172(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_172(op, st, BOOST_PP_SEQ_REVERSE_S(173, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_173(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_173(op, st, BOOST_PP_SEQ_REVERSE_S(174, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_174(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_174(op, st, BOOST_PP_SEQ_REVERSE_S(175, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_175(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_175(op, st, BOOST_PP_SEQ_REVERSE_S(176, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_176(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_176(op, st, BOOST_PP_SEQ_REVERSE_S(177, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_177(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_177(op, st, BOOST_PP_SEQ_REVERSE_S(178, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_178(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_178(op, st, BOOST_PP_SEQ_REVERSE_S(179, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_179(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_179(op, st, BOOST_PP_SEQ_REVERSE_S(180, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_180(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_180(op, st, BOOST_PP_SEQ_REVERSE_S(181, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_181(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_181(op, st, BOOST_PP_SEQ_REVERSE_S(182, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_182(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_182(op, st, BOOST_PP_SEQ_REVERSE_S(183, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_183(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_183(op, st, BOOST_PP_SEQ_REVERSE_S(184, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_184(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_184(op, st, BOOST_PP_SEQ_REVERSE_S(185, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_185(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_185(op, st, BOOST_PP_SEQ_REVERSE_S(186, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_186(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_186(op, st, BOOST_PP_SEQ_REVERSE_S(187, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_187(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_187(op, st, BOOST_PP_SEQ_REVERSE_S(188, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_188(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_188(op, st, BOOST_PP_SEQ_REVERSE_S(189, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_189(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_189(op, st, BOOST_PP_SEQ_REVERSE_S(190, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_190(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_190(op, st, BOOST_PP_SEQ_REVERSE_S(191, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_191(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_191(op, st, BOOST_PP_SEQ_REVERSE_S(192, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_192(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_192(op, st, BOOST_PP_SEQ_REVERSE_S(193, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_193(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_193(op, st, BOOST_PP_SEQ_REVERSE_S(194, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_194(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_194(op, st, BOOST_PP_SEQ_REVERSE_S(195, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_195(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_195(op, st, BOOST_PP_SEQ_REVERSE_S(196, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_196(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_196(op, st, BOOST_PP_SEQ_REVERSE_S(197, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_197(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_197(op, st, BOOST_PP_SEQ_REVERSE_S(198, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_198(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_198(op, st, BOOST_PP_SEQ_REVERSE_S(199, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_199(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_199(op, st, BOOST_PP_SEQ_REVERSE_S(200, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_200(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_200(op, st, BOOST_PP_SEQ_REVERSE_S(201, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_201(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_201(op, st, BOOST_PP_SEQ_REVERSE_S(202, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_202(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_202(op, st, BOOST_PP_SEQ_REVERSE_S(203, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_203(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_203(op, st, BOOST_PP_SEQ_REVERSE_S(204, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_204(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_204(op, st, BOOST_PP_SEQ_REVERSE_S(205, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_205(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_205(op, st, BOOST_PP_SEQ_REVERSE_S(206, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_206(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_206(op, st, BOOST_PP_SEQ_REVERSE_S(207, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_207(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_207(op, st, BOOST_PP_SEQ_REVERSE_S(208, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_208(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_208(op, st, BOOST_PP_SEQ_REVERSE_S(209, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_209(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_209(op, st, BOOST_PP_SEQ_REVERSE_S(210, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_210(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_210(op, st, BOOST_PP_SEQ_REVERSE_S(211, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_211(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_211(op, st, BOOST_PP_SEQ_REVERSE_S(212, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_212(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_212(op, st, BOOST_PP_SEQ_REVERSE_S(213, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_213(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_213(op, st, BOOST_PP_SEQ_REVERSE_S(214, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_214(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_214(op, st, BOOST_PP_SEQ_REVERSE_S(215, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_215(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_215(op, st, BOOST_PP_SEQ_REVERSE_S(216, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_216(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_216(op, st, BOOST_PP_SEQ_REVERSE_S(217, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_217(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_217(op, st, BOOST_PP_SEQ_REVERSE_S(218, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_218(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_218(op, st, BOOST_PP_SEQ_REVERSE_S(219, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_219(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_219(op, st, BOOST_PP_SEQ_REVERSE_S(220, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_220(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_220(op, st, BOOST_PP_SEQ_REVERSE_S(221, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_221(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_221(op, st, BOOST_PP_SEQ_REVERSE_S(222, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_222(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_222(op, st, BOOST_PP_SEQ_REVERSE_S(223, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_223(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_223(op, st, BOOST_PP_SEQ_REVERSE_S(224, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_224(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_224(op, st, BOOST_PP_SEQ_REVERSE_S(225, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_225(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_225(op, st, BOOST_PP_SEQ_REVERSE_S(226, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_226(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_226(op, st, BOOST_PP_SEQ_REVERSE_S(227, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_227(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_227(op, st, BOOST_PP_SEQ_REVERSE_S(228, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_228(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_228(op, st, BOOST_PP_SEQ_REVERSE_S(229, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_229(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_229(op, st, BOOST_PP_SEQ_REVERSE_S(230, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_230(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_230(op, st, BOOST_PP_SEQ_REVERSE_S(231, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_231(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_231(op, st, BOOST_PP_SEQ_REVERSE_S(232, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_232(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_232(op, st, BOOST_PP_SEQ_REVERSE_S(233, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_233(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_233(op, st, BOOST_PP_SEQ_REVERSE_S(234, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_234(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_234(op, st, BOOST_PP_SEQ_REVERSE_S(235, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_235(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_235(op, st, BOOST_PP_SEQ_REVERSE_S(236, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_236(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_236(op, st, BOOST_PP_SEQ_REVERSE_S(237, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_237(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_237(op, st, BOOST_PP_SEQ_REVERSE_S(238, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_238(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_238(op, st, BOOST_PP_SEQ_REVERSE_S(239, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_239(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_239(op, st, BOOST_PP_SEQ_REVERSE_S(240, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_240(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_240(op, st, BOOST_PP_SEQ_REVERSE_S(241, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_241(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_241(op, st, BOOST_PP_SEQ_REVERSE_S(242, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_242(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_242(op, st, BOOST_PP_SEQ_REVERSE_S(243, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_243(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_243(op, st, BOOST_PP_SEQ_REVERSE_S(244, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_244(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_244(op, st, BOOST_PP_SEQ_REVERSE_S(245, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_245(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_245(op, st, BOOST_PP_SEQ_REVERSE_S(246, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_246(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_246(op, st, BOOST_PP_SEQ_REVERSE_S(247, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_247(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_247(op, st, BOOST_PP_SEQ_REVERSE_S(248, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_248(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_248(op, st, BOOST_PP_SEQ_REVERSE_S(249, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_249(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_249(op, st, BOOST_PP_SEQ_REVERSE_S(250, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_250(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_250(op, st, BOOST_PP_SEQ_REVERSE_S(251, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_251(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_251(op, st, BOOST_PP_SEQ_REVERSE_S(252, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_252(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_252(op, st, BOOST_PP_SEQ_REVERSE_S(253, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_253(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_253(op, st, BOOST_PP_SEQ_REVERSE_S(254, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_254(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_254(op, st, BOOST_PP_SEQ_REVERSE_S(255, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_255(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_255(op, st, BOOST_PP_SEQ_REVERSE_S(256, ss), BOOST_PP_SEQ_SIZE(ss)) +# define BOOST_PP_SEQ_FOLD_RIGHT_256(op, st, ss) BOOST_PP_SEQ_FOLD_LEFT_I_256(op, st, BOOST_PP_SEQ_REVERSE_S(257, ss), BOOST_PP_SEQ_SIZE(ss)) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/for_each_product.hpp b/src/third_party/boost/boost/preprocessor/seq/for_each_product.hpp new file mode 100644 index 00000000000..baf22df4809 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/for_each_product.hpp @@ -0,0 +1,126 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_FOR_EACH_PRODUCT_HPP +# define BOOST_PREPROCESSOR_SEQ_FOR_EACH_PRODUCT_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/control/if.hpp> +# include <boost/preprocessor/repetition/for.hpp> +# include <boost/preprocessor/seq/seq.hpp> +# include <boost/preprocessor/seq/size.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_SEQ_FOR_EACH_PRODUCT */ +# +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT(macro, sets) BOOST_PP_SEQ_FOR_EACH_PRODUCT_E(BOOST_PP_FOR, macro, sets) +# +# /* BOOST_PP_SEQ_FOR_EACH_PRODUCT_R */ +# +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_R(r, macro, sets) BOOST_PP_SEQ_FOR_EACH_PRODUCT_E(BOOST_PP_FOR_ ## r, macro, sets) +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_E(impl, macro, sets) impl((BOOST_PP_SEQ_HEAD(sets)(nil), BOOST_PP_SEQ_TAIL(sets)(nil), (nil), macro), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_0) +# else +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_E(impl, macro, sets) BOOST_PP_SEQ_FOR_EACH_PRODUCT_E_I(impl, macro, sets) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_E_I(impl, macro, sets) impl((BOOST_PP_SEQ_HEAD(sets)(nil), BOOST_PP_SEQ_TAIL(sets)(nil), (nil), macro), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_0) +# endif +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_P(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_P_I data +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_P_I(cset, rset, res, macro) BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(cset)) +# else +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_P(r, data) BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_ELEM(4, 0, data))) +# endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_O(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_O_I data +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_O_I(cset, rset, res, macro) (BOOST_PP_SEQ_TAIL(cset), rset, res, macro) +# else +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_O(r, data) (BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(4, 0, data)), BOOST_PP_TUPLE_ELEM(4, 1, data), BOOST_PP_TUPLE_ELEM(4, 2, data), BOOST_PP_TUPLE_ELEM(4, 3, data)) +# endif +# +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, i) BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_ELEM(4, 1, data))), BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_ ## i, BOOST_PP_SEQ_FOR_EACH_PRODUCT_I) +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_I(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_I_I(r, BOOST_PP_TUPLE_ELEM(4, 0, data), BOOST_PP_TUPLE_ELEM(4, 1, data), BOOST_PP_TUPLE_ELEM(4, 2, data), BOOST_PP_TUPLE_ELEM(4, 3, data)) +# else +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_I(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_I_IM(r, BOOST_PP_TUPLE_REM_4 data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_I_IM(r, im) BOOST_PP_SEQ_FOR_EACH_PRODUCT_I_I(r, im) +# endif +# +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_I_I(r, cset, rset, res, macro) macro(r, BOOST_PP_SEQ_TAIL(res (BOOST_PP_SEQ_HEAD(cset)))) +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_H_I data +# else +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_H_I(BOOST_PP_TUPLE_ELEM(4, 0, data), BOOST_PP_TUPLE_ELEM(4, 1, data), BOOST_PP_TUPLE_ELEM(4, 2, data), BOOST_PP_TUPLE_ELEM(4, 3, data)) +# endif +# +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_H_I(cset, rset, res, macro) (BOOST_PP_SEQ_HEAD(rset)(nil), BOOST_PP_SEQ_TAIL(rset), res (BOOST_PP_SEQ_HEAD(cset)), macro) +# +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_0(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 0)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_1(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 1)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_2(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 2)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_3(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 3)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_4(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 4)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_5(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 5)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_6(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 6)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_7(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 7)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_8(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 8)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_9(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 9)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_10(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 10)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_11(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 11)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_12(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 12)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_13(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 13)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_14(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 14)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_15(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 15)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_16(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 16)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_17(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 17)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_18(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 18)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_19(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 19)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_20(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 20)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_21(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 21)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_22(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 22)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_23(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 23)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_24(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 24)(r, data) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_25(r, data) BOOST_PP_SEQ_FOR_EACH_PRODUCT_C(data, 25)(r, data) +# +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_0(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_1) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_1(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_2) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_2(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_3) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_3(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_4) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_4(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_5) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_5(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_6) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_6(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_7) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_7(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_8) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_8(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_9) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_9(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_10) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_10(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_11) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_11(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_12) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_12(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_13) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_13(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_14) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_14(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_15) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_15(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_16) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_16(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_17) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_17(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_18) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_18(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_19) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_19(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_20) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_20(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_21) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_21(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_22) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_22(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_23) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_23(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_24) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_24(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_25) +# define BOOST_PP_SEQ_FOR_EACH_PRODUCT_N_25(r, data) BOOST_PP_FOR_ ## r(BOOST_PP_SEQ_FOR_EACH_PRODUCT_H(data), BOOST_PP_SEQ_FOR_EACH_PRODUCT_P, BOOST_PP_SEQ_FOR_EACH_PRODUCT_O, BOOST_PP_SEQ_FOR_EACH_PRODUCT_M_26) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/insert.hpp b/src/third_party/boost/boost/preprocessor/seq/insert.hpp new file mode 100644 index 00000000000..59ce2f4d186 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/insert.hpp @@ -0,0 +1,28 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_INSERT_HPP +# define BOOST_PREPROCESSOR_SEQ_INSERT_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/seq/first_n.hpp> +# include <boost/preprocessor/seq/rest_n.hpp> +# +# /* BOOST_PP_SEQ_INSERT */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_INSERT(seq, i, elem) BOOST_PP_SEQ_FIRST_N(i, seq) (elem) BOOST_PP_SEQ_REST_N(i, seq) +# else +# define BOOST_PP_SEQ_INSERT(seq, i, elem) BOOST_PP_SEQ_INSERT_I(seq, i, elem) +# define BOOST_PP_SEQ_INSERT_I(seq, i, elem) BOOST_PP_SEQ_FIRST_N(i, seq) (elem) BOOST_PP_SEQ_REST_N(i, seq) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/pop_back.hpp b/src/third_party/boost/boost/preprocessor/seq/pop_back.hpp new file mode 100644 index 00000000000..54200d61858 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/pop_back.hpp @@ -0,0 +1,29 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_POP_BACK_HPP +# define BOOST_PREPROCESSOR_SEQ_POP_BACK_HPP +# +# include <boost/preprocessor/arithmetic/dec.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/seq/first_n.hpp> +# include <boost/preprocessor/seq/size.hpp> +# +# /* BOOST_PP_SEQ_POP_BACK */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_POP_BACK(seq) BOOST_PP_SEQ_FIRST_N(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)), seq) +# else +# define BOOST_PP_SEQ_POP_BACK(seq) BOOST_PP_SEQ_POP_BACK_I(seq) +# define BOOST_PP_SEQ_POP_BACK_I(seq) BOOST_PP_SEQ_FIRST_N(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)), seq) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/pop_front.hpp b/src/third_party/boost/boost/preprocessor/seq/pop_front.hpp new file mode 100644 index 00000000000..7d94eea9161 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/pop_front.hpp @@ -0,0 +1,27 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_POP_FRONT_HPP +# define BOOST_PREPROCESSOR_SEQ_POP_FRONT_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/seq/seq.hpp> +# +# /* BOOST_PP_SEQ_POP_FRONT */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_POP_FRONT(seq) BOOST_PP_SEQ_TAIL(seq) +# else +# define BOOST_PP_SEQ_POP_FRONT(seq) BOOST_PP_SEQ_POP_FRONT_I(seq) +# define BOOST_PP_SEQ_POP_FRONT_I(seq) BOOST_PP_SEQ_TAIL(seq) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/push_back.hpp b/src/third_party/boost/boost/preprocessor/seq/push_back.hpp new file mode 100644 index 00000000000..1938d0be644 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/push_back.hpp @@ -0,0 +1,19 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_PUSH_BACK_HPP +# define BOOST_PREPROCESSOR_SEQ_PUSH_BACK_HPP +# +# /* BOOST_PP_SEQ_PUSH_BACK */ +# +# define BOOST_PP_SEQ_PUSH_BACK(seq, elem) seq(elem) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/push_front.hpp b/src/third_party/boost/boost/preprocessor/seq/push_front.hpp new file mode 100644 index 00000000000..2ce73ad1a3f --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/push_front.hpp @@ -0,0 +1,19 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_PUSH_FRONT_HPP +# define BOOST_PREPROCESSOR_SEQ_PUSH_FRONT_HPP +# +# /* BOOST_PP_SEQ_PUSH_FRONT */ +# +# define BOOST_PP_SEQ_PUSH_FRONT(seq, elem) (elem)seq +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/remove.hpp b/src/third_party/boost/boost/preprocessor/seq/remove.hpp new file mode 100644 index 00000000000..d2f77b0c61b --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/remove.hpp @@ -0,0 +1,29 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_REMOVE_HPP +# define BOOST_PREPROCESSOR_SEQ_REMOVE_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/seq/first_n.hpp> +# include <boost/preprocessor/seq/rest_n.hpp> +# +# /* BOOST_PP_SEQ_REMOVE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_REMOVE(seq, i) BOOST_PP_SEQ_FIRST_N(i, seq) BOOST_PP_SEQ_REST_N(BOOST_PP_INC(i), seq) +# else +# define BOOST_PP_SEQ_REMOVE(seq, i) BOOST_PP_SEQ_REMOVE_I(seq, i) +# define BOOST_PP_SEQ_REMOVE_I(seq, i) BOOST_PP_SEQ_FIRST_N(i, seq) BOOST_PP_SEQ_REST_N(BOOST_PP_INC(i), seq) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/replace.hpp b/src/third_party/boost/boost/preprocessor/seq/replace.hpp new file mode 100644 index 00000000000..d6107a76268 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/replace.hpp @@ -0,0 +1,29 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_REPLACE_HPP +# define BOOST_PREPROCESSOR_SEQ_REPLACE_HPP +# +# include <boost/preprocessor/arithmetic/inc.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/seq/first_n.hpp> +# include <boost/preprocessor/seq/rest_n.hpp> +# +# /* BOOST_PP_SEQ_REPLACE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_REPLACE(seq, i, elem) BOOST_PP_SEQ_FIRST_N(i, seq) (elem) BOOST_PP_SEQ_REST_N(BOOST_PP_INC(i), seq) +# else +# define BOOST_PP_SEQ_REPLACE(seq, i, elem) BOOST_PP_SEQ_REPLACE_I(seq, i, elem) +# define BOOST_PP_SEQ_REPLACE_I(seq, i, elem) BOOST_PP_SEQ_FIRST_N(i, seq) (elem) BOOST_PP_SEQ_REST_N(BOOST_PP_INC(i), seq) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/reverse.hpp b/src/third_party/boost/boost/preprocessor/seq/reverse.hpp new file mode 100644 index 00000000000..338d777d77b --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/reverse.hpp @@ -0,0 +1,39 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_REVERSE_HPP +# define BOOST_PREPROCESSOR_SEQ_REVERSE_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/facilities/empty.hpp> +# include <boost/preprocessor/seq/fold_left.hpp> +# +# /* BOOST_PP_SEQ_REVERSE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_REVERSE(seq) BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_REVERSE_O, BOOST_PP_EMPTY, seq)() +# else +# define BOOST_PP_SEQ_REVERSE(seq) BOOST_PP_SEQ_REVERSE_I(seq) +# define BOOST_PP_SEQ_REVERSE_I(seq) BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_REVERSE_O, BOOST_PP_EMPTY, seq)() +# endif +# +# define BOOST_PP_SEQ_REVERSE_O(s, state, elem) (elem) state +# +# /* BOOST_PP_SEQ_REVERSE_S */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_REVERSE_S(s, seq) BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_REVERSE_O, BOOST_PP_EMPTY, seq)() +# else +# define BOOST_PP_SEQ_REVERSE_S(s, seq) BOOST_PP_SEQ_REVERSE_S_I(s, seq) +# define BOOST_PP_SEQ_REVERSE_S_I(s, seq) BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_REVERSE_O, BOOST_PP_EMPTY, seq)() +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/to_array.hpp b/src/third_party/boost/boost/preprocessor/seq/to_array.hpp new file mode 100644 index 00000000000..d8a8040f8d8 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/to_array.hpp @@ -0,0 +1,28 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_TO_ARRAY_HPP +# define BOOST_PREPROCESSOR_SEQ_TO_ARRAY_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/seq/enum.hpp> +# include <boost/preprocessor/seq/size.hpp> +# +# /* BOOST_PP_SEQ_TO_ARRAY */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_TO_ARRAY(seq) (BOOST_PP_SEQ_SIZE(seq), (BOOST_PP_SEQ_ENUM(seq))) +# else +# define BOOST_PP_SEQ_TO_ARRAY(seq) BOOST_PP_SEQ_TO_ARRAY_I(seq) +# define BOOST_PP_SEQ_TO_ARRAY_I(seq) (BOOST_PP_SEQ_SIZE(seq), (BOOST_PP_SEQ_ENUM(seq))) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/to_list.hpp b/src/third_party/boost/boost/preprocessor/seq/to_list.hpp new file mode 100644 index 00000000000..fa0421bcc8c --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/to_list.hpp @@ -0,0 +1,29 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2011. * +# * (C) Copyright Edward Diener 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_TO_LIST_HPP +# define BOOST_PREPROCESSOR_SEQ_TO_LIST_HPP +# +# include <boost/preprocessor/punctuation/comma.hpp> +# include <boost/preprocessor/punctuation/paren.hpp> +# include <boost/preprocessor/seq/detail/binary_transform.hpp> +# +# /* BOOST_PP_SEQ_TO_LIST */ +# +# define BOOST_PP_SEQ_TO_LIST(seq) BOOST_PP_SEQ_TO_LIST_I(BOOST_PP_SEQ_BINARY_TRANSFORM(seq)) +# define BOOST_PP_SEQ_TO_LIST_I(bseq) BOOST_PP_SEQ_TO_LIST_A bseq BOOST_PP_NIL BOOST_PP_SEQ_TO_LIST_B bseq +# define BOOST_PP_SEQ_TO_LIST_A(m, e) m(BOOST_PP_LPAREN() e BOOST_PP_COMMA() BOOST_PP_SEQ_TO_LIST_A_ID) +# define BOOST_PP_SEQ_TO_LIST_A_ID() BOOST_PP_SEQ_TO_LIST_A +# define BOOST_PP_SEQ_TO_LIST_B(m, e) m(BOOST_PP_RPAREN() BOOST_PP_SEQ_TO_LIST_B_ID) +# define BOOST_PP_SEQ_TO_LIST_B_ID() BOOST_PP_SEQ_TO_LIST_B +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/seq/to_tuple.hpp b/src/third_party/boost/boost/preprocessor/seq/to_tuple.hpp new file mode 100644 index 00000000000..ab38eb97fae --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/seq/to_tuple.hpp @@ -0,0 +1,27 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_TO_TUPLE_HPP +# define BOOST_PREPROCESSOR_SEQ_TO_TUPLE_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/seq/enum.hpp> +# +# /* BOOST_PP_SEQ_TO_TUPLE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_TO_TUPLE(seq) (BOOST_PP_SEQ_ENUM(seq)) +# else +# define BOOST_PP_SEQ_TO_TUPLE(seq) BOOST_PP_SEQ_TO_TUPLE_I(seq) +# define BOOST_PP_SEQ_TO_TUPLE_I(seq) (BOOST_PP_SEQ_ENUM(seq)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/slot.hpp b/src/third_party/boost/boost/preprocessor/slot.hpp new file mode 100644 index 00000000000..fb3c9b01dfc --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/slot.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SLOT_HPP +# define BOOST_PREPROCESSOR_SLOT_HPP +# +# include <boost/preprocessor/slot/slot.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/slot/counter.hpp b/src/third_party/boost/boost/preprocessor/slot/counter.hpp new file mode 100644 index 00000000000..d257a649a1b --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/slot/counter.hpp @@ -0,0 +1,25 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2005. * +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SLOT_COUNTER_HPP +# define BOOST_PREPROCESSOR_SLOT_COUNTER_HPP +# +# include <boost/preprocessor/slot/detail/def.hpp> +# +# /* BOOST_PP_COUNTER */ +# +# define BOOST_PP_COUNTER 0 +# +# /* BOOST_PP_UPDATE_COUNTER */ +# +# define BOOST_PP_UPDATE_COUNTER() <boost/preprocessor/slot/detail/counter.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/tuple.hpp b/src/third_party/boost/boost/preprocessor/tuple.hpp new file mode 100644 index 00000000000..0f4976b7aee --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/tuple.hpp @@ -0,0 +1,28 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# /* Revised by Edward Diener (2011) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_TUPLE_HPP +# define BOOST_PREPROCESSOR_TUPLE_HPP +# +# include <boost/preprocessor/tuple/eat.hpp> +# include <boost/preprocessor/tuple/elem.hpp> +# include <boost/preprocessor/tuple/enum.hpp> +# include <boost/preprocessor/tuple/rem.hpp> +# include <boost/preprocessor/tuple/reverse.hpp> +# include <boost/preprocessor/tuple/size.hpp> +# include <boost/preprocessor/tuple/to_array.hpp> +# include <boost/preprocessor/tuple/to_list.hpp> +# include <boost/preprocessor/tuple/to_seq.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/tuple/enum.hpp b/src/third_party/boost/boost/preprocessor/tuple/enum.hpp new file mode 100644 index 00000000000..4915831e479 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/tuple/enum.hpp @@ -0,0 +1,22 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_TUPLE_ENUM_HPP +# define BOOST_PREPROCESSOR_TUPLE_ENUM_HPP +# +# include <boost/preprocessor/tuple/rem.hpp> +# +# /* BOOST_PP_TUPLE_ENUM */ +# +# define BOOST_PP_TUPLE_ENUM BOOST_PP_TUPLE_REM_CTOR +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/tuple/reverse.hpp b/src/third_party/boost/boost/preprocessor/tuple/reverse.hpp new file mode 100644 index 00000000000..c4f263ad0d3 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/tuple/reverse.hpp @@ -0,0 +1,114 @@ +# /* Copyright (C) 2001 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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) +# */ +# +# /* Revised by Paul Mensonides (2002-2011) */ +# /* Revised by Edward Diener (2011) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_TUPLE_REVERSE_HPP +# define BOOST_PREPROCESSOR_TUPLE_REVERSE_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/facilities/overload.hpp> +# +# /* BOOST_PP_TUPLE_REVERSE */ +# +# if BOOST_PP_VARIADICS +# if BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_TUPLE_REVERSE(...) BOOST_PP_TUPLE_REVERSE_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_REVERSE_O_, __VA_ARGS__), (__VA_ARGS__)) +# define BOOST_PP_TUPLE_REVERSE_I(m, args) BOOST_PP_TUPLE_REVERSE_II(m, args) +# define BOOST_PP_TUPLE_REVERSE_II(m, args) BOOST_PP_CAT(m ## args,) +# else +# define BOOST_PP_TUPLE_REVERSE(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_REVERSE_O_, __VA_ARGS__)(__VA_ARGS__) +# endif +# define BOOST_PP_TUPLE_REVERSE_O_1(tuple) BOOST_PP_CAT(BOOST_PP_TUPLE_REVERSE_, BOOST_PP_VARIADIC_SIZE tuple) tuple +# define BOOST_PP_TUPLE_REVERSE_O_2(size, tuple) BOOST_PP_TUPLE_REVERSE_O_1(tuple) +# else +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_TUPLE_REVERSE(size, tuple) BOOST_PP_TUPLE_REVERSE_I(size, tuple) +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_TUPLE_REVERSE_I(s, t) BOOST_PP_TUPLE_REVERSE_ ## s t +# else +# define BOOST_PP_TUPLE_REVERSE_I(s, t) BOOST_PP_TUPLE_REVERSE_II(BOOST_PP_TUPLE_REVERSE_ ## s t) +# define BOOST_PP_TUPLE_REVERSE_II(res) res +# endif +# else +# define BOOST_PP_TUPLE_REVERSE(size, tuple) BOOST_PP_TUPLE_REVERSE_OO((size, tuple)) +# define BOOST_PP_TUPLE_REVERSE_OO(par) BOOST_PP_TUPLE_REVERSE_I ## par +# define BOOST_PP_TUPLE_REVERSE_I(s, t) BOOST_PP_TUPLE_REVERSE_ ## s ## t +# endif +# endif +# define BOOST_PP_TUPLE_REVERSE_1(e0) (e0) +# define BOOST_PP_TUPLE_REVERSE_2(e0, e1) (e1, e0) +# define BOOST_PP_TUPLE_REVERSE_3(e0, e1, e2) (e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_4(e0, e1, e2, e3) (e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_5(e0, e1, e2, e3, e4) (e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_6(e0, e1, e2, e3, e4, e5) (e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_7(e0, e1, e2, e3, e4, e5, e6) (e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_8(e0, e1, e2, e3, e4, e5, e6, e7) (e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_9(e0, e1, e2, e3, e4, e5, e6, e7, e8) (e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_10(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9) (e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_11(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10) (e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_12(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11) (e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_13(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12) (e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_14(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13) (e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_15(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14) (e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_16(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15) (e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_17(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16) (e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_18(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17) (e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_19(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18) (e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_20(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19) (e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_21(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20) (e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_22(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21) (e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_23(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22) (e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_24(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23) (e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_25(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24) (e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_26(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25) (e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_27(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26) (e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_28(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27) (e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_29(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28) (e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_30(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29) (e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_31(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30) (e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_32(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31) (e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_33(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32) (e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_34(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33) (e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_35(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34) (e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_36(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35) (e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_37(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36) (e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_38(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37) (e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_39(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38) (e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_40(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39) (e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_41(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40) (e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_42(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41) (e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_43(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42) (e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_44(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43) (e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_45(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44) (e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_46(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45) (e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_47(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46) (e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_48(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47) (e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_49(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48) (e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_50(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49) (e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_51(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50) (e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_52(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51) (e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_53(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52) (e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_54(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53) (e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_55(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54) (e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_56(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55) (e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_57(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56) (e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_58(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57) (e57, e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_59(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58) (e58, e57, e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_60(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59) (e59, e58, e57, e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_61(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60) (e60, e59, e58, e57, e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_62(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61) (e61, e60, e59, e58, e57, e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_63(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62) (e62, e61, e60, e59, e58, e57, e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# define BOOST_PP_TUPLE_REVERSE_64(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) (e63, e62, e61, e60, e59, e58, e57, e56, e55, e54, e53, e52, e51, e50, e49, e48, e47, e46, e45, e44, e43, e42, e41, e40, e39, e38, e37, e36, e35, e34, e33, e32, e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/tuple/size.hpp b/src/third_party/boost/boost/preprocessor/tuple/size.hpp new file mode 100644 index 00000000000..675c0651663 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/tuple/size.hpp @@ -0,0 +1,28 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_TUPLE_SIZE_HPP +# define BOOST_PREPROCESSOR_TUPLE_SIZE_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/variadic/size.hpp> +# +# if BOOST_PP_VARIADICS +# if BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_TUPLE_SIZE(tuple) BOOST_PP_CAT(BOOST_PP_VARIADIC_SIZE tuple,) +# else +# define BOOST_PP_TUPLE_SIZE(tuple) BOOST_PP_VARIADIC_SIZE tuple +# endif +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/tuple/to_array.hpp b/src/third_party/boost/boost/preprocessor/tuple/to_array.hpp new file mode 100644 index 00000000000..1b994f3f38a --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/tuple/to_array.hpp @@ -0,0 +1,37 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_TUPLE_TO_ARRAY_HPP +# define BOOST_PREPROCESSOR_TUPLE_TO_ARRAY_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/facilities/overload.hpp> +# include <boost/preprocessor/variadic/size.hpp> +# +# /* BOOST_PP_TUPLE_TO_ARRAY */ +# +# if BOOST_PP_VARIADICS +# if BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_TUPLE_TO_ARRAY(...) BOOST_PP_TUPLE_TO_ARRAY_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_TO_ARRAY_, __VA_ARGS__), (__VA_ARGS__)) +# define BOOST_PP_TUPLE_TO_ARRAY_I(m, args) BOOST_PP_TUPLE_TO_ARRAY_II(m, args) +# define BOOST_PP_TUPLE_TO_ARRAY_II(m, args) BOOST_PP_CAT(m ## args,) +# else +# define BOOST_PP_TUPLE_TO_ARRAY(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_TO_ARRAY_, __VA_ARGS__)(__VA_ARGS__) +# endif +# define BOOST_PP_TUPLE_TO_ARRAY_1(tuple) (BOOST_PP_VARIADIC_SIZE tuple, tuple) +# define BOOST_PP_TUPLE_TO_ARRAY_2(size, tuple) (size, tuple) +# else +# define BOOST_PP_TUPLE_TO_ARRAY(size, tuple) (size, tuple) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/tuple/to_seq.hpp b/src/third_party/boost/boost/preprocessor/tuple/to_seq.hpp new file mode 100644 index 00000000000..1fb7b811c77 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/tuple/to_seq.hpp @@ -0,0 +1,114 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002-2011. * +# * (C) Copyright Edward Diener 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_TUPLE_TO_SEQ_HPP +# define BOOST_PREPROCESSOR_TUPLE_TO_SEQ_HPP +# +# include <boost/preprocessor/cat.hpp> +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/facilities/overload.hpp> +# include <boost/preprocessor/variadic/size.hpp> +# +# /* BOOST_PP_TUPLE_TO_SEQ */ +# +# if BOOST_PP_VARIADICS +# if BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_TUPLE_TO_SEQ(...) BOOST_PP_TUPLE_TO_SEQ_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_TO_SEQ_O_, __VA_ARGS__), (__VA_ARGS__)) +# define BOOST_PP_TUPLE_TO_SEQ_I(m, args) BOOST_PP_TUPLE_TO_SEQ_II(m, args) +# define BOOST_PP_TUPLE_TO_SEQ_II(m, args) BOOST_PP_CAT(m ## args,) +# else +# define BOOST_PP_TUPLE_TO_SEQ(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_TO_SEQ_O_, __VA_ARGS__)(__VA_ARGS__) +# endif +# define BOOST_PP_TUPLE_TO_SEQ_O_1(tuple) BOOST_PP_CAT(BOOST_PP_TUPLE_TO_SEQ_, BOOST_PP_VARIADIC_SIZE tuple) tuple +# define BOOST_PP_TUPLE_TO_SEQ_O_2(size, tuple) BOOST_PP_TUPLE_TO_SEQ_O_1(tuple) +# else +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_TUPLE_TO_SEQ(size, tuple) BOOST_PP_TUPLE_TO_SEQ_I(size, tuple) +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_TUPLE_TO_SEQ_I(s, t) BOOST_PP_TUPLE_TO_SEQ_ ## s t +# else +# define BOOST_PP_TUPLE_TO_SEQ_I(s, t) BOOST_PP_TUPLE_TO_SEQ_II(BOOST_PP_TUPLE_TO_SEQ_ ## s t) +# define BOOST_PP_TUPLE_TO_SEQ_II(res) res +# endif +# else +# define BOOST_PP_TUPLE_TO_SEQ(size, tuple) BOOST_PP_TUPLE_TO_SEQ_OO((size, tuple)) +# define BOOST_PP_TUPLE_TO_SEQ_OO(par) BOOST_PP_TUPLE_TO_SEQ_I ## par +# define BOOST_PP_TUPLE_TO_SEQ_I(s, t) BOOST_PP_TUPLE_TO_SEQ_ ## s ## t +# endif +# endif +# +# define BOOST_PP_TUPLE_TO_SEQ_1(e0) (e0) +# define BOOST_PP_TUPLE_TO_SEQ_2(e0, e1) (e0)(e1) +# define BOOST_PP_TUPLE_TO_SEQ_3(e0, e1, e2) (e0)(e1)(e2) +# define BOOST_PP_TUPLE_TO_SEQ_4(e0, e1, e2, e3) (e0)(e1)(e2)(e3) +# define BOOST_PP_TUPLE_TO_SEQ_5(e0, e1, e2, e3, e4) (e0)(e1)(e2)(e3)(e4) +# define BOOST_PP_TUPLE_TO_SEQ_6(e0, e1, e2, e3, e4, e5) (e0)(e1)(e2)(e3)(e4)(e5) +# define BOOST_PP_TUPLE_TO_SEQ_7(e0, e1, e2, e3, e4, e5, e6) (e0)(e1)(e2)(e3)(e4)(e5)(e6) +# define BOOST_PP_TUPLE_TO_SEQ_8(e0, e1, e2, e3, e4, e5, e6, e7) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7) +# define BOOST_PP_TUPLE_TO_SEQ_9(e0, e1, e2, e3, e4, e5, e6, e7, e8) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8) +# define BOOST_PP_TUPLE_TO_SEQ_10(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9) +# define BOOST_PP_TUPLE_TO_SEQ_11(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10) +# define BOOST_PP_TUPLE_TO_SEQ_12(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11) +# define BOOST_PP_TUPLE_TO_SEQ_13(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12) +# define BOOST_PP_TUPLE_TO_SEQ_14(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13) +# define BOOST_PP_TUPLE_TO_SEQ_15(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14) +# define BOOST_PP_TUPLE_TO_SEQ_16(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15) +# define BOOST_PP_TUPLE_TO_SEQ_17(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16) +# define BOOST_PP_TUPLE_TO_SEQ_18(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17) +# define BOOST_PP_TUPLE_TO_SEQ_19(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18) +# define BOOST_PP_TUPLE_TO_SEQ_20(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19) +# define BOOST_PP_TUPLE_TO_SEQ_21(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20) +# define BOOST_PP_TUPLE_TO_SEQ_22(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21) +# define BOOST_PP_TUPLE_TO_SEQ_23(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22) +# define BOOST_PP_TUPLE_TO_SEQ_24(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23) +# define BOOST_PP_TUPLE_TO_SEQ_25(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24) +# define BOOST_PP_TUPLE_TO_SEQ_26(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25) +# define BOOST_PP_TUPLE_TO_SEQ_27(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26) +# define BOOST_PP_TUPLE_TO_SEQ_28(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27) +# define BOOST_PP_TUPLE_TO_SEQ_29(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28) +# define BOOST_PP_TUPLE_TO_SEQ_30(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29) +# define BOOST_PP_TUPLE_TO_SEQ_31(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30) +# define BOOST_PP_TUPLE_TO_SEQ_32(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31) +# define BOOST_PP_TUPLE_TO_SEQ_33(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32) +# define BOOST_PP_TUPLE_TO_SEQ_34(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33) +# define BOOST_PP_TUPLE_TO_SEQ_35(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34) +# define BOOST_PP_TUPLE_TO_SEQ_36(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35) +# define BOOST_PP_TUPLE_TO_SEQ_37(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36) +# define BOOST_PP_TUPLE_TO_SEQ_38(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37) +# define BOOST_PP_TUPLE_TO_SEQ_39(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38) +# define BOOST_PP_TUPLE_TO_SEQ_40(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39) +# define BOOST_PP_TUPLE_TO_SEQ_41(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40) +# define BOOST_PP_TUPLE_TO_SEQ_42(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41) +# define BOOST_PP_TUPLE_TO_SEQ_43(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42) +# define BOOST_PP_TUPLE_TO_SEQ_44(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43) +# define BOOST_PP_TUPLE_TO_SEQ_45(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44) +# define BOOST_PP_TUPLE_TO_SEQ_46(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45) +# define BOOST_PP_TUPLE_TO_SEQ_47(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46) +# define BOOST_PP_TUPLE_TO_SEQ_48(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47) +# define BOOST_PP_TUPLE_TO_SEQ_49(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48) +# define BOOST_PP_TUPLE_TO_SEQ_50(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49) +# define BOOST_PP_TUPLE_TO_SEQ_51(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50) +# define BOOST_PP_TUPLE_TO_SEQ_52(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51) +# define BOOST_PP_TUPLE_TO_SEQ_53(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52) +# define BOOST_PP_TUPLE_TO_SEQ_54(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53) +# define BOOST_PP_TUPLE_TO_SEQ_55(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54) +# define BOOST_PP_TUPLE_TO_SEQ_56(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55) +# define BOOST_PP_TUPLE_TO_SEQ_57(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56) +# define BOOST_PP_TUPLE_TO_SEQ_58(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56)(e57) +# define BOOST_PP_TUPLE_TO_SEQ_59(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56)(e57)(e58) +# define BOOST_PP_TUPLE_TO_SEQ_60(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56)(e57)(e58)(e59) +# define BOOST_PP_TUPLE_TO_SEQ_61(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56)(e57)(e58)(e59)(e60) +# define BOOST_PP_TUPLE_TO_SEQ_62(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56)(e57)(e58)(e59)(e60)(e61) +# define BOOST_PP_TUPLE_TO_SEQ_63(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56)(e57)(e58)(e59)(e60)(e61)(e62) +# define BOOST_PP_TUPLE_TO_SEQ_64(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) (e0)(e1)(e2)(e3)(e4)(e5)(e6)(e7)(e8)(e9)(e10)(e11)(e12)(e13)(e14)(e15)(e16)(e17)(e18)(e19)(e20)(e21)(e22)(e23)(e24)(e25)(e26)(e27)(e28)(e29)(e30)(e31)(e32)(e33)(e34)(e35)(e36)(e37)(e38)(e39)(e40)(e41)(e42)(e43)(e44)(e45)(e46)(e47)(e48)(e49)(e50)(e51)(e52)(e53)(e54)(e55)(e56)(e57)(e58)(e59)(e60)(e61)(e62)(e63) +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/variadic.hpp b/src/third_party/boost/boost/preprocessor/variadic.hpp new file mode 100644 index 00000000000..a28e026af4e --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/variadic.hpp @@ -0,0 +1,23 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_VARIADIC_HPP +# define BOOST_PREPROCESSOR_VARIADIC_HPP +# +# include <boost/preprocessor/variadic/elem.hpp> +# include <boost/preprocessor/variadic/size.hpp> +# include <boost/preprocessor/variadic/to_array.hpp> +# include <boost/preprocessor/variadic/to_list.hpp> +# include <boost/preprocessor/variadic/to_seq.hpp> +# include <boost/preprocessor/variadic/to_tuple.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/variadic/to_array.hpp b/src/third_party/boost/boost/preprocessor/variadic/to_array.hpp new file mode 100644 index 00000000000..14c2b9220e2 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/variadic/to_array.hpp @@ -0,0 +1,32 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_VARIADIC_TO_ARRAY_HPP +# define BOOST_PREPROCESSOR_VARIADIC_TO_ARRAY_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/to_array.hpp> +# if BOOST_PP_VARIADICS_MSVC +# include <boost/preprocessor/variadic/size.hpp> +# endif +# +# /* BOOST_PP_VARIADIC_TO_ARRAY */ +# +# if BOOST_PP_VARIADICS +# if BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_VARIADIC_TO_ARRAY(...) BOOST_PP_TUPLE_TO_ARRAY_2(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),(__VA_ARGS__)) +# else +# define BOOST_PP_VARIADIC_TO_ARRAY(...) BOOST_PP_TUPLE_TO_ARRAY((__VA_ARGS__)) +# endif +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/variadic/to_list.hpp b/src/third_party/boost/boost/preprocessor/variadic/to_list.hpp new file mode 100644 index 00000000000..43d526a9421 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/variadic/to_list.hpp @@ -0,0 +1,25 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_VARIADIC_TO_LIST_HPP +# define BOOST_PREPROCESSOR_VARIADIC_TO_LIST_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/to_list.hpp> +# +# /* BOOST_PP_VARIADIC_TO_LIST */ +# +# if BOOST_PP_VARIADICS +# define BOOST_PP_VARIADIC_TO_LIST(...) BOOST_PP_TUPLE_TO_LIST((__VA_ARGS__)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/variadic/to_seq.hpp b/src/third_party/boost/boost/preprocessor/variadic/to_seq.hpp new file mode 100644 index 00000000000..255af4f38cb --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/variadic/to_seq.hpp @@ -0,0 +1,25 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_VARIADIC_TO_SEQ_HPP +# define BOOST_PREPROCESSOR_VARIADIC_TO_SEQ_HPP +# +# include <boost/preprocessor/config/config.hpp> +# include <boost/preprocessor/tuple/to_seq.hpp> +# +# /* BOOST_PP_VARIADIC_TO_SEQ */ +# +# if BOOST_PP_VARIADICS +# define BOOST_PP_VARIADIC_TO_SEQ(...) BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__)) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/variadic/to_tuple.hpp b/src/third_party/boost/boost/preprocessor/variadic/to_tuple.hpp new file mode 100644 index 00000000000..ddb6d8b1310 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/variadic/to_tuple.hpp @@ -0,0 +1,24 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2011. * +# * (C) Copyright Paul Mensonides 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_VARIADIC_TO_TUPLE_HPP +# define BOOST_PREPROCESSOR_VARIADIC_TO_TUPLE_HPP +# +# include <boost/preprocessor/config/config.hpp> +# +# /* BOOST_PP_VARIADIC_TO_TUPLE */ +# +# if BOOST_PP_VARIADICS +# define BOOST_PP_VARIADIC_TO_TUPLE(...) (__VA_ARGS__) +# endif +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/while.hpp b/src/third_party/boost/boost/preprocessor/while.hpp new file mode 100644 index 00000000000..4b9c801ac0e --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/while.hpp @@ -0,0 +1,17 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_WHILE_HPP +# define BOOST_PREPROCESSOR_WHILE_HPP +# +# include <boost/preprocessor/control/while.hpp> +# +# endif diff --git a/src/third_party/boost/boost/preprocessor/wstringize.hpp b/src/third_party/boost/boost/preprocessor/wstringize.hpp new file mode 100644 index 00000000000..5d1a83aa2e0 --- /dev/null +++ b/src/third_party/boost/boost/preprocessor/wstringize.hpp @@ -0,0 +1,29 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * 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 for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_WSTRINGIZE_HPP +# define BOOST_PREPROCESSOR_WSTRINGIZE_HPP +# +# include <boost/preprocessor/config/config.hpp> +# +# /* BOOST_PP_WSTRINGIZE */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_WSTRINGIZE(text) BOOST_PP_WSTRINGIZE_I(text) +# else +# define BOOST_PP_WSTRINGIZE(text) BOOST_PP_WSTRINGIZE_OO((text)) +# define BOOST_PP_WSTRINGIZE_OO(par) BOOST_PP_WSTRINGIZE_I ## par +# endif +# +# define BOOST_PP_WSTRINGIZE_I(text) BOOST_PP_WSTRINGIZE_II(#text) +# define BOOST_PP_WSTRINGIZE_II(str) L ## str +# +# endif |