diff --git a/include/boost/intrusive/any_hook.hpp b/include/boost/intrusive/any_hook.hpp index b53df9f..5b047c9 100644 --- a/include/boost/intrusive/any_hook.hpp +++ b/include/boost/intrusive/any_hook.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace boost { namespace intrusive { @@ -244,15 +244,15 @@ namespace detail{ template struct any_to_get_base_pointer_type { - typedef typename pointer_traits::template - rebind_pointer::type type; + typedef typename pointer_rebind + ::type type; }; template struct any_to_get_member_pointer_type { - typedef typename pointer_traits - ::template rebind_pointer::type type; + typedef typename pointer_rebind + ::type type; }; //!This option setter specifies that the container diff --git a/include/boost/intrusive/avl_set.hpp b/include/boost/intrusive/avl_set.hpp index 827e03b..9ae6bd4 100644 --- a/include/boost/intrusive/avl_set.hpp +++ b/include/boost/intrusive/avl_set.hpp @@ -18,7 +18,6 @@ #include #include #include -#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/avltree.hpp b/include/boost/intrusive/avltree.hpp index 717af8b..5996abc 100644 --- a/include/boost/intrusive/avltree.hpp +++ b/include/boost/intrusive/avltree.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/include/boost/intrusive/bs_set.hpp b/include/boost/intrusive/bs_set.hpp index 9bcf677..8a328fa 100644 --- a/include/boost/intrusive/bs_set.hpp +++ b/include/boost/intrusive/bs_set.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/include/boost/intrusive/bstree.hpp b/include/boost/intrusive/bstree.hpp index 3b0ecb1..c7dc0b2 100644 --- a/include/boost/intrusive/bstree.hpp +++ b/include/boost/intrusive/bstree.hpp @@ -14,20 +14,17 @@ #include #include -#include -#include -#include -#include #include #include #include #include #include +#include #include #include #include -#include +#include #include #include #include @@ -37,6 +34,12 @@ #include #include +#include //pair,lexicographical_compare +#include //swap +#include //size_t... +#include //less, equal_to + + namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/bstree_algorithms.hpp b/include/boost/intrusive/bstree_algorithms.hpp index 6eed031..ca12460 100644 --- a/include/boost/intrusive/bstree_algorithms.hpp +++ b/include/boost/intrusive/bstree_algorithms.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/intrusive/detail/any_node_and_algorithms.hpp b/include/boost/intrusive/detail/any_node_and_algorithms.hpp index eef537b..5777448 100644 --- a/include/boost/intrusive/detail/any_node_and_algorithms.hpp +++ b/include/boost/intrusive/detail/any_node_and_algorithms.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -25,8 +25,9 @@ namespace intrusive { template struct any_node { - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; + typedef any_node node; + typedef typename pointer_rebind::type node_ptr; + typedef typename pointer_rebind::type const_node_ptr; node_ptr node_ptr_1; node_ptr node_ptr_2; node_ptr node_ptr_3; @@ -36,11 +37,9 @@ struct any_node template struct any_list_node_traits { - typedef any_node node; - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type const_node_ptr; + typedef any_node node; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; static const node_ptr &get_next(const const_node_ptr & n) { return n->node_ptr_1; } @@ -59,11 +58,9 @@ struct any_list_node_traits template struct any_slist_node_traits { - typedef any_node node; - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type const_node_ptr; + typedef any_node node; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; static const node_ptr &get_next(const const_node_ptr & n) { return n->node_ptr_1; } @@ -108,12 +105,9 @@ struct any_unordered_node_traits template struct any_rbtree_node_traits { - typedef any_node node; - - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type const_node_ptr; + typedef any_node node; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; typedef std::size_t color; @@ -152,12 +146,10 @@ struct any_rbtree_node_traits template struct any_avltree_node_traits { - typedef any_node node; + typedef any_node node; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type const_node_ptr; typedef std::size_t balance; static const node_ptr &get_parent(const const_node_ptr & n) @@ -198,12 +190,9 @@ struct any_avltree_node_traits template struct any_tree_node_traits { - typedef any_node node; - - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type const_node_ptr; + typedef any_node node; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; static const node_ptr &get_parent(const const_node_ptr & n) { return n->node_ptr_1; } @@ -229,10 +218,8 @@ class any_node_traits { public: typedef any_node node; - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type const_node_ptr; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; }; template @@ -243,12 +230,10 @@ class any_algorithms {} public: - typedef any_node node; - typedef typename pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer::type const_node_ptr; - typedef any_node_traits node_traits; + typedef any_node node; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; + typedef any_node_traits node_traits; //! Requires: node must not be part of any tree. //! diff --git a/include/boost/intrusive/detail/avltree_node.hpp b/include/boost/intrusive/detail/avltree_node.hpp index 8031c7d..21ac1a2 100644 --- a/include/boost/intrusive/detail/avltree_node.hpp +++ b/include/boost/intrusive/detail/avltree_node.hpp @@ -14,8 +14,7 @@ #define BOOST_INTRUSIVE_AVLTREE_NODE_HPP #include -#include -#include +#include #include #include #include @@ -33,9 +32,8 @@ namespace intrusive { template struct compact_avltree_node { - typedef typename pointer_traits - ::template rebind_pointer - >::type node_ptr; + typedef typename pointer_rebind >::type node_ptr; + typedef typename pointer_rebind >::type const_node_ptr; enum balance { negative_t, zero_t, positive_t }; node_ptr parent_, left_, right_; }; @@ -44,9 +42,8 @@ struct compact_avltree_node template struct avltree_node { - typedef typename pointer_traits - ::template rebind_pointer - >::type node_ptr; + typedef typename pointer_rebind >::type node_ptr; + typedef typename pointer_rebind >::type const_node_ptr; enum balance { negative_t, zero_t, positive_t }; node_ptr parent_, left_, right_; balance balance_; @@ -58,13 +55,8 @@ template struct default_avltree_node_traits_impl { typedef avltree_node node; - - typedef typename pointer_traits - ::template rebind_pointer - ::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer - ::type const_node_ptr; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; typedef typename node::balance balance; @@ -120,13 +112,8 @@ template struct compact_avltree_node_traits_impl { typedef compact_avltree_node node; - - typedef typename pointer_traits - ::template rebind_pointer - ::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer - ::type const_node_ptr; + typedef typename node::node_ptr node_ptr; + typedef typename node::const_node_ptr const_node_ptr; typedef typename node::balance balance; typedef pointer_plus_bits ptr_bit; diff --git a/include/boost/intrusive/detail/default_header_holder.hpp b/include/boost/intrusive/detail/default_header_holder.hpp index 35b715a..6e1c0ff 100644 --- a/include/boost/intrusive/detail/default_header_holder.hpp +++ b/include/boost/intrusive/detail/default_header_holder.hpp @@ -15,21 +15,7 @@ #include #include - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/detail/has_member_function_callable_with.hpp b/include/boost/intrusive/detail/has_member_function_callable_with.hpp index 9cd0779..ca96f15 100644 --- a/include/boost/intrusive/detail/has_member_function_callable_with.hpp +++ b/include/boost/intrusive/detail/has_member_function_callable_with.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2011-2014. 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) // @@ -15,12 +15,9 @@ #ifndef BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED - #include - #include #include #include #include - #include //Mark that we don't support 0 arg calls due to compiler ICE in GCC 3.4/4.0/4.1 and @@ -38,6 +35,12 @@ dont_care(...); }; + template + struct make_dontcare + { + typedef boost_intrusive_has_member_function_callable_with::dont_care type; + }; + struct private_type { static private_type p; @@ -53,7 +56,9 @@ } //boost_intrusive_has_member_function_callable_with - #include + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_SINGLE_ITERATION + #endif #endif //BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED @@ -100,7 +105,7 @@ sizeof(boost_intrusive_has_member_function_callable_with::yes_type) == sizeof(deduce((Base*)(0))); }; - #if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template @@ -115,7 +120,7 @@ }; //! - #else //!defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #else //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl); @@ -171,30 +176,23 @@ == sizeof(boost_intrusive_has_member_function_callable_with::yes_type); }; - template - 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 struct BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl) { - template - struct make_dontcare + + template + struct FunWrapTmpl : Fun { - typedef boost_intrusive_has_member_function_callable_with::dont_care type; + FunWrapTmpl(); + 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; }; - typedef BOOST_PP_CAT( funwrap_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME ) - ::type...> FunWrap; + typedef FunWrapTmpl::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 @@ -216,7 +214,7 @@ , Args... > {}; - #endif //!defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #endif //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END @@ -226,7 +224,7 @@ BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN - #if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #if !defined(_MSC_VER) || (_MSC_VER < 1600) @@ -297,34 +295,18 @@ }; #endif //#if !defined(_MSC_VER) || (_MSC_VER < 1600) - #else //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #else //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #endif //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #endif //#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END #else //BOOST_PP_ITERATION() == 0 - #if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN - template - 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 struct BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_ , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) @@ -334,9 +316,18 @@ , 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)) - FunWrap; + struct FunWrap : Fun + { + FunWrap(); + + 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; + }; + 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 @@ -350,13 +341,13 @@ }; BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - #endif //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #endif //#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #endif //BOOST_PP_ITERATION() == 0 #if BOOST_PP_ITERATION() == BOOST_PP_ITERATION_FINISH() - #if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN @@ -370,7 +361,7 @@ BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - #endif //#if !defined(BOOST_INTRUSIVE_PERFECT_FORWARDING) + #endif //#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN diff --git a/include/boost/intrusive/detail/hashtable_node.hpp b/include/boost/intrusive/detail/hashtable_node.hpp index ba6e372..3f42f46 100644 --- a/include/boost/intrusive/detail/hashtable_node.hpp +++ b/include/boost/intrusive/detail/hashtable_node.hpp @@ -14,13 +14,12 @@ #define BOOST_INTRUSIVE_HASHTABLE_NODE_HPP #include -#include #include #include #include #include -#include //make_slist #include +#include //make_slist #include #include #include @@ -30,71 +29,6 @@ namespace boost { namespace intrusive { namespace detail { -template -struct prime_list_holder -{ - static const std::size_t prime_list[]; - static const std::size_t prime_list_size; -}; - -//We only support LLP64(Win64) or LP64(most Unix) data models -#ifdef _WIN64 //In 64 bit windows sizeof(size_t) == sizeof(unsigned long long) - #define BOOST_INTRUSIVE_PRIME_C(NUMBER) NUMBER##ULL - #define BOOST_INTRUSIVE_64_BIT_SIZE_T 1 -#else //In 32 bit windows and 32/64 bit unixes sizeof(size_t) == sizeof(unsigned long) - #define BOOST_INTRUSIVE_PRIME_C(NUMBER) NUMBER##UL - #define BOOST_INTRUSIVE_64_BIT_SIZE_T (((((ULONG_MAX>>16)>>16)>>16)>>15) != 0) -#endif - -template -const std::size_t prime_list_holder::prime_list[] = { - BOOST_INTRUSIVE_PRIME_C(3), BOOST_INTRUSIVE_PRIME_C(7), - BOOST_INTRUSIVE_PRIME_C(11), BOOST_INTRUSIVE_PRIME_C(17), - BOOST_INTRUSIVE_PRIME_C(29), BOOST_INTRUSIVE_PRIME_C(53), - BOOST_INTRUSIVE_PRIME_C(97), BOOST_INTRUSIVE_PRIME_C(193), - BOOST_INTRUSIVE_PRIME_C(389), BOOST_INTRUSIVE_PRIME_C(769), - BOOST_INTRUSIVE_PRIME_C(1543), BOOST_INTRUSIVE_PRIME_C(3079), - BOOST_INTRUSIVE_PRIME_C(6151), BOOST_INTRUSIVE_PRIME_C(12289), - BOOST_INTRUSIVE_PRIME_C(24593), BOOST_INTRUSIVE_PRIME_C(49157), - BOOST_INTRUSIVE_PRIME_C(98317), BOOST_INTRUSIVE_PRIME_C(196613), - BOOST_INTRUSIVE_PRIME_C(393241), BOOST_INTRUSIVE_PRIME_C(786433), - BOOST_INTRUSIVE_PRIME_C(1572869), BOOST_INTRUSIVE_PRIME_C(3145739), - BOOST_INTRUSIVE_PRIME_C(6291469), BOOST_INTRUSIVE_PRIME_C(12582917), - BOOST_INTRUSIVE_PRIME_C(25165843), BOOST_INTRUSIVE_PRIME_C(50331653), - BOOST_INTRUSIVE_PRIME_C(100663319), BOOST_INTRUSIVE_PRIME_C(201326611), - BOOST_INTRUSIVE_PRIME_C(402653189), BOOST_INTRUSIVE_PRIME_C(805306457), - BOOST_INTRUSIVE_PRIME_C(1610612741), BOOST_INTRUSIVE_PRIME_C(3221225473), -#if BOOST_INTRUSIVE_64_BIT_SIZE_T - //Taken from Boost.MultiIndex code, thanks to Joaquin M Lopez Munoz. - BOOST_INTRUSIVE_PRIME_C(6442450939), BOOST_INTRUSIVE_PRIME_C(12884901893), - BOOST_INTRUSIVE_PRIME_C(25769803751), BOOST_INTRUSIVE_PRIME_C(51539607551), - BOOST_INTRUSIVE_PRIME_C(103079215111), BOOST_INTRUSIVE_PRIME_C(206158430209), - BOOST_INTRUSIVE_PRIME_C(412316860441), BOOST_INTRUSIVE_PRIME_C(824633720831), - BOOST_INTRUSIVE_PRIME_C(1649267441651), BOOST_INTRUSIVE_PRIME_C(3298534883309), - BOOST_INTRUSIVE_PRIME_C(6597069766657), BOOST_INTRUSIVE_PRIME_C(13194139533299), - BOOST_INTRUSIVE_PRIME_C(26388279066623), BOOST_INTRUSIVE_PRIME_C(52776558133303), - BOOST_INTRUSIVE_PRIME_C(105553116266489), BOOST_INTRUSIVE_PRIME_C(211106232532969), - BOOST_INTRUSIVE_PRIME_C(422212465066001), BOOST_INTRUSIVE_PRIME_C(844424930131963), - BOOST_INTRUSIVE_PRIME_C(1688849860263953), BOOST_INTRUSIVE_PRIME_C(3377699720527861), - BOOST_INTRUSIVE_PRIME_C(6755399441055731), BOOST_INTRUSIVE_PRIME_C(13510798882111483), - BOOST_INTRUSIVE_PRIME_C(27021597764222939), BOOST_INTRUSIVE_PRIME_C(54043195528445957), - BOOST_INTRUSIVE_PRIME_C(108086391056891903), BOOST_INTRUSIVE_PRIME_C(216172782113783843), - BOOST_INTRUSIVE_PRIME_C(432345564227567621), BOOST_INTRUSIVE_PRIME_C(864691128455135207), - BOOST_INTRUSIVE_PRIME_C(1729382256910270481), BOOST_INTRUSIVE_PRIME_C(3458764513820540933), - BOOST_INTRUSIVE_PRIME_C(6917529027641081903), BOOST_INTRUSIVE_PRIME_C(13835058055282163729), - BOOST_INTRUSIVE_PRIME_C(18446744073709551557) -#else - BOOST_INTRUSIVE_PRIME_C(4294967291) -#endif - }; - -#undef BOOST_INTRUSIVE_PRIME_C -#undef BOOST_INTRUSIVE_64_BIT_SIZE_T - -template -const std::size_t prime_list_holder::prime_list_size - = sizeof(prime_list)/sizeof(std::size_t); - template struct bucket_impl : public Slist { @@ -214,7 +148,7 @@ struct get_slist_impl template class hashtable_iterator { - typedef std::iterator + typedef boost::intrusive::iterator < std::forward_iterator_tag , typename BucketValueTraits::value_traits::value_type , typename pointer_traits::difference_type diff --git a/include/boost/intrusive/detail/iiterator.hpp b/include/boost/intrusive/detail/iiterator.hpp new file mode 100644 index 0000000..ee314e7 --- /dev/null +++ b/include/boost/intrusive/detail/iiterator.hpp @@ -0,0 +1,226 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2014 +// +// 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_IITERATOR_HPP +#define BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP + +#include +#include +#include +#include +#include + +#include + + +namespace boost { +namespace intrusive { + +template +struct iterator +{ + typedef Category iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; +}; + +template +struct iterator_traits +{ + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + typedef typename Iterator::iterator_category iterator_category; +}; + +template +struct iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; + +template +struct iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef const T* pointer; + typedef const T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; + +template +struct value_traits_pointers +{ + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT + (boost::intrusive::detail:: + , ValueTraits, value_traits_ptr + , typename pointer_traits::template + rebind_pointer::type) value_traits_ptr; + + typedef typename pointer_traits::template + rebind_pointer::type const_value_traits_ptr; +}; + +template +struct iiterator +{ + typedef ValueTraits value_traits; + typedef typename value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef ::boost::intrusive::pointer_traits nodepointer_traits_t; + typedef typename nodepointer_traits_t::template + rebind_pointer::type void_pointer; + typedef typename ValueTraits::value_type value_type; + typedef typename ValueTraits::pointer nonconst_pointer; + typedef typename ValueTraits::const_pointer yesconst_pointer; + typedef typename ::boost::intrusive::pointer_traits + ::reference nonconst_reference; + typedef typename ::boost::intrusive::pointer_traits + ::reference yesconst_reference; + typedef typename nodepointer_traits_t::difference_type difference_type; + typedef typename detail::if_c + ::type pointer; + typedef typename detail::if_c + ::type reference; + typedef iterator + < Category + , value_type + , difference_type + , pointer + , reference + > iterator_traits; + typedef typename value_traits_pointers + ::value_traits_ptr value_traits_ptr; + typedef typename value_traits_pointers + ::const_value_traits_ptr const_value_traits_ptr; + static const bool stateful_value_traits = + detail::is_stateful_value_traits::value; +}; + +template +struct iiterator_members +{ + + iiterator_members() + : nodeptr_()//Value initialization to achieve "null iterators" (N3644) + {} + + iiterator_members(const NodePtr &n_ptr, const StoredPointer &data) + : nodeptr_(n_ptr), ptr_(data) + {} + + StoredPointer get_ptr() const + { return ptr_; } + + NodePtr nodeptr_; + StoredPointer ptr_; +}; + +template +struct iiterator_members +{ + iiterator_members() + : nodeptr_()//Value initialization to achieve "null iterators" (N3644) + {} + + iiterator_members(const NodePtr &n_ptr, const StoredPointer &) + : nodeptr_(n_ptr) + {} + + StoredPointer get_ptr() const + { return StoredPointer(); } + + NodePtr nodeptr_; +}; + +namespace detail { + +template inline +void advance_impl(InputIt& it, Distance n, const std::input_iterator_tag&) +{ + while(n--) + ++it; +} + +template inline +void advance_impl(InputIt& it, Distance n, std::forward_iterator_tag &) +{ + while(n--) + ++it; +} + +template inline +void advance_impl(InputIt& it, Distance n, std::bidirectional_iterator_tag &) +{ + for (; 0 < n; --n) + ++it; + for (; n < 0; ++n) + --it; +} + +template +inline void advance_impl(InputIt& it, Distance n, const std::random_access_iterator_tag &) +{ + it += n; +} + +} //namespace detail + +template +inline void iterator_advance(InputIt& it, Distance n) +{ // increment iterator by offset, arbitrary iterators + boost::intrusive::detail::advance_impl(it, n, boost::intrusive::iterator_traits::iterator_category()); +} + +namespace detail{ + +template +inline void distance_impl(InputIt first, InputIt last, Distance& off, const Category &) +{ + while(first != last){ + ++off; + ++first; + } +} + +template inline +void distance_impl(InputIt first, InputIt last, Distance& off, const std::random_access_iterator_tag&) +{ + off += last - first; +} + +} //namespace detail + +template inline +typename iterator_traits::difference_type iterator_distance(InputIt first, InputIt last) +{ + typename iterator_traits::difference_type off = 0; + boost::intrusive::detail::distance_impl(first, last, off, boost::intrusive::iterator_traits::iterator_category()); + return off; +} + + +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP diff --git a/include/boost/intrusive/detail/list_iterator.hpp b/include/boost/intrusive/detail/list_iterator.hpp new file mode 100644 index 0000000..6d743dc --- /dev/null +++ b/include/boost/intrusive/detail/list_iterator.hpp @@ -0,0 +1,128 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Olaf Krzikalla 2004-2006. +// (C) Copyright Ion Gaztanaga 2006-2013 +// +// 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_ITERATOR_HPP +#define BOOST_INTRUSIVE_LIST_ITERATOR_HPP + +#include +#include +#include +#include + +namespace boost { +namespace intrusive { + +// list_iterator provides some basic functions for a +// node oriented bidirectional iterator: +template +class list_iterator +{ + protected: + typedef iiterator + types_t; + + static const bool stateful_value_traits = types_t::stateful_value_traits; + + typedef ValueTraits value_traits; + typedef typename types_t::node_traits node_traits; + + typedef typename types_t::node node; + typedef typename types_t::node_ptr node_ptr; + typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; + + public: + typedef typename types_t::iterator_traits::difference_type difference_type; + typedef typename types_t::iterator_traits::value_type value_type; + typedef typename types_t::iterator_traits::pointer pointer; + typedef typename types_t::iterator_traits::reference reference; + typedef typename types_t::iterator_traits::iterator_category iterator_category; + + list_iterator() + {} + + explicit list_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr) + : members_(nodeptr, traits_ptr) + {} + + list_iterator(list_iterator const& other) + : members_(other.pointed_node(), other.get_value_traits()) + {} + + const node_ptr &pointed_node() const + { return members_.nodeptr_; } + + list_iterator &operator=(const node_ptr &node) + { members_.nodeptr_ = node; return static_cast(*this); } + + const_value_traits_ptr get_value_traits() const + { return members_.get_ptr(); } + + public: + list_iterator& operator++() + { + node_ptr p = node_traits::get_next(members_.nodeptr_); + members_.nodeptr_ = p; + return static_cast (*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 (*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->operator_arrow(detail::bool_()); } + + list_iterator unconst() const + { return list_iterator(this->pointed_node(), this->get_value_traits()); } + + private: + pointer operator_arrow(detail::false_) const + { return ValueTraits::to_value_ptr(members_.nodeptr_); } + + pointer operator_arrow(detail::true_) const + { return this->get_value_traits()->to_value_ptr(members_.nodeptr_); } + + iiterator_members members_; +}; + +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_LIST_ITERATOR_HPP diff --git a/include/boost/intrusive/detail/list_node.hpp b/include/boost/intrusive/detail/list_node.hpp index 0967183..cf1fd6e 100644 --- a/include/boost/intrusive/detail/list_node.hpp +++ b/include/boost/intrusive/detail/list_node.hpp @@ -15,10 +15,7 @@ #define BOOST_INTRUSIVE_LIST_NODE_HPP #include -#include -#include -#include -#include +#include namespace boost { namespace intrusive { @@ -30,8 +27,7 @@ namespace intrusive { template struct list_node { - typedef typename pointer_traits - :: template rebind_pointer::type node_ptr; + typedef typename pointer_rebind::type node_ptr; node_ptr next_; node_ptr prev_; }; @@ -39,11 +35,9 @@ struct list_node template struct list_node_traits { - typedef list_node node; - typedef typename pointer_traits - :: template rebind_pointer::type node_ptr; - typedef typename pointer_traits - :: template rebind_pointer::type const_node_ptr; + typedef list_node node; + typedef typename node::node_ptr node_ptr; + typedef typename pointer_rebind::type const_node_ptr; static node_ptr get_previous(const const_node_ptr & n) { return n->prev_; } @@ -64,104 +58,6 @@ struct list_node_traits { n->next_ = next; } }; -// list_iterator provides some basic functions for a -// node oriented bidirectional iterator: -template -class list_iterator -{ - protected: - typedef iiterator - types_t; - - static const bool stateful_value_traits = types_t::stateful_value_traits; - - typedef ValueTraits value_traits; - typedef typename types_t::node_traits node_traits; - - typedef typename types_t::node node; - typedef typename types_t::node_ptr node_ptr; - typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; - - public: - typedef typename types_t::iterator_traits::difference_type difference_type; - typedef typename types_t::iterator_traits::value_type value_type; - typedef typename types_t::iterator_traits::pointer pointer; - typedef typename types_t::iterator_traits::reference reference; - typedef typename types_t::iterator_traits::iterator_category iterator_category; - - list_iterator() - {} - - explicit list_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr) - : members_(nodeptr, traits_ptr) - {} - - list_iterator(list_iterator const& other) - : members_(other.pointed_node(), other.get_value_traits()) - {} - - const node_ptr &pointed_node() const - { return members_.nodeptr_; } - - list_iterator &operator=(const node_ptr &node) - { members_.nodeptr_ = node; return static_cast(*this); } - - const_value_traits_ptr get_value_traits() const - { return members_.get_ptr(); } - - public: - list_iterator& operator++() - { - node_ptr p = node_traits::get_next(members_.nodeptr_); - members_.nodeptr_ = p; - return static_cast (*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 (*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->operator_arrow(detail::bool_()); } - - list_iterator unconst() const - { return list_iterator(this->pointed_node(), this->get_value_traits()); } - - private: - pointer operator_arrow(detail::false_) const - { return ValueTraits::to_value_ptr(members_.nodeptr_); } - - pointer operator_arrow(detail::true_) const - { return this->get_value_traits()->to_value_ptr(members_.nodeptr_); } - - iiterator_members members_; -}; - } //namespace intrusive } //namespace boost diff --git a/include/boost/intrusive/detail/memory_util.hpp b/include/boost/intrusive/detail/memory_util.hpp index 3d78b1a..a321dbf 100644 --- a/include/boost/intrusive/detail/memory_util.hpp +++ b/include/boost/intrusive/detail/memory_util.hpp @@ -42,14 +42,6 @@ inline T* addressof(T& obj) ); } -template struct unvoid { typedef T type; }; -template <> struct unvoid { struct type { }; }; -template <> struct unvoid { struct type { }; }; - -template struct unvoid_ref { typedef T &type; }; -template <> struct unvoid_ref { struct type_impl { }; typedef type_impl & type; }; -template <> struct unvoid_ref { struct type_impl { }; typedef type_impl & type; }; - template struct LowPriorityConversion { @@ -57,59 +49,6 @@ struct LowPriorityConversion LowPriorityConversion(const T&) { } }; -// Infrastructure for providing a default type for T::TNAME if absent. -#define BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(TNAME) \ - template \ - struct boost_intrusive_default_type_ ## TNAME \ - { \ - template \ - static char test(int, typename X::TNAME*); \ - \ - template \ - static int test(...); \ - \ - struct DefaultWrap { typedef DefaultType TNAME; }; \ - \ - static const bool value = (1 == sizeof(test(0, 0))); \ - \ - typedef typename \ - ::boost::intrusive::detail::if_c \ - ::type::TNAME type; \ - }; \ - \ - template \ - struct boost_intrusive_eval_default_type_ ## TNAME \ - { \ - template \ - static char test(int, typename X::TNAME*); \ - \ - template \ - static int test(...); \ - \ - struct DefaultWrap \ - { typedef typename DefaultType::type TNAME; }; \ - \ - static const bool value = (1 == sizeof(test(0, 0))); \ - \ - typedef typename \ - ::boost::intrusive::detail::eval_if_c \ - < value \ - , ::boost::intrusive::detail::identity \ - , ::boost::intrusive::detail::identity \ - >::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 @@ -147,260 +86,6 @@ BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_traits_ptr) -////////////////////// -//struct first_param -////////////////////// - -template struct first_param -{ typedef void type; }; - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template