diff --git a/example/doc_erasing_and_disposing.cpp b/example/doc_erasing_and_disposing.cpp index 7e0d27c..7ac20e8 100644 --- a/example/doc_erasing_and_disposing.cpp +++ b/example/doc_erasing_and_disposing.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -9,7 +9,7 @@ // See http://www.boost.org/libs/intrusive for documentation. // ///////////////////////////////////////////////////////////////////////////// -#include +#include //[doc_erasing_and_disposing #include diff --git a/include/boost/intrusive/avl_set.hpp b/include/boost/intrusive/avl_set.hpp index 0dc1e8d..827e03b 100644 --- a/include/boost/intrusive/avl_set.hpp +++ b/include/boost/intrusive/avl_set.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,6 +17,7 @@ #include #include #include +#include #include namespace boost { diff --git a/include/boost/intrusive/avltree.hpp b/include/boost/intrusive/avltree.hpp index ebe78d3..aa33fd3 100644 --- a/include/boost/intrusive/avltree.hpp +++ b/include/boost/intrusive/avltree.hpp @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/intrusive/avltree_algorithms.hpp b/include/boost/intrusive/avltree_algorithms.hpp index 3c98499..1a08df6 100644 --- a/include/boost/intrusive/avltree_algorithms.hpp +++ b/include/boost/intrusive/avltree_algorithms.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Daniel K. O. 2005. -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -20,10 +20,9 @@ #include #include -#include +#include +#include #include -#include - namespace boost { namespace intrusive { @@ -81,7 +80,8 @@ struct avltree_node_checker (height_diff == 0 && node_traits::get_balance(p) == node_traits::zero()) || (height_diff == 1 && node_traits::get_balance(p) == node_traits::positive()) ); - check_return.height = 1 + std::max(check_return_left.height, check_return_right.height); + check_return.height = 1 + + (check_return_left.height > check_return_right.height ? check_return_left.height : check_return_right.height); base_checker_t::operator()(p, check_return_left, check_return_right, check_return); } }; diff --git a/include/boost/intrusive/bs_set.hpp b/include/boost/intrusive/bs_set.hpp index 0620b9a..9bcf677 100644 --- a/include/boost/intrusive/bs_set.hpp +++ b/include/boost/intrusive/bs_set.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2013-2013 +// (C) Copyright Ion Gaztanaga 2013-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -18,6 +18,7 @@ #include #include #include +#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/bstree.hpp b/include/boost/intrusive/bstree.hpp index 4e3a43b..3b0ecb1 100644 --- a/include/boost/intrusive/bstree.hpp +++ b/include/boost/intrusive/bstree.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2013-2013 +// (C) Copyright Ion Gaztanaga 2013-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -30,6 +29,8 @@ #include #include #include +#include +#include #include #include #include @@ -1456,7 +1457,9 @@ class bstree_impl size_type count(const KeyType &key, KeyValueCompare comp) const { std::pair ret = this->equal_range(key, comp); - return size_type(std::distance(ret.first, ret.second)); + size_type n = 0; + for(; ret.first != ret.second; ++ret.first){ ++n; } + return n; } #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) @@ -1470,7 +1473,9 @@ class bstree_impl size_type count(const KeyType &key, KeyValueCompare comp) { std::pair ret = this->equal_range(key, comp); - return size_type(std::distance(ret.first, ret.second)); + size_type n = 0; + for(; ret.first != ret.second; ++ret.first){ ++n; } + return n; } #else //defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) diff --git a/include/boost/intrusive/bstree_algorithms.hpp b/include/boost/intrusive/bstree_algorithms.hpp index befc232..6eed031 100644 --- a/include/boost/intrusive/bstree_algorithms.hpp +++ b/include/boost/intrusive/bstree_algorithms.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -13,12 +13,15 @@ #ifndef BOOST_INTRUSIVE_BSTREE_ALGORITHMS_HPP #define BOOST_INTRUSIVE_BSTREE_ALGORITHMS_HPP +#include #include #include #include -#include +#include #include -#include +#include +#include +#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/circular_list_algorithms.hpp b/include/boost/intrusive/circular_list_algorithms.hpp index 3253f15..477718e 100644 --- a/include/boost/intrusive/circular_list_algorithms.hpp +++ b/include/boost/intrusive/circular_list_algorithms.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -16,7 +16,8 @@ #include #include -#include +#include +#include #include namespace boost { @@ -401,6 +402,24 @@ class circular_list_algorithms link_after(last, p); } + //! Requires: f and l must be in a circular list. + //! + //! Effects: Returns the number of nodes in the range [f, l). + //! + //! Complexity: Linear + //! + //! Throws: Nothing. + static std::size_t distance(const const_node_ptr &f, const const_node_ptr &l) + { + const_node_ptr i(f); + std::size_t result = 0; + while(i != l){ + i = NodeTraits::get_next(i); + ++result; + } + return result; + } + struct stable_partition_info { std::size_t num_1st_partition; diff --git a/include/boost/intrusive/circular_slist_algorithms.hpp b/include/boost/intrusive/circular_slist_algorithms.hpp index d41dac4..c98d4aa 100644 --- a/include/boost/intrusive/circular_slist_algorithms.hpp +++ b/include/boost/intrusive/circular_slist_algorithms.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -14,12 +14,13 @@ #ifndef BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP #define BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP +#include #include #include #include #include -#include -#include +#include + namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/detail/algo_type.hpp b/include/boost/intrusive/detail/algo_type.hpp new file mode 100644 index 0000000..47e25b4 --- /dev/null +++ b/include/boost/intrusive/detail/algo_type.hpp @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-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_ALGO_TYPE_HPP +#define BOOST_INTRUSIVE_DETAIL_ALGO_TYPE_HPP + +#include + +namespace boost { +namespace intrusive { + +enum algo_types +{ + CircularListAlgorithms, + CircularSListAlgorithms, + LinearSListAlgorithms, + CommonSListAlgorithms, + BsTreeAlgorithms, + RbTreeAlgorithms, + AvlTreeAlgorithms, + SgTreeAlgorithms, + SplayTreeAlgorithms, + TreapAlgorithms +}; + +template +struct get_algo; + +template +struct get_node_checker; + +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_DETAIL_ALGO_TYPE_HPP diff --git a/include/boost/intrusive/detail/any_node_and_algorithms.hpp b/include/boost/intrusive/detail/any_node_and_algorithms.hpp index 455546c..eef537b 100644 --- a/include/boost/intrusive/detail/any_node_and_algorithms.hpp +++ b/include/boost/intrusive/detail/any_node_and_algorithms.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -14,7 +14,6 @@ #define BOOST_INTRUSIVE_ANY_NODE_HPP #include -#include #include #include #include diff --git a/include/boost/intrusive/detail/common_slist_algorithms.hpp b/include/boost/intrusive/detail/common_slist_algorithms.hpp index 316e5a1..969cd39 100644 --- a/include/boost/intrusive/detail/common_slist_algorithms.hpp +++ b/include/boost/intrusive/detail/common_slist_algorithms.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include #include namespace boost { @@ -151,6 +152,24 @@ class common_slist_algorithms info.beg_2st_partition = new_f; info.new_last_node = bcur; } + + //! Requires: f and l must be in a circular list. + //! + //! Effects: Returns the number of nodes in the range [f, l). + //! + //! Complexity: Linear + //! + //! Throws: Nothing. + static std::size_t distance(const const_node_ptr &f, const const_node_ptr &l) + { + const_node_ptr i(f); + std::size_t result = 0; + while(i != l){ + i = NodeTraits::get_next(i); + ++result; + } + return result; + } }; /// @endcond diff --git a/include/boost/intrusive/detail/default_header_holder.hpp b/include/boost/intrusive/detail/default_header_holder.hpp new file mode 100644 index 0000000..35b715a --- /dev/null +++ b/include/boost/intrusive/detail/default_header_holder.hpp @@ -0,0 +1,78 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-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_DEFAULT_HEADER_HOLDER_HPP +#define BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP + +#include +#include + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { +namespace intrusive { +namespace detail { + +// trivial header node holder +template < typename NodeTraits > +struct default_header_holder : public NodeTraits::node +{ + typedef NodeTraits 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; + + default_header_holder() : node() {} + + const_node_ptr get_node() const + { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); } + + node_ptr get_node() + { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); } + + // (unsafe) downcast used to implement container-from-iterator + static default_header_holder* get_holder(const node_ptr &p) + { return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); } +}; + +// type function producing the header node holder +template < typename Value_Traits, typename HeaderHolder > +struct get_header_holder_type +{ + typedef HeaderHolder type; +}; +template < typename Value_Traits > +struct get_header_holder_type< Value_Traits, void > +{ + typedef default_header_holder< typename Value_Traits::node_traits > type; +}; + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP diff --git a/include/boost/intrusive/detail/hashtable_node.hpp b/include/boost/intrusive/detail/hashtable_node.hpp index 40b1f35..ba6e372 100644 --- a/include/boost/intrusive/detail/hashtable_node.hpp +++ b/include/boost/intrusive/detail/hashtable_node.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include //make_slist diff --git a/include/boost/intrusive/detail/math.hpp b/include/boost/intrusive/detail/math.hpp new file mode 100644 index 0000000..e9ffa24 --- /dev/null +++ b/include/boost/intrusive/detail/math.hpp @@ -0,0 +1,271 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-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_MATH_HPP +#define BOOST_INTRUSIVE_DETAIL_MATH_HPP + +#include + +#include +#include + +namespace boost { +namespace intrusive { +namespace detail { + +/////////////////////////// +// floor_log2 Dispatcher +//////////////////////////// + +#if defined(_MSC_VER) && (_MSC_VER >= 1300) + + }}} //namespace boost::intrusive::detail + + //Use _BitScanReverseXX intrinsics + + #if defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64) //64 bit target + #define BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT + #endif + + #ifndef __INTRIN_H_ // Avoid including any windows system header + #ifdef __cplusplus + extern "C" { + #endif // __cplusplus + + #if defined(BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT) //64 bit target + unsigned char _BitScanReverse64(unsigned long *index, unsigned __int64 mask); + #pragma intrinsic(_BitScanReverse64) + #else //32 bit target + unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); + #pragma intrinsic(_BitScanReverse) + #endif + + #ifdef __cplusplus + } + #endif // __cplusplus + #endif // __INTRIN_H_ + + #ifdef BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT + #define BOOST_INTRUSIVE_BSR_INTRINSIC _BitScanReverse64 + #undef BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT + #else + #define BOOST_INTRUSIVE_BSR_INTRINSIC _BitScanReverse + #endif + + namespace boost { + namespace intrusive { + namespace detail { + + inline std::size_t floor_log2 (std::size_t x) + { + unsigned long log2; + BOOST_INTRUSIVE_BSR_INTRINSIC( &log2, (unsigned long)x ); + return log2; + } + + #undef BOOST_INTRUSIVE_BSR_INTRINSIC + +#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) //GCC >=3.4 + + //Compile-time error in case of missing specialization + template + struct builtin_clz_dispatch; + + #if defined(BOOST_HAS_LONG_LONG) + template<> + struct builtin_clz_dispatch + { + static unsigned long long call(unsigned long long n) + { return __builtin_clzll(n); } + }; + #endif + + template<> + struct builtin_clz_dispatch + { + static unsigned long call(unsigned long n) + { return __builtin_clzl(n); } + }; + + template<> + struct builtin_clz_dispatch + { + static unsigned int call(unsigned int n) + { return __builtin_clz(n); } + }; + + inline std::size_t floor_log2(std::size_t n) + { + return sizeof(std::size_t)*CHAR_BIT - std::size_t(1) - builtin_clz_dispatch::call(n); + } + +#else //Portable methods + +//////////////////////////// +// Generic method +//////////////////////////// + + inline std::size_t floor_log2_get_shift(std::size_t n, true_ )//power of two size_t + { return n >> 1; } + + inline std::size_t floor_log2_get_shift(std::size_t n, false_ )//non-power of two size_t + { return (n >> 1) + ((n & 1u) & (n != 1)); } + + template + inline std::size_t floor_log2 (std::size_t x, integer) + { + const std::size_t Bits = N; + const bool Size_t_Bits_Power_2= !(Bits & (Bits-1)); + + std::size_t n = x; + std::size_t log2 = 0; + + std::size_t remaining_bits = Bits; + std::size_t shift = floor_log2_get_shift(remaining_bits, bool_()); + while(shift){ + std::size_t tmp = n >> shift; + if (tmp){ + log2 += shift, n = tmp; + } + shift = floor_log2_get_shift(shift, bool_()); + } + + return log2; + } + + //////////////////////////// + // DeBruijn method + //////////////////////////// + + //Taken from: + //http://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers + //Thanks to Desmond Hume + + inline std::size_t floor_log2 (std::size_t v, integer) + { + static const int MultiplyDeBruijnBitPosition[32] = + { + 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, + 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 + }; + + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + + return MultiplyDeBruijnBitPosition[(std::size_t)(v * 0x07C4ACDDU) >> 27]; + } + + inline std::size_t floor_log2 (std::size_t v, integer) + { + static const std::size_t MultiplyDeBruijnBitPosition[64] = { + 63, 0, 58, 1, 59, 47, 53, 2, + 60, 39, 48, 27, 54, 33, 42, 3, + 61, 51, 37, 40, 49, 18, 28, 20, + 55, 30, 34, 11, 43, 14, 22, 4, + 62, 57, 46, 52, 38, 26, 32, 41, + 50, 36, 17, 19, 29, 10, 13, 21, + 56, 45, 25, 31, 35, 16, 9, 12, + 44, 24, 15, 8, 23, 7, 6, 5}; + + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v |= v >> 32; + return MultiplyDeBruijnBitPosition[((std::size_t)((v - (v >> 1))*0x07EDD5E59A4E28C2ULL)) >> 58]; + } + + + inline std::size_t floor_log2 (std::size_t x) + { + const std::size_t Bits = sizeof(std::size_t)*CHAR_BIT; + return floor_log2(x, integer()); + } + +#endif + +//Thanks to Laurent de Soras in +//http://www.flipcode.com/archives/Fast_log_Function.shtml +inline float fast_log2 (float val) +{ + union caster_t + { + unsigned x; + float val; + } caster; + + caster.val = val; + unsigned x = caster.x; + const int log_2 = int((x >> 23) & 255) - 128; + x &= ~(unsigned(255u) << 23u); + x += unsigned(127) << 23u; + caster.x = x; + val = caster.val; + //1+log2(m), m ranging from 1 to 2 + //3rd degree polynomial keeping first derivate continuity. + //For less precision the line can be commented out + val = ((-1.f/3.f) * val + 2.f) * val - (2.f/3.f); + return val + static_cast(log_2); +} + +inline std::size_t ceil_log2 (std::size_t x) +{ + return static_cast((x & (x-1)) != 0) + floor_log2(x); +} + +template +struct numbits_eq +{ + static const bool value = sizeof(SizeType)*CHAR_BIT == N; +}; + +template +struct sqrt2_pow_max; + +template +struct sqrt2_pow_max >::type> +{ + static const SizeType value = 0xb504f334; + static const std::size_t pow = 31; +}; + +#ifndef BOOST_NO_INT64_T + +template +struct sqrt2_pow_max >::type> +{ + static const SizeType value = 0xb504f333f9de6484ull; + static const std::size_t pow = 63; +}; + +#endif //BOOST_NO_INT64_T + +// 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::value; + const std::size_t pow = (std::size_t)sqrt2_pow_max::pow; + return (value >> (pow - x)) + 1; +} + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_DETAIL_MATH_HPP diff --git a/include/boost/intrusive/detail/memory_util.hpp b/include/boost/intrusive/detail/memory_util.hpp index 49b69cf..fa261db 100644 --- a/include/boost/intrusive/detail/memory_util.hpp +++ b/include/boost/intrusive/detail/memory_util.hpp @@ -6,7 +6,7 @@ // ////////////////////////////////////////////////////////////////////////////// // -// (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) // @@ -25,6 +25,11 @@ #include #include #include +#include + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +# include +#endif namespace boost { namespace intrusive { @@ -57,46 +62,46 @@ struct LowPriorityConversion }; // 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_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) \ diff --git a/include/boost/intrusive/detail/parent_from_member.hpp b/include/boost/intrusive/detail/parent_from_member.hpp index cf9f379..a7f2f57 100644 --- a/include/boost/intrusive/detail/parent_from_member.hpp +++ b/include/boost/intrusive/detail/parent_from_member.hpp @@ -17,7 +17,6 @@ #if defined(BOOST_MSVC) || ((defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && defined(BOOST_INTEL)) #define BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER - #include #include #endif @@ -35,13 +34,13 @@ inline std::ptrdiff_t offset_from_pointer_to_member(const Member Parent::* ptr_t union caster_union { const Member Parent::* ptr_to_member; - boost::int32_t offset; + int offset; } caster; //MSVC ABI can use up to 3 int32 to represent pointer to member data //with virtual base classes, in those cases there is no simple to //obtain the address of the parent. So static assert to avoid runtime errors - BOOST_STATIC_ASSERT( sizeof(caster) == sizeof(boost::int32_t) ); + BOOST_STATIC_ASSERT( sizeof(caster) == sizeof(int) ); caster.ptr_to_member = ptr_to_member; return std::ptrdiff_t(caster.offset); diff --git a/include/boost/intrusive/detail/preprocessor.hpp b/include/boost/intrusive/detail/preprocessor.hpp index 0326dc2..cdbc8a1 100644 --- a/include/boost/intrusive/detail/preprocessor.hpp +++ b/include/boost/intrusive/detail/preprocessor.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2008-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2008-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) // @@ -18,20 +18,12 @@ #include #include -#include -#include -#include -#include #include #include -#include #include #include -#include -#include #include -#include -#include + #define BOOST_INTRUSIVE_MAX_CONSTRUCTOR_PARAMETERS 10 diff --git a/include/boost/intrusive/detail/to_raw_pointer.hpp b/include/boost/intrusive/detail/to_raw_pointer.hpp new file mode 100644 index 0000000..1fc3cb0 --- /dev/null +++ b/include/boost/intrusive/detail/to_raw_pointer.hpp @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-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_TO_RAW_POINTER_HPP +#define BOOST_INTRUSIVE_DETAIL_TO_RAW_POINTER_HPP + +#include +#include + +namespace boost { +namespace intrusive { +namespace detail { + +template +inline T* to_raw_pointer(T* p) +{ return p; } + +template +inline typename boost::intrusive::pointer_traits::element_type* +to_raw_pointer(const Pointer &p) +{ return boost::intrusive::detail::to_raw_pointer(p.operator->()); } + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP diff --git a/include/boost/intrusive/detail/uncast.hpp b/include/boost/intrusive/detail/uncast.hpp new file mode 100644 index 0000000..0a5e9cb --- /dev/null +++ b/include/boost/intrusive/detail/uncast.hpp @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (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_UNCAST_HPP +#define BOOST_INTRUSIVE_DETAIL_UNCAST_HPP + +#include +#include +#include + +namespace boost { +namespace intrusive { +namespace detail { + +template +struct uncast_types +{ + typedef typename pointer_traits::element_type element_type; + typedef typename remove_const::type non_const_type; + typedef typename pointer_traits:: + template rebind_pointer::type non_const_pointer; + typedef pointer_traits non_const_traits; +}; + +template +static typename uncast_types::non_const_pointer + uncast(const ConstNodePtr & ptr) +{ + return uncast_types::non_const_traits::const_cast_from(ptr); +} + +} //namespace detail { +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP diff --git a/include/boost/intrusive/detail/utilities.hpp b/include/boost/intrusive/detail/utilities.hpp index 1f3ad67..64b75b2 100644 --- a/include/boost/intrusive/detail/utilities.hpp +++ b/include/boost/intrusive/detail/utilities.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -22,40 +22,21 @@ #include #include #include -#include -#include +#include +#include +#include + #include -#include #include -#include -#include -#include #include -#include namespace boost { + +template +struct hash; + namespace intrusive { -enum algo_types -{ - CircularListAlgorithms, - CircularSListAlgorithms, - LinearSListAlgorithms, - CommonSListAlgorithms, - BsTreeAlgorithms, - RbTreeAlgorithms, - AvlTreeAlgorithms, - SgTreeAlgorithms, - SplayTreeAlgorithms, - TreapAlgorithms -}; - -template -struct get_algo; - -template -struct get_node_checker; - template struct is_safe_autounlink { @@ -96,15 +77,6 @@ BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, hooktags::is_ba BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook) BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(resizable, resizable) -template -inline T* to_raw_pointer(T* p) -{ return p; } - -template -inline typename boost::intrusive::pointer_traits::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 @@ -394,246 +366,6 @@ template void destructor_impl(Hook &, detail::link_dispatch) {} -/////////////////////////// -// floor_log2 Dispatcher -//////////////////////////// - -#if defined(_MSC_VER) && (_MSC_VER >= 1300) - - }}} //namespace boost::intrusive::detail - - //Use _BitScanReverseXX intrinsics - - #if defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64) //64 bit target - #define BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT - #endif - - #ifndef __INTRIN_H_ // Avoid including any windows system header - #ifdef __cplusplus - extern "C" { - #endif // __cplusplus - - #if defined(BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT) //64 bit target - unsigned char _BitScanReverse64(unsigned long *index, unsigned __int64 mask); - #pragma intrinsic(_BitScanReverse64) - #else //32 bit target - unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); - #pragma intrinsic(_BitScanReverse) - #endif - - #ifdef __cplusplus - } - #endif // __cplusplus - #endif // __INTRIN_H_ - - #ifdef BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT - #define BOOST_INTRUSIVE_BSR_INTRINSIC _BitScanReverse64 - #undef BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT - #else - #define BOOST_INTRUSIVE_BSR_INTRINSIC _BitScanReverse - #endif - - namespace boost { - namespace intrusive { - namespace detail { - - inline std::size_t floor_log2 (std::size_t x) - { - unsigned long log2; - BOOST_INTRUSIVE_BSR_INTRINSIC( &log2, (unsigned long)x ); - return log2; - } - - #undef BOOST_INTRUSIVE_BSR_INTRINSIC - -#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) //GCC >=3.4 - - //Compile-time error in case of missing specialization - template - struct builtin_clz_dispatch; - - #if defined(BOOST_HAS_LONG_LONG) - template<> - struct builtin_clz_dispatch - { - static unsigned long long call(unsigned long long n) - { return __builtin_clzll(n); } - }; - #endif - - template<> - struct builtin_clz_dispatch - { - static unsigned long call(unsigned long n) - { return __builtin_clzl(n); } - }; - - template<> - struct builtin_clz_dispatch - { - static unsigned int call(unsigned int n) - { return __builtin_clz(n); } - }; - - inline std::size_t floor_log2(std::size_t n) - { - return sizeof(std::size_t)*CHAR_BIT - std::size_t(1) - builtin_clz_dispatch::call(n); - } - -#else //Portable methods - -//////////////////////////// -// Generic method -//////////////////////////// - - inline std::size_t floor_log2_get_shift(std::size_t n, true_ )//power of two size_t - { return n >> 1; } - - inline std::size_t floor_log2_get_shift(std::size_t n, false_ )//non-power of two size_t - { return (n >> 1) + ((n & 1u) & (n != 1)); } - - template - inline std::size_t floor_log2 (std::size_t x, integer) - { - const std::size_t Bits = N; - const bool Size_t_Bits_Power_2= !(Bits & (Bits-1)); - - std::size_t n = x; - std::size_t log2 = 0; - - std::size_t remaining_bits = Bits; - std::size_t shift = floor_log2_get_shift(remaining_bits, bool_()); - while(shift){ - std::size_t tmp = n >> shift; - if (tmp){ - log2 += shift, n = tmp; - } - shift = floor_log2_get_shift(shift, bool_()); - } - - return log2; - } - - //////////////////////////// - // DeBruijn method - //////////////////////////// - - //Taken from: - //http://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers - //Thanks to Desmond Hume - - inline std::size_t floor_log2 (std::size_t v, integer) - { - static const int MultiplyDeBruijnBitPosition[32] = - { - 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, - 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 - }; - - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - - return MultiplyDeBruijnBitPosition[(std::size_t)(v * 0x07C4ACDDU) >> 27]; - } - - inline std::size_t floor_log2 (std::size_t v, integer) - { - static const std::size_t MultiplyDeBruijnBitPosition[64] = { - 63, 0, 58, 1, 59, 47, 53, 2, - 60, 39, 48, 27, 54, 33, 42, 3, - 61, 51, 37, 40, 49, 18, 28, 20, - 55, 30, 34, 11, 43, 14, 22, 4, - 62, 57, 46, 52, 38, 26, 32, 41, - 50, 36, 17, 19, 29, 10, 13, 21, - 56, 45, 25, 31, 35, 16, 9, 12, - 44, 24, 15, 8, 23, 7, 6, 5}; - - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - v |= v >> 32; - return MultiplyDeBruijnBitPosition[((std::size_t)((v - (v >> 1))*0x07EDD5E59A4E28C2ULL)) >> 58]; - } - - - inline std::size_t floor_log2 (std::size_t x) - { - const std::size_t Bits = sizeof(std::size_t)*CHAR_BIT; - return floor_log2(x, integer()); - } - -#endif - -//Thanks to Laurent de Soras in -//http://www.flipcode.com/archives/Fast_log_Function.shtml -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 &= ~(boost::uint32_t(255u) << 23u); - x += boost::uint32_t(127) << 23u; - caster.x = x; - val = caster.val; - //1+log2(m), m ranging from 1 to 2 - //3rd degree polynomial keeping first derivate continuity. - //For less precision the line can be commented out - val = ((-1.f/3.f) * val + 2.f) * val - (2.f/3.f); - return val + static_cast(log_2); -} - -inline std::size_t ceil_log2 (std::size_t x) -{ - return static_cast((x & (x-1)) != 0) + floor_log2(x); -} - -template -struct numbits_eq -{ - static const bool value = sizeof(SizeType)*CHAR_BIT == N; -}; - -template -struct sqrt2_pow_max; - -template -struct sqrt2_pow_max >::type> -{ - static const boost::uint32_t value = 0xb504f334; - static const std::size_t pow = 31; -}; - -#ifndef BOOST_NO_INT64_T - -template -struct sqrt2_pow_max >::type> -{ - static const boost::uint64_t value = 0xb504f333f9de6484ull; - static const std::size_t pow = 63; -}; - -#endif //BOOST_NO_INT64_T - -// 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::value; - const std::size_t pow = (std::size_t)sqrt2_pow_max::pow; - return (value >> (pow - x)) + 1; -} - template class exception_disposer { @@ -797,57 +529,6 @@ class array_initializer private: detail::max_align rawbuf[(N*sizeof(T)-1)/sizeof(detail::max_align)+1]; }; - -template -struct uncast_types -{ - typedef typename pointer_traits::element_type element_type; - typedef typename remove_const::type non_const_type; - typedef typename pointer_traits:: - template rebind_pointer::type non_const_pointer; - typedef pointer_traits non_const_traits; -}; - -template -static typename uncast_types::non_const_pointer - uncast(const ConstNodePtr & ptr) -{ - return uncast_types::non_const_traits::const_cast_from(ptr); -} - -// trivial header node holder -template < typename NodeTraits > -struct default_header_holder : public NodeTraits::node -{ - typedef NodeTraits 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; - - default_header_holder() : node() {} - - const_node_ptr get_node() const - { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); } - - node_ptr get_node() - { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); } - - // (unsafe) downcast used to implement container-from-iterator - static default_header_holder* get_holder(const node_ptr &p) - { return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); } -}; - -// type function producing the header node holder -template < typename Value_Traits, typename HeaderHolder > -struct get_header_holder_type -{ - typedef HeaderHolder type; -}; -template < typename Value_Traits > -struct get_header_holder_type< Value_Traits, void > -{ - typedef default_header_holder< typename Value_Traits::node_traits > type; -}; } //namespace detail diff --git a/include/boost/intrusive/hashtable.hpp b/include/boost/intrusive/hashtable.hpp index 872e572..b51eb7a 100644 --- a/include/boost/intrusive/hashtable.hpp +++ b/include/boost/intrusive/hashtable.hpp @@ -3000,7 +3000,9 @@ class hashtable_impl to_return.second = bucket_type::s_iterator_to (*node_traits::get_next(group_functions_t::get_last_in_group (detail::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); - cnt = std::distance(it, to_return.second); + + cnt = 0; + for(; it != to_return.second; ++it){ ++cnt; } if(to_return.second != b.end()){ bucket_number_second = bucket_number_first; return to_return; diff --git a/include/boost/intrusive/linear_slist_algorithms.hpp b/include/boost/intrusive/linear_slist_algorithms.hpp index 86f9bb3..ca04917 100644 --- a/include/boost/intrusive/linear_slist_algorithms.hpp +++ b/include/boost/intrusive/linear_slist_algorithms.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/boost/intrusive/list.hpp b/include/boost/intrusive/list.hpp index 2a0bae5..ca6b844 100644 --- a/include/boost/intrusive/list.hpp +++ b/include/boost/intrusive/list.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -26,7 +26,9 @@ #include #include #include -#include +#include +#include +#include #include #include #include @@ -597,9 +599,9 @@ class list_impl //! //! Note: Invalidates the iterators (but not the references) to the //! erased elements. - iterator erase(const_iterator b, const_iterator e, difference_type n) + iterator erase(const_iterator b, const_iterator e, size_type n) { - BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(b, e) == difference_type(n)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance(b.pointed_node(), e.pointed_node()) == n); if(safemode_or_autounlink || constant_time_size){ return this->erase_and_dispose(b, e, detail::null_disposer()); } @@ -891,7 +893,7 @@ class list_impl void splice(const_iterator p, list_impl&x, const_iterator f, const_iterator e) { if(constant_time_size) - this->splice(p, x, f, e, std::distance(f, e)); + this->splice(p, x, f, e, node_algorithms::distance(f.pointed_node(), e.pointed_node())); else this->splice(p, x, f, e, 1);//distance is a dummy value } @@ -909,11 +911,11 @@ class list_impl //! //! Note: 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 f, const_iterator e, difference_type n) + void splice(const_iterator p, list_impl&x, const_iterator f, const_iterator e, size_type n) { if(n){ if(constant_time_size){ - BOOST_INTRUSIVE_INVARIANT_ASSERT(n == std::distance(f, e)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(n == node_algorithms::distance(f.pointed_node(), e.pointed_node())); node_algorithms::transfer(p.pointed_node(), f.pointed_node(), e.pointed_node()); size_traits &thist = this->priv_size_traits(); size_traits &xt = x.priv_size_traits(); diff --git a/include/boost/intrusive/rbtree.hpp b/include/boost/intrusive/rbtree.hpp index 97bae9a..bac1398 100644 --- a/include/boost/intrusive/rbtree.hpp +++ b/include/boost/intrusive/rbtree.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/intrusive/rbtree_algorithms.hpp b/include/boost/intrusive/rbtree_algorithms.hpp index 2c7529e..811c439 100644 --- a/include/boost/intrusive/rbtree_algorithms.hpp +++ b/include/boost/intrusive/rbtree_algorithms.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013. +// (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 @@ -29,9 +29,9 @@ #include #include -#include +#include #include -#include +#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/set.hpp b/include/boost/intrusive/set.hpp index 7d89cd9..09d325f 100644 --- a/include/boost/intrusive/set.hpp +++ b/include/boost/intrusive/set.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -18,8 +18,10 @@ #include #include -#include #include +#include + +#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/sg_set.hpp b/include/boost/intrusive/sg_set.hpp index 46fba04..83fd8b2 100644 --- a/include/boost/intrusive/sg_set.hpp +++ b/include/boost/intrusive/sg_set.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,9 +16,12 @@ #include #include #include -#include +#include #include +#include + + namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/sgtree.hpp b/include/boost/intrusive/sgtree.hpp index e0e9807..ae15e7e 100644 --- a/include/boost/intrusive/sgtree.hpp +++ b/include/boost/intrusive/sgtree.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -32,10 +32,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include diff --git a/include/boost/intrusive/sgtree_algorithms.hpp b/include/boost/intrusive/sgtree_algorithms.hpp index 4a36949..fd39495 100644 --- a/include/boost/intrusive/sgtree_algorithms.hpp +++ b/include/boost/intrusive/sgtree_algorithms.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -22,9 +22,9 @@ #include #include -#include +#include #include -#include + namespace boost { diff --git a/include/boost/intrusive/slist.hpp b/include/boost/intrusive/slist.hpp index df98047..14cbfe2 100644 --- a/include/boost/intrusive/slist.hpp +++ b/include/boost/intrusive/slist.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -25,8 +25,9 @@ #include #include #include +#include +#include #include -#include #include #include #include //std::size_t @@ -900,7 +901,7 @@ class slist_impl //! erased element. iterator erase_after(const_iterator before_f, const_iterator l, size_type n) { - BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(++const_iterator(before_f), l) == difference_type(n)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance((++const_iterator(before_f)).pointed_node(), l.pointed_node()) == n); if(safemode_or_autounlink){ return this->erase_after(before_f, l); } @@ -1234,7 +1235,7 @@ class slist_impl void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_f, const_iterator before_l) { if(constant_time_size) - this->splice_after(prev_pos, x, before_f, before_l, std::distance(before_f, before_l)); + this->splice_after(prev_pos, x, before_f, before_l, node_algorithms::distance(before_f.pointed_node(), before_l.pointed_node())); else this->priv_splice_after (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node()); @@ -1256,7 +1257,7 @@ class slist_impl //! 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_f, const_iterator before_l, size_type n) { - BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(before_f, before_l) == difference_type(n)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance(before_f.pointed_node(), before_l.pointed_node()) == n); this->priv_splice_after (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node()); if(constant_time_size){ @@ -1799,7 +1800,7 @@ class slist_impl void incorporate_after(const_iterator prev_pos, const node_ptr & f, const node_ptr & before_l) { if(constant_time_size) - this->incorporate_after(prev_pos, f, before_l, std::distance(f, before_l)+1); + this->incorporate_after(prev_pos, f, before_l, node_algorithms::distance(f.pointed_node(), before_l.pointed_node())+1); else this->priv_incorporate_after(prev_pos.pointed_node(), f, before_l); } diff --git a/include/boost/intrusive/splay_set.hpp b/include/boost/intrusive/splay_set.hpp index 2df3f95..8c3e00c 100644 --- a/include/boost/intrusive/splay_set.hpp +++ b/include/boost/intrusive/splay_set.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,6 +17,8 @@ #include #include #include +#include + #include namespace boost { diff --git a/include/boost/intrusive/splaytree.hpp b/include/boost/intrusive/splaytree.hpp index 7856b8b..1bee40e 100644 --- a/include/boost/intrusive/splaytree.hpp +++ b/include/boost/intrusive/splaytree.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/intrusive/splaytree_algorithms.hpp b/include/boost/intrusive/splaytree_algorithms.hpp index 925628b..187e723 100644 --- a/include/boost/intrusive/splaytree_algorithms.hpp +++ b/include/boost/intrusive/splaytree_algorithms.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -33,9 +33,9 @@ #include #include #include -#include #include -#include +#include +#include #include namespace boost { diff --git a/include/boost/intrusive/treap_algorithms.hpp b/include/boost/intrusive/treap_algorithms.hpp index 2c8f8e4..e0d9dfb 100644 --- a/include/boost/intrusive/treap_algorithms.hpp +++ b/include/boost/intrusive/treap_algorithms.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2013. +// (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 @@ -19,8 +19,7 @@ #include #include -#include -#include +#include #include #include diff --git a/include/boost/intrusive/treap_set.hpp b/include/boost/intrusive/treap_set.hpp index 8514441..fd9e17e 100644 --- a/include/boost/intrusive/treap_set.hpp +++ b/include/boost/intrusive/treap_set.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013 +// (C) Copyright Ion Gaztanaga 2007-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,6 +17,8 @@ #include #include #include +#include + #include namespace boost { diff --git a/include/boost/intrusive/unordered_set.hpp b/include/boost/intrusive/unordered_set.hpp index abb74eb..1c85f10 100644 --- a/include/boost/intrusive/unordered_set.hpp +++ b/include/boost/intrusive/unordered_set.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 +// (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 @@ -17,6 +17,8 @@ #include #include #include +#include + #include diff --git a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj index cee9f49..c754c89 100644 --- a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj +++ b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj @@ -226,6 +226,9 @@ + + @@ -241,6 +244,9 @@ + + @@ -265,6 +271,9 @@ + + @@ -283,12 +292,18 @@ + + + +