stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
enum algo_types
|
||||
{
|
||||
CircularListAlgorithms,
|
||||
CircularSListAlgorithms,
|
||||
LinearSListAlgorithms,
|
||||
CommonSListAlgorithms,
|
||||
BsTreeAlgorithms,
|
||||
RbTreeAlgorithms,
|
||||
AvlTreeAlgorithms,
|
||||
SgTreeAlgorithms,
|
||||
SplayTreeAlgorithms,
|
||||
TreapAlgorithms,
|
||||
UnorderedAlgorithms,
|
||||
UnorderedCircularSlistAlgorithms,
|
||||
AnyAlgorithm
|
||||
};
|
||||
|
||||
template<algo_types AlgoType, class NodeTraits>
|
||||
struct get_algo;
|
||||
|
||||
template<algo_types AlgoType, class ValueTraits, class NodePtrCompare, class ExtraChecker>
|
||||
struct get_node_checker;
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_ALGO_TYPE_HPP
|
||||
@@ -0,0 +1,90 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_ALGORITHM_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
struct algo_pred_equal
|
||||
{
|
||||
template<class T>
|
||||
bool operator()(const T &x, const T &y) const
|
||||
{ return x == y; }
|
||||
};
|
||||
|
||||
struct algo_pred_less
|
||||
{
|
||||
template<class T>
|
||||
bool operator()(const T &x, const T &y) const
|
||||
{ return x < y; }
|
||||
};
|
||||
|
||||
template<class InputIt1, class InputIt2, class BinaryPredicate>
|
||||
bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p)
|
||||
{
|
||||
for (; first1 != last1; ++first1, ++first2) {
|
||||
if (!p(*first1, *first2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class InputIt1, class InputIt2>
|
||||
bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
|
||||
{ return (algo_equal)(first1, last1, first2, algo_pred_equal()); }
|
||||
|
||||
template<class InputIt1, class InputIt2, class BinaryPredicate>
|
||||
bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate pred)
|
||||
{
|
||||
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
||||
if (!pred(*first1, *first2))
|
||||
return false;
|
||||
return first1 == last1 && first2 == last2;
|
||||
}
|
||||
|
||||
template<class InputIt1, class InputIt2>
|
||||
bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
|
||||
{ return (algo_equal)(first1, last1, first2, last2, algo_pred_equal()); }
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||
bool algo_lexicographical_compare (InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
BinaryPredicate pred)
|
||||
{
|
||||
while (first1 != last1){
|
||||
if (first2 == last2 || *first2 < *first1) return false;
|
||||
else if (pred(*first1, *first2)) return true;
|
||||
++first1; ++first2;
|
||||
}
|
||||
return (first2 != last2);
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
bool algo_lexicographical_compare (InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2)
|
||||
{ return (algo_lexicographical_compare)(first1, last1, first2, last2, algo_pred_less()); }
|
||||
|
||||
} //namespace intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
#endif //#ifndef BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP
|
||||
+297
@@ -0,0 +1,297 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_ANY_NODE_HPP
|
||||
#define BOOST_INTRUSIVE_ANY_NODE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_rebind.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/algo_type.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class VoidPointer>
|
||||
struct any_node
|
||||
{
|
||||
typedef any_node node;
|
||||
typedef typename pointer_rebind<VoidPointer, node>::type node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const node>::type const_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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const const_node_ptr & n)
|
||||
{ return n->node_ptr_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_next(const node_ptr & n, const node_ptr & next)
|
||||
{ n->node_ptr_1 = next; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_previous(const const_node_ptr & n)
|
||||
{ return n->node_ptr_2; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const const_node_ptr & n)
|
||||
{ return n->node_ptr_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const const_node_ptr & n)
|
||||
{ return n->node_ptr_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_next(const node_ptr & n, const node_ptr & next)
|
||||
{ n->node_ptr_1 = next; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_prev_in_group(const const_node_ptr & n)
|
||||
{ return n->node_ptr_2; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_prev_in_group(const node_ptr & n, const node_ptr & prev)
|
||||
{ n->node_ptr_2 = prev; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static std::size_t get_hash(const const_node_ptr & n)
|
||||
{ return n->size_t_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
typedef std::size_t color;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return n->node_ptr_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ n->node_ptr_1 = p; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->node_ptr_2; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->node_ptr_2 = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->node_ptr_3; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
|
||||
{ n->node_ptr_3 = r; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color get_color(const const_node_ptr & n)
|
||||
{ return n->size_t_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_color(const node_ptr & n, color c)
|
||||
{ n->size_t_1 = c; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color black()
|
||||
{ return 0u; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color red()
|
||||
{ return 1u; }
|
||||
};
|
||||
|
||||
|
||||
template<class VoidPointer>
|
||||
struct any_avltree_node_traits
|
||||
{
|
||||
typedef any_node<VoidPointer> node;
|
||||
typedef typename node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
typedef std::size_t balance;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return n->node_ptr_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ n->node_ptr_1 = p; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->node_ptr_2; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->node_ptr_2 = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->node_ptr_3; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
|
||||
{ n->node_ptr_3 = r; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance get_balance(const const_node_ptr & n)
|
||||
{ return n->size_t_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_balance(const node_ptr & n, balance b)
|
||||
{ n->size_t_1 = b; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance negative()
|
||||
{ return 0u; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance zero()
|
||||
{ return 1u; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance positive()
|
||||
{ return 2u; }
|
||||
};
|
||||
|
||||
|
||||
template<class VoidPointer>
|
||||
struct any_tree_node_traits
|
||||
{
|
||||
typedef any_node<VoidPointer> node;
|
||||
typedef typename node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return n->node_ptr_1; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ n->node_ptr_1 = p; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->node_ptr_2; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->node_ptr_2 = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->node_ptr_3; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr 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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr 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.
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void init(const node_ptr & node)
|
||||
{ node->node_ptr_1 = 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.
|
||||
BOOST_INTRUSIVE_FORCEINLINE static bool inited(const const_node_ptr & node)
|
||||
{ return !node->node_ptr_1; };
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static bool unique(const const_node_ptr & node)
|
||||
{ return !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 &, const node_ptr &)
|
||||
{
|
||||
//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>();
|
||||
}
|
||||
};
|
||||
|
||||
///@cond
|
||||
|
||||
template<class NodeTraits>
|
||||
struct get_algo<AnyAlgorithm, NodeTraits>
|
||||
{
|
||||
typedef typename pointer_rebind<typename NodeTraits::node_ptr, void>::type void_pointer;
|
||||
typedef any_algorithms<void_pointer> type;
|
||||
};
|
||||
|
||||
///@endcond
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_ANY_NODE_HPP
|
||||
@@ -0,0 +1,95 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_ARRAY_INITIALIZER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_ARRAY_INITIALIZER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
//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
|
||||
::boost::long_long_type 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;
|
||||
BOOST_TRY{
|
||||
for(; i != N; ++i){
|
||||
new(init_buf)T(init);
|
||||
init_buf += sizeof(T);
|
||||
}
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
while(i--){
|
||||
init_buf -= sizeof(T);
|
||||
((T*)init_buf)->~T();
|
||||
}
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
|
||||
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];
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_ARRAY_INITIALIZER_HPP
|
||||
@@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_DETAIL_ASSERT_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_ASSERT_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#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
|
||||
@@ -0,0 +1,193 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-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_AVLTREE_NODE_HPP
|
||||
#define BOOST_INTRUSIVE_AVLTREE_NODE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_rebind.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_rebind<VoidPointer, compact_avltree_node<VoidPointer> >::type node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const compact_avltree_node<VoidPointer> >::type const_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_rebind<VoidPointer, avltree_node<VoidPointer> >::type node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const avltree_node<VoidPointer> >::type const_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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
typedef typename node::balance balance;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return n->parent_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const node_ptr & n)
|
||||
{ return n->parent_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ n->parent_ = p; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->left_ = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
|
||||
{ n->right_ = r; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance get_balance(const const_node_ptr & n)
|
||||
{ return n->balance_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance get_balance(const node_ptr & n)
|
||||
{ return n->balance_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_balance(const node_ptr & n, balance b)
|
||||
{ n->balance_ = b; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance negative()
|
||||
{ return node::negative_t; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance zero()
|
||||
{ return node::zero_t; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
typedef typename node::balance balance;
|
||||
|
||||
typedef pointer_plus_bits<node_ptr, 2> ptr_bit;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return ptr_bit::get_pointer(n->parent_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ ptr_bit::set_pointer(n->parent_, p); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->left_ = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
|
||||
{ n->right_ = r; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance get_balance(const const_node_ptr & n)
|
||||
{ return (balance)ptr_bit::get_bits(n->parent_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_balance(const node_ptr & n, balance b)
|
||||
{ ptr_bit::set_bits(n->parent_, (std::size_t)b); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance negative()
|
||||
{ return node::negative_t; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static balance zero()
|
||||
{ return node::zero_t; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 rbtree_node_traits_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
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_BSTREE_ALGORITHMS_BASE_HPP
|
||||
#define BOOST_INTRUSIVE_BSTREE_ALGORITHMS_BASE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/uncast.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class NodeTraits>
|
||||
class bstree_algorithms_base
|
||||
{
|
||||
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;
|
||||
|
||||
//! <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 const n_right(NodeTraits::get_right(node));
|
||||
if(n_right){
|
||||
return minimum(n_right);
|
||||
}
|
||||
else {
|
||||
node_ptr n(node);
|
||||
node_ptr p(NodeTraits::get_parent(n));
|
||||
while(n == NodeTraits::get_right(p)){
|
||||
n = p;
|
||||
p = NodeTraits::get_parent(p);
|
||||
}
|
||||
return NodeTraits::get_right(n) != p ? p : n;
|
||||
}
|
||||
}
|
||||
|
||||
//! <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(node_ptr node)
|
||||
{
|
||||
for(node_ptr p_left = NodeTraits::get_left(node)
|
||||
;p_left
|
||||
;p_left = NodeTraits::get_left(node)){
|
||||
node = p_left;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
//! <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(node_ptr node)
|
||||
{
|
||||
for(node_ptr p_right = NodeTraits::get_right(node)
|
||||
;p_right
|
||||
;p_right = NodeTraits::get_right(node)){
|
||||
node = p_right;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
//! <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)
|
||||
{
|
||||
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>: 'node' is a node of the tree or a header node.
|
||||
//!
|
||||
//! <b>Effects</b>: Returns the header of the tree.
|
||||
//!
|
||||
//! <b>Complexity</b>: Logarithmic.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
static node_ptr get_header(const const_node_ptr & node)
|
||||
{
|
||||
node_ptr n(detail::uncast(node));
|
||||
node_ptr p(NodeTraits::get_parent(node));
|
||||
//If p is null, then n is the header of an empty tree
|
||||
if(p){
|
||||
//Non-empty tree, check if n is neither root nor header
|
||||
node_ptr pp(NodeTraits::get_parent(p));
|
||||
//If granparent is not equal to n, then n is neither root nor header,
|
||||
//the try the fast path
|
||||
if(n != pp){
|
||||
do{
|
||||
n = p;
|
||||
p = pp;
|
||||
pp = NodeTraits::get_parent(pp);
|
||||
}while(n != pp);
|
||||
n = p;
|
||||
}
|
||||
//Check if n is root or header when size() > 0
|
||||
else if(!bstree_algorithms_base::is_header(n)){
|
||||
n = p;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_BSTREE_ALGORITHMS_BASE_HPP
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
// 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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/intrusive_fwd.hpp>
|
||||
#include <boost/intrusive/detail/assert.hpp>
|
||||
#include <boost/intrusive/detail/algo_type.hpp>
|
||||
#include <boost/core/no_exceptions_support.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(node_ptr p, const node_ptr & this_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 circular lists
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(p);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void init(const node_ptr & this_node)
|
||||
{ NodeTraits::set_next(this_node, node_ptr()); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static bool unique(const const_node_ptr & this_node)
|
||||
{
|
||||
node_ptr next = NodeTraits::get_next(this_node);
|
||||
return !next || next == this_node;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static bool inited(const const_node_ptr & this_node)
|
||||
{ return !NodeTraits::get_next(this_node); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void unlink_after(const node_ptr & prev_node, const node_ptr & last_node)
|
||||
{ NodeTraits::set_next(prev_node, last_node); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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);
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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);
|
||||
}
|
||||
}
|
||||
|
||||
struct stable_partition_info
|
||||
{
|
||||
std::size_t num_1st_partition;
|
||||
std::size_t num_2nd_partition;
|
||||
node_ptr beg_2st_partition;
|
||||
node_ptr new_last_node;
|
||||
};
|
||||
|
||||
template<class Pred>
|
||||
static void stable_partition(node_ptr before_beg, const node_ptr &end, Pred pred, stable_partition_info &info)
|
||||
{
|
||||
node_ptr bcur = before_beg;
|
||||
node_ptr cur = node_traits::get_next(bcur);
|
||||
node_ptr new_f = end;
|
||||
|
||||
std::size_t num1 = 0, num2 = 0;
|
||||
while(cur != end){
|
||||
if(pred(cur)){
|
||||
++num1;
|
||||
bcur = cur;
|
||||
cur = node_traits::get_next(cur);
|
||||
}
|
||||
else{
|
||||
++num2;
|
||||
node_ptr last_to_remove = bcur;
|
||||
new_f = cur;
|
||||
bcur = cur;
|
||||
cur = node_traits::get_next(cur);
|
||||
BOOST_TRY{
|
||||
//Main loop
|
||||
while(cur != end){
|
||||
if(pred(cur)){ //Might throw
|
||||
++num1;
|
||||
//Process current node
|
||||
node_traits::set_next(last_to_remove, cur);
|
||||
last_to_remove = cur;
|
||||
node_ptr nxt = node_traits::get_next(cur);
|
||||
node_traits::set_next(bcur, nxt);
|
||||
cur = nxt;
|
||||
}
|
||||
else{
|
||||
++num2;
|
||||
bcur = cur;
|
||||
cur = node_traits::get_next(cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
node_traits::set_next(last_to_remove, new_f);
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
node_traits::set_next(last_to_remove, new_f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
info.num_1st_partition = num1;
|
||||
info.num_2nd_partition = num2;
|
||||
info.beg_2st_partition = new_f;
|
||||
info.new_last_node = bcur;
|
||||
}
|
||||
|
||||
//! <b>Requires</b>: f and l must be in a circular list.
|
||||
//!
|
||||
//! <b>Effects</b>: Returns the number of nodes in the range [f, l).
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear
|
||||
//!
|
||||
//! <b>Throws</b>: 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
|
||||
|
||||
} //namespace detail
|
||||
|
||||
/// @cond
|
||||
|
||||
template<class NodeTraits>
|
||||
struct get_algo<CommonSListAlgorithms, NodeTraits>
|
||||
{
|
||||
typedef detail::common_slist_algorithms<NodeTraits> type;
|
||||
};
|
||||
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP
|
||||
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_CONFIG_HPP
|
||||
#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 : 4127) //conditional expression is constant
|
||||
#pragma warning (disable : 4146)
|
||||
#pragma warning (disable : 4267) //conversion from 'X' to 'Y', possible loss of data
|
||||
#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-
|
||||
#pragma warning (disable : 4522)
|
||||
#pragma warning (disable : 4706) //assignment within conditional expression
|
||||
#pragma warning (disable : 4710) // function not inlined
|
||||
#pragma warning (disable : 4714) // "function": marked as __forceinline 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
|
||||
#endif
|
||||
|
||||
//#define BOOST_INTRUSIVE_USE_ITERATOR_FACADE
|
||||
//#define BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
|
||||
@@ -0,0 +1,15 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined BOOST_MSVC
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/detail/to_raw_pointer.hpp>
|
||||
|
||||
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() {}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const_node_ptr get_node() const
|
||||
{ return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE node_ptr get_node()
|
||||
{ return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); }
|
||||
|
||||
// (unsafe) downcast used to implement container-from-iterator
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 ValueTraits, typename HeaderHolder >
|
||||
struct get_header_holder_type
|
||||
{
|
||||
typedef HeaderHolder type;
|
||||
};
|
||||
template < typename ValueTraits >
|
||||
struct get_header_holder_type< ValueTraits, void >
|
||||
{
|
||||
typedef default_header_holder< typename ValueTraits::node_traits > type;
|
||||
};
|
||||
|
||||
} //namespace detail
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP
|
||||
@@ -0,0 +1,292 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Joaquin M Lopez Munoz 2006-2013
|
||||
// (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_EBO_HOLDER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
#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) && !defined(_M_ARM) && !defined(UNDER_CE)
|
||||
#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; };
|
||||
|
||||
#ifndef _MANAGED
|
||||
|
||||
template <typename R>
|
||||
struct is_unary_or_binary_function_impl<R (__fastcall*)()>
|
||||
{ static const bool value = true; };
|
||||
|
||||
#endif
|
||||
|
||||
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; };
|
||||
|
||||
#ifndef _MANAGED
|
||||
|
||||
template <typename R, class T0>
|
||||
struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)>
|
||||
{ static const bool value = true; };
|
||||
|
||||
#endif
|
||||
|
||||
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; };
|
||||
|
||||
#ifndef _MANAGED
|
||||
|
||||
template <typename R, class T0, class T1>
|
||||
struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)>
|
||||
{ static const bool value = true; };
|
||||
|
||||
#endif
|
||||
|
||||
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 : is_unary_or_binary_function_impl<T>
|
||||
{};
|
||||
|
||||
template<typename T, bool = is_unary_or_binary_function<T>::value>
|
||||
class ebo_functor_holder
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder)
|
||||
|
||||
public:
|
||||
typedef T functor_type;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder()
|
||||
: t_()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(const T &t)
|
||||
: t_(t)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(BOOST_RV_REF(T) t)
|
||||
: t_(::boost::move(t))
|
||||
{}
|
||||
|
||||
template<class Arg1, class Arg2>
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2)
|
||||
: t_(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2))
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(const ebo_functor_holder &x)
|
||||
: t_(x.t_)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x)
|
||||
: t_(x.t_)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x)
|
||||
{
|
||||
this->get() = x.get();
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x)
|
||||
{
|
||||
this->get() = ::boost::move(x.get());
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(const T &x)
|
||||
{
|
||||
this->get() = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(T) x)
|
||||
{
|
||||
this->get() = ::boost::move(x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE T& get(){return t_;}
|
||||
BOOST_INTRUSIVE_FORCEINLINE const T& get()const{return t_;}
|
||||
|
||||
private:
|
||||
T t_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ebo_functor_holder<T, false>
|
||||
: public T
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder)
|
||||
|
||||
public:
|
||||
typedef T functor_type;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder()
|
||||
: T()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(const T &t)
|
||||
: T(t)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(BOOST_RV_REF(T) t)
|
||||
: T(::boost::move(t))
|
||||
{}
|
||||
|
||||
template<class Arg1, class Arg2>
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2)
|
||||
: T(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2))
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(const ebo_functor_holder &x)
|
||||
: T(static_cast<const T&>(x))
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x)
|
||||
: T(BOOST_MOVE_BASE(T, x))
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x)
|
||||
{
|
||||
const ebo_functor_holder&r = x;
|
||||
this->get() = r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x)
|
||||
{
|
||||
this->get() = ::boost::move(x.get());
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(const T &x)
|
||||
{
|
||||
this->get() = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(T) x)
|
||||
{
|
||||
this->get() = ::boost::move(x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE T& get(){return *this;}
|
||||
BOOST_INTRUSIVE_FORCEINLINE const T& get()const{return *this;}
|
||||
};
|
||||
|
||||
} //namespace detail {
|
||||
} //namespace intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
#endif //#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
|
||||
@@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_EMPTY_NODE_CHECKER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_EMPTY_NODE_CHECKER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template<class ValueTraits>
|
||||
struct empty_node_checker
|
||||
{
|
||||
typedef ValueTraits value_traits;
|
||||
typedef typename value_traits::node_traits node_traits;
|
||||
typedef typename node_traits::const_node_ptr const_node_ptr;
|
||||
|
||||
struct return_type {};
|
||||
|
||||
void operator () (const const_node_ptr&, const return_type&, const return_type&, return_type&) {}
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_EMPTY_NODE_CHECKER_HPP
|
||||
@@ -0,0 +1,50 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_EQUAL_TO_VALUE_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_EQUAL_TO_VALUE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
//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)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(ConstReference t)const
|
||||
{ return t_ == t; }
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_EQUAL_TO_VALUE_HPP
|
||||
@@ -0,0 +1,90 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_EXCEPTION_DISPOSER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
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)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void release()
|
||||
{ cont_ = 0; }
|
||||
|
||||
~exception_array_disposer()
|
||||
{
|
||||
SizeType n = constructed_;
|
||||
if(cont_){
|
||||
while(n--){
|
||||
cont_[n].clear_and_dispose(disp_);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP
|
||||
@@ -0,0 +1,92 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2009-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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
#endif //@ifndef BOOST_INTRUSIVE_DETAIL_FUNCTION_DETECTOR_HPP
|
||||
@@ -0,0 +1,223 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-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_GENERIC_HOOK_HPP
|
||||
#define BOOST_INTRUSIVE_GENERIC_HOOK_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/link_mode.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/assert.hpp>
|
||||
#include <boost/intrusive/detail/node_holder.hpp>
|
||||
#include <boost/intrusive/detail/algo_type.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
/// @cond
|
||||
|
||||
namespace detail {
|
||||
|
||||
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>)
|
||||
{}
|
||||
|
||||
} //namespace detail {
|
||||
|
||||
enum base_hook_type
|
||||
{ NoBaseHookId
|
||||
, ListBaseHookId
|
||||
, SlistBaseHookId
|
||||
, RbTreeBaseHookId
|
||||
, HashBaseHookId
|
||||
, AvlTreeBaseHookId
|
||||
, BsTreeBaseHookId
|
||||
, TreapTreeBaseHookId
|
||||
, AnyBaseHookId
|
||||
};
|
||||
|
||||
|
||||
template <class HookTags, unsigned int>
|
||||
struct hook_tags_definer{};
|
||||
|
||||
template <class HookTags>
|
||||
struct hook_tags_definer<HookTags, ListBaseHookId>
|
||||
{ typedef HookTags default_list_hook; };
|
||||
|
||||
template <class HookTags>
|
||||
struct hook_tags_definer<HookTags, SlistBaseHookId>
|
||||
{ typedef HookTags default_slist_hook; };
|
||||
|
||||
template <class HookTags>
|
||||
struct hook_tags_definer<HookTags, RbTreeBaseHookId>
|
||||
{ typedef HookTags default_rbtree_hook; };
|
||||
|
||||
template <class HookTags>
|
||||
struct hook_tags_definer<HookTags, HashBaseHookId>
|
||||
{ typedef HookTags default_hashtable_hook; };
|
||||
|
||||
template <class HookTags>
|
||||
struct hook_tags_definer<HookTags, AvlTreeBaseHookId>
|
||||
{ typedef HookTags default_avltree_hook; };
|
||||
|
||||
template <class HookTags>
|
||||
struct hook_tags_definer<HookTags, BsTreeBaseHookId>
|
||||
{ typedef HookTags default_bstree_hook; };
|
||||
|
||||
template <class HookTags>
|
||||
struct hook_tags_definer<HookTags, AnyBaseHookId>
|
||||
{ typedef HookTags default_any_hook; };
|
||||
|
||||
template
|
||||
< class NodeTraits
|
||||
, class Tag
|
||||
, link_mode_type LinkMode
|
||||
, base_hook_type BaseHookType
|
||||
>
|
||||
struct hooktags_impl
|
||||
{
|
||||
static const link_mode_type link_mode = LinkMode;
|
||||
typedef Tag tag;
|
||||
typedef NodeTraits node_traits;
|
||||
static const bool is_base_hook = !detail::is_same<Tag, member_tag>::value;
|
||||
static const bool safemode_or_autounlink = is_safe_autounlink<link_mode>::value;
|
||||
static const unsigned int type = BaseHookType;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
|
||||
template
|
||||
< boost::intrusive::algo_types Algo
|
||||
, class NodeTraits
|
||||
, class Tag
|
||||
, link_mode_type LinkMode
|
||||
, base_hook_type BaseHookType
|
||||
>
|
||||
class generic_hook
|
||||
/// @cond
|
||||
//If the hook is a base hook, derive generic hook from node_holder
|
||||
//so that a unique base class is created to convert from the node
|
||||
//to the type. This mechanism will be used by bhtraits.
|
||||
//
|
||||
//If the hook is a member hook, generic hook will directly derive
|
||||
//from the hook.
|
||||
: public detail::if_c
|
||||
< detail::is_same<Tag, member_tag>::value
|
||||
, typename NodeTraits::node
|
||||
, node_holder<typename NodeTraits::node, Tag, BaseHookType>
|
||||
>::type
|
||||
//If this is the a default-tagged base hook derive from a class that
|
||||
//will define an special internal typedef. Containers will be able to detect this
|
||||
//special typedef and obtain generic_hook's internal types in order to deduce
|
||||
//value_traits for this hook.
|
||||
, public hook_tags_definer
|
||||
< generic_hook<Algo, NodeTraits, Tag, LinkMode, BaseHookType>
|
||||
, detail::is_same<Tag, dft_tag>::value ? BaseHookType : NoBaseHookId>
|
||||
/// @endcond
|
||||
{
|
||||
/// @cond
|
||||
typedef typename get_algo<Algo, NodeTraits>::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:
|
||||
|
||||
typedef hooktags_impl
|
||||
< NodeTraits
|
||||
, Tag, LinkMode, BaseHookType> hooktags;
|
||||
|
||||
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(hooktags::safemode_or_autounlink){
|
||||
node_algorithms::init(this->this_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
generic_hook(const generic_hook& )
|
||||
{
|
||||
if(hooktags::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<hooktags::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(( hooktags::safemode_or_autounlink ));
|
||||
return !node_algorithms::unique(this->this_ptr());
|
||||
}
|
||||
|
||||
void unlink()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( (int)hooktags::link_mode == (int)auto_unlink ));
|
||||
node_ptr n(this->this_ptr());
|
||||
if(!node_algorithms::inited(n)){
|
||||
node_algorithms::unlink(n);
|
||||
node_algorithms::init(n);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_GENERIC_HOOK_HPP
|
||||
@@ -0,0 +1,222 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_GET_VALUE_TRAITS_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/hook_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
template<class SupposedValueTraits>
|
||||
struct is_default_hook_tag
|
||||
{ static const bool value = false; };
|
||||
|
||||
namespace detail{
|
||||
|
||||
template <class T, class BaseHook>
|
||||
struct concrete_hook_base_value_traits
|
||||
{
|
||||
typedef typename BaseHook::hooktags tags;
|
||||
typedef bhtraits
|
||||
< T
|
||||
, typename tags::node_traits
|
||||
, tags::link_mode
|
||||
, typename tags::tag
|
||||
, tags::type> type;
|
||||
};
|
||||
|
||||
template <class BaseHook>
|
||||
struct concrete_hook_base_value_traits<void, BaseHook>
|
||||
{
|
||||
typedef typename BaseHook::hooktags type;
|
||||
};
|
||||
|
||||
template <class T, class AnyToSomeHook_ProtoValueTraits>
|
||||
struct any_hook_base_value_traits
|
||||
{
|
||||
//AnyToSomeHook value_traits derive from a generic_hook
|
||||
//The generic_hook is configured with any_node_traits
|
||||
//and AnyToSomeHook::value_traits with the correct
|
||||
//node traits for the container, so use node_traits
|
||||
//from AnyToSomeHook_ProtoValueTraits and the rest of
|
||||
//elements from the hooktags member of the generic_hook
|
||||
|
||||
typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t;
|
||||
typedef typename pointer_rebind
|
||||
< typename basic_hook_t::hooktags::node_traits::node_ptr
|
||||
, void>::type void_pointer;
|
||||
typedef typename AnyToSomeHook_ProtoValueTraits::template
|
||||
node_traits_from_voidptr<void_pointer>::type node_traits;
|
||||
|
||||
typedef bhtraits
|
||||
< T
|
||||
, node_traits
|
||||
, basic_hook_t::hooktags::link_mode
|
||||
, typename basic_hook_t::hooktags::tag
|
||||
, basic_hook_t::hooktags::type
|
||||
> type;
|
||||
};
|
||||
|
||||
template <class AnyToSomeHook_ProtoValueTraits>
|
||||
struct any_hook_base_value_traits<void, AnyToSomeHook_ProtoValueTraits>
|
||||
{
|
||||
typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t;
|
||||
typedef typename pointer_rebind
|
||||
< typename basic_hook_t::hooktags::node_traits::node_ptr
|
||||
, void>::type void_pointer;
|
||||
|
||||
struct type
|
||||
{
|
||||
typedef typename AnyToSomeHook_ProtoValueTraits::template
|
||||
node_traits_from_voidptr<void_pointer>::type node_traits;
|
||||
};
|
||||
};
|
||||
|
||||
template<class MemberHook>
|
||||
struct get_member_value_traits
|
||||
{
|
||||
typedef typename MemberHook::member_value_traits type;
|
||||
};
|
||||
|
||||
BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook)
|
||||
BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, hooktags::is_base_hook)
|
||||
|
||||
template <class T>
|
||||
struct internal_member_value_traits
|
||||
{
|
||||
template <class U> static yes_type test(...);
|
||||
template <class U> static no_type test(typename U::member_value_traits* = 0);
|
||||
static const bool value = sizeof(test<T>(0)) == sizeof(no_type);
|
||||
};
|
||||
|
||||
template<class SupposedValueTraits, class T, bool = is_default_hook_tag<SupposedValueTraits>::value>
|
||||
struct supposed_value_traits;
|
||||
|
||||
template<class T, class BaseHook, bool = internal_any_hook_bool_is_true<BaseHook>::value>
|
||||
struct get_base_value_traits;
|
||||
|
||||
template<class SupposedValueTraits, class T, bool = internal_base_hook_bool_is_true<SupposedValueTraits>::value>
|
||||
struct supposed_base_value_traits;
|
||||
|
||||
template<class SupposedValueTraits, bool = internal_member_value_traits<SupposedValueTraits>::value>
|
||||
struct supposed_member_value_traits;
|
||||
|
||||
template<class SupposedValueTraits, bool = internal_any_hook_bool_is_true<SupposedValueTraits>::value>
|
||||
struct any_or_concrete_value_traits;
|
||||
|
||||
//Base any hook
|
||||
template<class T, class BaseHook>
|
||||
struct get_base_value_traits<T, BaseHook, true>
|
||||
: any_hook_base_value_traits<T, BaseHook>
|
||||
{};
|
||||
|
||||
//Non-any base hook
|
||||
template<class T, class BaseHook>
|
||||
struct get_base_value_traits<T, BaseHook, false>
|
||||
: concrete_hook_base_value_traits<T, BaseHook>
|
||||
{};
|
||||
|
||||
//...It's a default hook
|
||||
template<class SupposedValueTraits, class T>
|
||||
struct supposed_value_traits<SupposedValueTraits, T, true>
|
||||
{ typedef typename SupposedValueTraits::template apply<T>::type type; };
|
||||
|
||||
//...Not a default hook
|
||||
template<class SupposedValueTraits, class T>
|
||||
struct supposed_value_traits<SupposedValueTraits, T, false>
|
||||
{ typedef SupposedValueTraits type; };
|
||||
|
||||
//...It's a base hook
|
||||
template<class BaseHook, class T>
|
||||
struct supposed_base_value_traits<BaseHook, T, true>
|
||||
: get_base_value_traits<T, BaseHook>
|
||||
{};
|
||||
|
||||
//...Not a base hook, try if it's a member or value_traits
|
||||
template<class SupposedValueTraits, class T>
|
||||
struct supposed_base_value_traits<SupposedValueTraits, T, false>
|
||||
: supposed_member_value_traits<SupposedValueTraits>
|
||||
{};
|
||||
|
||||
//...It's a member hook
|
||||
template<class MemberHook>
|
||||
struct supposed_member_value_traits<MemberHook, true>
|
||||
: get_member_value_traits<MemberHook>
|
||||
{};
|
||||
|
||||
//...Not a member hook
|
||||
template<class SupposedValueTraits>
|
||||
struct supposed_member_value_traits<SupposedValueTraits, false>
|
||||
: any_or_concrete_value_traits<SupposedValueTraits>
|
||||
{};
|
||||
|
||||
template<class AnyToSomeHook_ProtoValueTraits>
|
||||
struct any_or_concrete_value_traits<AnyToSomeHook_ProtoValueTraits, true>
|
||||
{
|
||||
//A hook node (non-base, e.g.: member or other value traits
|
||||
typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t;
|
||||
typedef typename pointer_rebind
|
||||
<typename basic_hook_t::node_ptr, void>::type void_pointer;
|
||||
typedef typename AnyToSomeHook_ProtoValueTraits::template
|
||||
node_traits_from_voidptr<void_pointer>::type any_node_traits;
|
||||
|
||||
struct type : basic_hook_t
|
||||
{
|
||||
typedef any_node_traits node_traits;
|
||||
};
|
||||
};
|
||||
|
||||
template<class SupposedValueTraits>
|
||||
struct any_or_concrete_value_traits<SupposedValueTraits, false>
|
||||
{
|
||||
typedef SupposedValueTraits type;
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// get_value_traits / get_node_traits
|
||||
////////////////////////////////////////
|
||||
|
||||
template<class T, class SupposedValueTraits>
|
||||
struct get_value_traits
|
||||
: supposed_base_value_traits<typename supposed_value_traits<SupposedValueTraits, T>::type, T>
|
||||
{};
|
||||
|
||||
template<class SupposedValueTraits>
|
||||
struct get_node_traits
|
||||
{
|
||||
typedef typename get_value_traits<void, SupposedValueTraits>::type::node_traits type;
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP
|
||||
+366
@@ -0,0 +1,366 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
//In case no decltype and no variadics, 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/MSVC10/MSVC11
|
||||
#if defined(BOOST_NO_CXX11_DECLTYPE) && defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
# if defined(BOOST_GCC) && (BOOST_GCC < 40400)
|
||||
# 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
|
||||
# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800)
|
||||
# define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED
|
||||
# endif
|
||||
#endif //#if defined(BOOST_NO_CXX11_DECLTYPE) && defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/detail/fwd_macros.hpp>
|
||||
|
||||
namespace boost_intrusive_hmfcw {
|
||||
|
||||
typedef char yes_type;
|
||||
struct no_type{ char dummy[2]; };
|
||||
|
||||
struct dont_care
|
||||
{
|
||||
dont_care(...);
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template<class T>
|
||||
struct make_dontcare
|
||||
{
|
||||
typedef dont_care type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct private_type
|
||||
{
|
||||
static private_type p;
|
||||
private_type const &operator,(int) const;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
no_type is_private_type(T const &);
|
||||
yes_type is_private_type(private_type const &);
|
||||
|
||||
#endif //#if defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
|
||||
template<typename T> struct remove_cv { typedef T type; };
|
||||
template<typename T> struct remove_cv<const T> { typedef T type; };
|
||||
template<typename T> struct remove_cv<const volatile T> { typedef T type; };
|
||||
template<typename T> struct remove_cv<volatile T> { typedef T type; };
|
||||
|
||||
#endif
|
||||
|
||||
} //namespace boost_intrusive_hmfcw {
|
||||
|
||||
#endif //BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME
|
||||
#error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME before including this header!"
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN
|
||||
#error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN before including this header!"
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX
|
||||
#error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX before including this header!"
|
||||
#endif
|
||||
|
||||
#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX < BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN
|
||||
#error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX value MUST be greater or equal than BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN!"
|
||||
#endif
|
||||
|
||||
#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX == 0
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF
|
||||
#else
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF ,
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG
|
||||
#error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG 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
|
||||
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
//With decltype and variadic templaes, things are pretty easy
|
||||
template<typename Fun, class ...Args>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
{
|
||||
template<class U>
|
||||
static decltype(boost::move_detail::declval<U>().
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(::boost::move_detail::declval<Args>()...)
|
||||
, boost_intrusive_hmfcw::yes_type()) Test(U* f);
|
||||
template<class U>
|
||||
static boost_intrusive_hmfcw::no_type Test(...);
|
||||
static const bool value = sizeof(Test<Fun>((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type);
|
||||
};
|
||||
|
||||
#else //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
// has_member_function_callable_with_impl_XXX
|
||||
// declaration, special case and 0 arg specializaton
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
template <typename Type>
|
||||
class BOOST_MOVE_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
{
|
||||
struct BaseMixin
|
||||
{
|
||||
void BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME()
|
||||
{} //Some compilers require the definition or linker errors happen
|
||||
};
|
||||
|
||||
struct Base
|
||||
: public boost_intrusive_hmfcw::remove_cv<Type>::type, public BaseMixin
|
||||
{ //Declare the unneeded default constructor as some old compilers wrongly require it with is_convertible
|
||||
Base(){}
|
||||
};
|
||||
template <typename T, T t> class Helper{};
|
||||
|
||||
template <typename U>
|
||||
static boost_intrusive_hmfcw::no_type deduce
|
||||
(U*, Helper<void (BaseMixin::*)(), &U::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME>* = 0);
|
||||
static boost_intrusive_hmfcw::yes_type deduce(...);
|
||||
|
||||
public:
|
||||
static const bool value = sizeof(boost_intrusive_hmfcw::yes_type) == sizeof(deduce((Base*)0));
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
// has_member_function_callable_with_impl_XXX for 1 to N arguments
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
//defined(BOOST_NO_CXX11_DECLTYPE) must be true
|
||||
template<class Fun>
|
||||
struct FunWrapTmpl : Fun
|
||||
{
|
||||
using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME;
|
||||
FunWrapTmpl();
|
||||
template<class ...DontCares>
|
||||
boost_intrusive_hmfcw::private_type BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(DontCares...) const;
|
||||
};
|
||||
|
||||
template<typename Fun, bool HasFunc, class ...Args>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME);
|
||||
|
||||
//No BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME member specialization
|
||||
template<typename Fun, class ...Args>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
<Fun, false, Args...>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<typename Fun, class ...Args>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun, true, Args...>
|
||||
{
|
||||
static bool const value = (sizeof(boost_intrusive_hmfcw::no_type) == sizeof(boost_intrusive_hmfcw::is_private_type
|
||||
( (::boost::move_detail::declval
|
||||
< FunWrapTmpl<Fun> >().
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(::boost::move_detail::declval<Args>()...), 0) )
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
template<typename Fun, class ...Args>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
: public BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
<Fun
|
||||
, BOOST_MOVE_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun>::value
|
||||
, Args...>
|
||||
{};
|
||||
#else //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
// has_member_function_callable_with_impl_XXX specializations
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
template<typename Fun, bool HasFunc BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF BOOST_MOVE_CAT(BOOST_MOVE_CLASSDFLT,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME);
|
||||
|
||||
//No BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME member specialization
|
||||
template<typename Fun BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF BOOST_MOVE_CAT(BOOST_MOVE_CLASS,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
<Fun, false BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF BOOST_MOVE_CAT(BOOST_MOVE_TARG,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0
|
||||
//0 arg specialization when BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME is present
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
|
||||
template<typename Fun>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun, true>
|
||||
{
|
||||
template<class U>
|
||||
static decltype(boost::move_detail::declval<U>().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME()
|
||||
, boost_intrusive_hmfcw::yes_type()) Test(U* f);
|
||||
|
||||
template<class U>
|
||||
static boost_intrusive_hmfcw::no_type Test(...);
|
||||
static const bool value = sizeof(Test<Fun>((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type);
|
||||
};
|
||||
|
||||
#else //defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
|
||||
#if !defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED)
|
||||
|
||||
template<class F, std::size_t N = sizeof(boost::move_detail::declval<F>().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(), 0)>
|
||||
struct BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
{ boost_intrusive_hmfcw::yes_type dummy[N ? 1 : 2]; };
|
||||
|
||||
template<typename Fun>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun, true>
|
||||
{
|
||||
template<class U> static BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>
|
||||
Test(BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*);
|
||||
template<class U> static boost_intrusive_hmfcw::no_type Test(...);
|
||||
static const bool value = sizeof(Test< Fun >(0)) == sizeof(boost_intrusive_hmfcw::yes_type);
|
||||
};
|
||||
|
||||
#else //defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED)
|
||||
|
||||
template<typename Fun>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun, true>
|
||||
{ //Some compilers gives ICE when instantiating the 0 arg version so it is not supported.
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#endif//!defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED)
|
||||
#endif //!defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
#endif //#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0
|
||||
|
||||
#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX > 0
|
||||
//1 to N arg specialization when BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME is present
|
||||
//Declare some unneeded default constructor as some old compilers wrongly require it with is_convertible
|
||||
#if defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION(N)\
|
||||
\
|
||||
template<class Fun>\
|
||||
struct BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\
|
||||
: Fun\
|
||||
{\
|
||||
using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME;\
|
||||
BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)();\
|
||||
boost_intrusive_hmfcw::private_type BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME\
|
||||
(BOOST_MOVE_REPEAT##N(boost_intrusive_hmfcw::dont_care)) const;\
|
||||
};\
|
||||
\
|
||||
template<typename Fun, BOOST_MOVE_CLASS##N>\
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun, true, BOOST_MOVE_TARG##N>\
|
||||
{\
|
||||
static bool const value = (sizeof(boost_intrusive_hmfcw::no_type) == sizeof(boost_intrusive_hmfcw::is_private_type\
|
||||
( (::boost::move_detail::declval\
|
||||
< BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun> >().\
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(BOOST_MOVE_DECLVAL##N), 0) )\
|
||||
)\
|
||||
);\
|
||||
};\
|
||||
//
|
||||
#else
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION(N)\
|
||||
template<typename Fun, BOOST_MOVE_CLASS##N>\
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\
|
||||
<Fun, true, BOOST_MOVE_TARG##N>\
|
||||
{\
|
||||
template<class U>\
|
||||
static decltype(boost::move_detail::declval<U>().\
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(BOOST_MOVE_DECLVAL##N)\
|
||||
, boost_intrusive_hmfcw::yes_type()) Test(U* f);\
|
||||
template<class U>\
|
||||
static boost_intrusive_hmfcw::no_type Test(...);\
|
||||
static const bool value = sizeof(Test<Fun>((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type);\
|
||||
};\
|
||||
//
|
||||
#endif
|
||||
////////////////////////////////////
|
||||
// Build and invoke BOOST_MOVE_ITERATE_NTOM macrofunction, note that N has to be at least 1
|
||||
////////////////////////////////////
|
||||
#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN 1
|
||||
#else
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN
|
||||
#endif
|
||||
BOOST_MOVE_CAT
|
||||
(BOOST_MOVE_CAT(BOOST_MOVE_CAT(BOOST_MOVE_ITERATE_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN), TO)
|
||||
,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)
|
||||
(BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION)
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN
|
||||
////////////////////////////////////
|
||||
// End of BOOST_MOVE_ITERATE_NTOM
|
||||
////////////////////////////////////
|
||||
#endif //BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX > 0
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
// has_member_function_callable_with_FUNC
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
//Otherwise use the preprocessor
|
||||
template<typename Fun BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF BOOST_MOVE_CAT(BOOST_MOVE_CLASSDFLT,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)>
|
||||
struct BOOST_MOVE_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
: public BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
|
||||
<Fun
|
||||
, BOOST_MOVE_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<Fun>::value
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF BOOST_MOVE_CAT(BOOST_MOVE_TARG,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)>
|
||||
{};
|
||||
#endif //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#endif
|
||||
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END
|
||||
|
||||
//Undef local macros
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF
|
||||
|
||||
//Undef user defined macros
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG
|
||||
#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END
|
||||
@@ -0,0 +1,286 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
// 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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/assert.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/trivial_value_traits.hpp>
|
||||
#include <boost/intrusive/slist.hpp> //make_slist
|
||||
#include <cstddef>
|
||||
#include <climits>
|
||||
#include <boost/move/core.hpp>
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template <class Slist>
|
||||
struct bucket_impl : public Slist
|
||||
{
|
||||
typedef Slist slist_type;
|
||||
BOOST_INTRUSIVE_FORCEINLINE bucket_impl()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bucket_impl(const bucket_impl &)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE ~bucket_impl()
|
||||
{
|
||||
//This bucket is still being used!
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty());
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bucket_impl &operator=(const bucket_impl&)
|
||||
{
|
||||
//This bucket is still in use!
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty());
|
||||
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 Slist slist;
|
||||
typedef typename Slist::size_type size_type;
|
||||
/// @endcond
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bucket_traits_impl(bucket_ptr buckets, size_type len)
|
||||
: buckets_(buckets), buckets_len_(len)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bucket_traits_impl(const bucket_traits_impl &x)
|
||||
: buckets_(x.buckets_), buckets_len_(x.buckets_len_)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bucket_traits_impl& operator=(BOOST_COPY_ASSIGN_REF(bucket_traits_impl) x)
|
||||
{
|
||||
buckets_ = x.buckets_; buckets_len_ = x.buckets_len_; return *this;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const bucket_ptr &bucket_begin() const
|
||||
{ return buckets_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE size_type bucket_count() const
|
||||
{ return buckets_len_; }
|
||||
|
||||
private:
|
||||
bucket_ptr buckets_;
|
||||
size_type buckets_len_;
|
||||
};
|
||||
|
||||
template <class NodeTraits>
|
||||
struct hash_reduced_slist_node_traits
|
||||
{
|
||||
template <class U> static detail::no_type test(...);
|
||||
template <class U> static detail::yes_type test(typename U::reduced_slist_node_traits*);
|
||||
static const bool value = sizeof(test<NodeTraits>(0)) == sizeof(detail::yes_type);
|
||||
};
|
||||
|
||||
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<std::size_t>
|
||||
>::type
|
||||
{};
|
||||
};
|
||||
|
||||
} //namespace detail {
|
||||
|
||||
template<class BucketValueTraits, bool IsConst>
|
||||
class hashtable_iterator
|
||||
{
|
||||
typedef typename BucketValueTraits::value_traits value_traits;
|
||||
typedef typename BucketValueTraits::bucket_traits bucket_traits;
|
||||
|
||||
typedef iiterator< value_traits, IsConst
|
||||
, std::forward_iterator_tag> types_t;
|
||||
public:
|
||||
typedef typename types_t::iterator_type::difference_type difference_type;
|
||||
typedef typename types_t::iterator_type::value_type value_type;
|
||||
typedef typename types_t::iterator_type::pointer pointer;
|
||||
typedef typename types_t::iterator_type::reference reference;
|
||||
typedef typename types_t::iterator_type::iterator_category iterator_category;
|
||||
|
||||
private:
|
||||
typedef typename value_traits::node_traits node_traits;
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef typename detail::get_slist_impl
|
||||
< typename detail::reduced_slist_node_traits
|
||||
<node_traits>::type >::type slist_impl;
|
||||
typedef typename slist_impl::iterator siterator;
|
||||
typedef typename slist_impl::const_iterator const_siterator;
|
||||
typedef detail::bucket_impl<slist_impl> bucket_type;
|
||||
|
||||
typedef typename pointer_traits
|
||||
<pointer>::template rebind_pointer
|
||||
< const BucketValueTraits >::type const_bucketvaltraits_ptr;
|
||||
typedef typename slist_impl::size_type size_type;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr downcast_bucket(typename bucket_type::node_ptr p)
|
||||
{
|
||||
return pointer_traits<node_ptr>::
|
||||
pointer_to(static_cast<typename node_traits::node&>(*p));
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator ()
|
||||
: slist_it_() //Value initialization to achieve "null iterators" (N3644)
|
||||
{}
|
||||
|
||||
explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont)
|
||||
: slist_it_ (ptr)
|
||||
, traitsptr_ (cont ? pointer_traits<const_bucketvaltraits_ptr>::pointer_to(*cont) : const_bucketvaltraits_ptr() )
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator(const hashtable_iterator<BucketValueTraits, false> &other)
|
||||
: slist_it_(other.slist_it()), traitsptr_(other.get_bucket_value_traits())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const siterator &slist_it() const
|
||||
{ return slist_it_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator<BucketValueTraits, false> unconst() const
|
||||
{ return hashtable_iterator<BucketValueTraits, false>(this->slist_it(), this->get_bucket_value_traits()); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator& operator++()
|
||||
{ this->increment(); return *this; }
|
||||
|
||||
hashtable_iterator operator++(int)
|
||||
{
|
||||
hashtable_iterator result (*this);
|
||||
this->increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator== (const hashtable_iterator& i, const hashtable_iterator& i2)
|
||||
{ return i.slist_it_ == i2.slist_it_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator!= (const hashtable_iterator& i, const hashtable_iterator& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE reference operator*() const
|
||||
{ return *this->operator ->(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator->() const
|
||||
{
|
||||
return this->priv_value_traits().to_value_ptr
|
||||
(downcast_bucket(slist_it_.pointed_node()));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const const_bucketvaltraits_ptr &get_bucket_value_traits() const
|
||||
{ return traitsptr_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const value_traits &priv_value_traits() const
|
||||
{ return traitsptr_->priv_value_traits(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const bucket_traits &priv_bucket_traits() const
|
||||
{ return traitsptr_->priv_bucket_traits(); }
|
||||
|
||||
private:
|
||||
void increment()
|
||||
{
|
||||
const bucket_traits &rbuck_traits = this->priv_bucket_traits();
|
||||
bucket_type* const buckets = boost::intrusive::detail::to_raw_pointer(rbuck_traits.bucket_begin());
|
||||
const size_type buckets_len = rbuck_traits.bucket_count();
|
||||
|
||||
++slist_it_;
|
||||
const typename slist_impl::node_ptr n = slist_it_.pointed_node();
|
||||
const siterator first_bucket_bbegin = buckets->end();
|
||||
if(first_bucket_bbegin.pointed_node() <= n && n <= buckets[buckets_len-1].cend().pointed_node()){
|
||||
//If one-past the node is inside the bucket then look for the next non-empty bucket
|
||||
//1. 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_));
|
||||
|
||||
//2. Now just calculate the index b has in the bucket array
|
||||
size_type n_bucket = static_cast<size_type>(&b - buckets);
|
||||
|
||||
//3. Iterate until a non-empty bucket is found
|
||||
do{
|
||||
if (++n_bucket >= buckets_len){ //bucket overflow, return end() iterator
|
||||
slist_it_ = buckets->before_begin();
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (buckets[n_bucket].empty());
|
||||
slist_it_ = buckets[n_bucket].begin();
|
||||
}
|
||||
else{
|
||||
//++slist_it_ yield to a valid object
|
||||
}
|
||||
}
|
||||
|
||||
siterator slist_it_;
|
||||
const_bucketvaltraits_ptr traitsptr_;
|
||||
};
|
||||
|
||||
} //namespace intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,187 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_HOOK_TRAITS_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/detail/parent_from_member.hpp>
|
||||
#include <boost/intrusive/link_mode.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/to_raw_pointer.hpp>
|
||||
#include <boost/intrusive/detail/node_holder.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class T, class NodePtr, class Tag, unsigned int Type>
|
||||
struct bhtraits_base
|
||||
{
|
||||
public:
|
||||
typedef NodePtr node_ptr;
|
||||
typedef typename pointer_traits<node_ptr>::element_type node;
|
||||
typedef node_holder<node, Tag, Type> node_holder_type;
|
||||
typedef T value_type;
|
||||
typedef typename pointer_traits<node_ptr>::
|
||||
template rebind_pointer<const node>::type 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_type & node_holder_reference;
|
||||
typedef const node_holder_type & const_node_holder_reference;
|
||||
typedef node& node_reference;
|
||||
typedef const node & const_node_reference;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static pointer to_value_ptr(const node_ptr & n)
|
||||
{
|
||||
return pointer_traits<pointer>::pointer_to
|
||||
(static_cast<reference>(static_cast<node_holder_reference>(*n)));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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)));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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)));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 NodeTraits, link_mode_type LinkMode, class Tag, unsigned int Type>
|
||||
struct bhtraits
|
||||
: public bhtraits_base<T, typename NodeTraits::node_ptr, Tag, Type>
|
||||
{
|
||||
static const link_mode_type link_mode = LinkMode;
|
||||
typedef NodeTraits node_traits;
|
||||
};
|
||||
|
||||
|
||||
template<class T, class Hook, Hook T::* P>
|
||||
struct mhtraits
|
||||
{
|
||||
public:
|
||||
typedef Hook hook_type;
|
||||
typedef typename hook_type::hooktags::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::hooktags::link_mode;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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)));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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)));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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));
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 fhtraits
|
||||
{
|
||||
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::hooktags::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::hooktags::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)); }
|
||||
};
|
||||
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP
|
||||
@@ -0,0 +1,122 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/iterator.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/is_stateful_value_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class ValueTraits>
|
||||
struct value_traits_pointers
|
||||
{
|
||||
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT
|
||||
(boost::intrusive::detail::
|
||||
, ValueTraits, value_traits_ptr
|
||||
, typename boost::intrusive::pointer_traits<typename ValueTraits::node_traits::node_ptr>::template
|
||||
rebind_pointer<ValueTraits>::type) value_traits_ptr;
|
||||
|
||||
typedef typename boost::intrusive::pointer_traits<value_traits_ptr>::template
|
||||
rebind_pointer<ValueTraits const>::type const_value_traits_ptr;
|
||||
};
|
||||
|
||||
template<class ValueTraits, bool IsConst, class Category>
|
||||
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<node_ptr> nodepointer_traits_t;
|
||||
typedef typename nodepointer_traits_t::template
|
||||
rebind_pointer<void>::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
|
||||
<nonconst_pointer>::reference nonconst_reference;
|
||||
typedef typename ::boost::intrusive::pointer_traits
|
||||
<yesconst_pointer>::reference yesconst_reference;
|
||||
typedef typename nodepointer_traits_t::difference_type difference_type;
|
||||
typedef typename detail::if_c
|
||||
<IsConst, yesconst_pointer, nonconst_pointer>::type pointer;
|
||||
typedef typename detail::if_c
|
||||
<IsConst, yesconst_reference, nonconst_reference>::type reference;
|
||||
typedef iterator
|
||||
< Category
|
||||
, value_type
|
||||
, difference_type
|
||||
, pointer
|
||||
, reference
|
||||
> iterator_type;
|
||||
typedef typename value_traits_pointers
|
||||
<ValueTraits>::value_traits_ptr value_traits_ptr;
|
||||
typedef typename value_traits_pointers
|
||||
<ValueTraits>::const_value_traits_ptr const_value_traits_ptr;
|
||||
static const bool stateful_value_traits =
|
||||
detail::is_stateful_value_traits<value_traits>::value;
|
||||
};
|
||||
|
||||
template<class NodePtr, class StoredPointer, bool StatefulValueTraits = true>
|
||||
struct iiterator_members
|
||||
{
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE iiterator_members()
|
||||
: nodeptr_()//Value initialization to achieve "null iterators" (N3644)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE iiterator_members(const NodePtr &n_ptr, const StoredPointer &data)
|
||||
: nodeptr_(n_ptr), ptr_(data)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE StoredPointer get_ptr() const
|
||||
{ return ptr_; }
|
||||
|
||||
NodePtr nodeptr_;
|
||||
StoredPointer ptr_;
|
||||
};
|
||||
|
||||
template<class NodePtr, class StoredPointer>
|
||||
struct iiterator_members<NodePtr, StoredPointer, false>
|
||||
{
|
||||
BOOST_INTRUSIVE_FORCEINLINE iiterator_members()
|
||||
: nodeptr_()//Value initialization to achieve "null iterators" (N3644)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE iiterator_members(const NodePtr &n_ptr, const StoredPointer &)
|
||||
: nodeptr_(n_ptr)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE StoredPointer get_ptr() const
|
||||
{ return StoredPointer(); }
|
||||
|
||||
NodePtr nodeptr_;
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2009-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_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#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<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
|
||||
|
||||
#endif //@ifndef BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP
|
||||
@@ -0,0 +1,156 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_ITERATOR_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/intrusive/detail/std_fwd.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/move/detail/iterator_traits.hpp>
|
||||
#include <boost/move/detail/meta_utils_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
using boost::movelib::iterator_traits;
|
||||
|
||||
////////////////////
|
||||
// iterator
|
||||
////////////////////
|
||||
template<class Category, class T, class Difference, class Pointer, class Reference>
|
||||
struct iterator
|
||||
{
|
||||
typedef Category iterator_category;
|
||||
typedef T value_type;
|
||||
typedef Difference difference_type;
|
||||
typedef Pointer pointer;
|
||||
typedef Reference reference;
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// iterator_[dis|en]able_if_tag
|
||||
////////////////////////////////////////
|
||||
template<class I, class Tag, class R = void>
|
||||
struct iterator_enable_if_tag
|
||||
: ::boost::move_detail::enable_if_c
|
||||
< ::boost::move_detail::is_same
|
||||
< typename boost::intrusive::iterator_traits<I>::iterator_category
|
||||
, Tag
|
||||
>::value
|
||||
, R>
|
||||
{};
|
||||
|
||||
template<class I, class Tag, class R = void>
|
||||
struct iterator_disable_if_tag
|
||||
: ::boost::move_detail::enable_if_c
|
||||
< !::boost::move_detail::is_same
|
||||
< typename boost::intrusive::iterator_traits<I>::iterator_category
|
||||
, Tag
|
||||
>::value
|
||||
, R>
|
||||
{};
|
||||
|
||||
////////////////////////////////////////
|
||||
// iterator_[dis|en]able_if_tag_difference_type
|
||||
////////////////////////////////////////
|
||||
template<class I, class Tag>
|
||||
struct iterator_enable_if_tag_difference_type
|
||||
: iterator_enable_if_tag<I, Tag, typename boost::intrusive::iterator_traits<I>::difference_type>
|
||||
{};
|
||||
|
||||
template<class I, class Tag>
|
||||
struct iterator_disable_if_tag_difference_type
|
||||
: iterator_disable_if_tag<I, Tag, typename boost::intrusive::iterator_traits<I>::difference_type>
|
||||
{};
|
||||
|
||||
////////////////////
|
||||
// advance
|
||||
////////////////////
|
||||
template<class InputIt, class Distance>
|
||||
typename iterator_enable_if_tag<InputIt, std::input_iterator_tag>::type
|
||||
iterator_advance(InputIt& it, Distance n)
|
||||
{
|
||||
while(n--)
|
||||
++it;
|
||||
}
|
||||
|
||||
template<class InputIt, class Distance>
|
||||
typename iterator_enable_if_tag<InputIt, std::forward_iterator_tag>::type
|
||||
iterator_advance(InputIt& it, Distance n)
|
||||
{
|
||||
while(n--)
|
||||
++it;
|
||||
}
|
||||
|
||||
template<class InputIt, class Distance>
|
||||
typename iterator_enable_if_tag<InputIt, std::bidirectional_iterator_tag>::type
|
||||
iterator_advance(InputIt& it, Distance n)
|
||||
{
|
||||
for (; 0 < n; --n)
|
||||
++it;
|
||||
for (; n < 0; ++n)
|
||||
--it;
|
||||
}
|
||||
|
||||
template<class InputIt, class Distance>
|
||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_tag<InputIt, std::random_access_iterator_tag>::type
|
||||
iterator_advance(InputIt& it, Distance n)
|
||||
{
|
||||
it += n;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// distance
|
||||
////////////////////
|
||||
template<class InputIt> inline
|
||||
typename iterator_disable_if_tag_difference_type
|
||||
<InputIt, std::random_access_iterator_tag>::type
|
||||
iterator_distance(InputIt first, InputIt last)
|
||||
{
|
||||
typename iterator_traits<InputIt>::difference_type off = 0;
|
||||
while(first != last){
|
||||
++off;
|
||||
++first;
|
||||
}
|
||||
return off;
|
||||
}
|
||||
|
||||
template<class InputIt>
|
||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_tag_difference_type
|
||||
<InputIt, std::random_access_iterator_tag>::type
|
||||
iterator_distance(InputIt first, InputIt last)
|
||||
{
|
||||
typename iterator_traits<InputIt>::difference_type off = last - first;
|
||||
return off;
|
||||
}
|
||||
|
||||
template<class I>
|
||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_traits<I>::pointer iterator_arrow_result(const I &i)
|
||||
{ return i.operator->(); }
|
||||
|
||||
template<class T>
|
||||
BOOST_INTRUSIVE_FORCEINLINE T * iterator_arrow_result(T *p)
|
||||
{ return p; }
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP
|
||||
@@ -0,0 +1,125 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_KEY_NODEPTR_COMP_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/ebo_functor_holder.hpp>
|
||||
#include <boost/intrusive/detail/tree_value_compare.hpp>
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template < class KeyTypeKeyCompare
|
||||
, class ValueTraits
|
||||
, class KeyOfValue
|
||||
>
|
||||
struct key_nodeptr_comp_types
|
||||
{
|
||||
typedef ValueTraits value_traits;
|
||||
typedef typename value_traits::value_type value_type;
|
||||
typedef typename value_traits::node_ptr node_ptr;
|
||||
typedef typename value_traits::const_node_ptr const_node_ptr;
|
||||
typedef typename detail::if_c
|
||||
< detail::is_same<KeyOfValue, void>::value
|
||||
, detail::identity<value_type>
|
||||
, KeyOfValue
|
||||
>::type key_of_value;
|
||||
typedef tree_value_compare
|
||||
<typename ValueTraits::pointer, KeyTypeKeyCompare, key_of_value> base_t;
|
||||
};
|
||||
|
||||
//This function object transforms a key comparison type to
|
||||
//a function that can compare nodes or nodes with nodes or keys.
|
||||
template < class KeyTypeKeyCompare
|
||||
, class ValueTraits
|
||||
, class KeyOfValue = void
|
||||
>
|
||||
struct key_nodeptr_comp
|
||||
//Use public inheritance to avoid MSVC bugs with closures
|
||||
: public key_nodeptr_comp_types<KeyTypeKeyCompare, ValueTraits, KeyOfValue>::base_t
|
||||
{
|
||||
private:
|
||||
struct sfinae_type;
|
||||
|
||||
public:
|
||||
typedef key_nodeptr_comp_types<KeyTypeKeyCompare, ValueTraits, KeyOfValue> types_t;
|
||||
typedef typename types_t::value_traits value_traits;
|
||||
typedef typename types_t::value_type value_type;
|
||||
typedef typename types_t::node_ptr node_ptr;
|
||||
typedef typename types_t::const_node_ptr const_node_ptr;
|
||||
typedef typename types_t::base_t base_t;
|
||||
typedef typename types_t::key_of_value key_of_value;
|
||||
|
||||
template <class P1>
|
||||
struct is_same_or_nodeptr_convertible
|
||||
{
|
||||
static const bool same_type = is_same<P1,const_node_ptr>::value || is_same<P1,node_ptr>::value;
|
||||
static const bool value = same_type || is_convertible<P1, const_node_ptr>::value;
|
||||
};
|
||||
|
||||
base_t base() const
|
||||
{ return static_cast<const base_t&>(*this); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE key_nodeptr_comp(KeyTypeKeyCompare kcomp, const ValueTraits *traits)
|
||||
: base_t(kcomp), traits_(traits)
|
||||
{}
|
||||
|
||||
//pred(pnode)
|
||||
template<class T1>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const T1 &t1, typename enable_if_c< is_same_or_nodeptr_convertible<T1>::value, sfinae_type* >::type = 0) const
|
||||
{ return base().get()(key_of_value()(*traits_->to_value_ptr(t1))); }
|
||||
|
||||
//operator() 2 arg
|
||||
//pred(pnode, pnode)
|
||||
template<class T1, class T2>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()
|
||||
(const T1 &t1, const T2 &t2, typename enable_if_c< is_same_or_nodeptr_convertible<T1>::value && is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
|
||||
{ return base()(*traits_->to_value_ptr(t1), *traits_->to_value_ptr(t2)); }
|
||||
|
||||
//pred(pnode, key)
|
||||
template<class T1, class T2>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()
|
||||
(const T1 &t1, const T2 &t2, typename enable_if_c< is_same_or_nodeptr_convertible<T1>::value && !is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
|
||||
{ return base()(*traits_->to_value_ptr(t1), t2); }
|
||||
|
||||
//pred(key, pnode)
|
||||
template<class T1, class T2>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()
|
||||
(const T1 &t1, const T2 &t2, typename enable_if_c< !is_same_or_nodeptr_convertible<T1>::value && is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
|
||||
{ return base()(t1, *traits_->to_value_ptr(t2)); }
|
||||
|
||||
//pred(key, key)
|
||||
template<class T1, class T2>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()
|
||||
(const T1 &t1, const T2 &t2, typename enable_if_c< !is_same_or_nodeptr_convertible<T1>::value && !is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
|
||||
{ return base()(t1, t2); }
|
||||
|
||||
const ValueTraits *const traits_;
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP
|
||||
@@ -0,0 +1,134 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/std_fwd.hpp>
|
||||
#include <boost/intrusive/detail/iiterator.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
// list_iterator provides some basic functions for a
|
||||
// node oriented bidirectional iterator:
|
||||
template<class ValueTraits, bool IsConst>
|
||||
class list_iterator
|
||||
{
|
||||
private:
|
||||
typedef iiterator
|
||||
<ValueTraits, IsConst, std::bidirectional_iterator_tag> 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_type::difference_type difference_type;
|
||||
typedef typename types_t::iterator_type::value_type value_type;
|
||||
typedef typename types_t::iterator_type::pointer pointer;
|
||||
typedef typename types_t::iterator_type::reference reference;
|
||||
typedef typename types_t::iterator_type::iterator_category iterator_category;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE list_iterator()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit list_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr)
|
||||
: members_(nodeptr, traits_ptr)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE list_iterator(list_iterator<ValueTraits, false> const& other)
|
||||
: members_(other.pointed_node(), other.get_value_traits())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const node_ptr &pointed_node() const
|
||||
{ return members_.nodeptr_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE list_iterator &operator=(const node_ptr &node)
|
||||
{ members_.nodeptr_ = node; return static_cast<list_iterator&>(*this); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const_value_traits_ptr get_value_traits() const
|
||||
{ return members_.get_ptr(); }
|
||||
|
||||
public:
|
||||
BOOST_INTRUSIVE_FORCEINLINE list_iterator& operator++()
|
||||
{
|
||||
node_ptr p = node_traits::get_next(members_.nodeptr_);
|
||||
members_.nodeptr_ = p;
|
||||
return static_cast<list_iterator&> (*this);
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE list_iterator operator++(int)
|
||||
{
|
||||
list_iterator result (*this);
|
||||
members_.nodeptr_ = node_traits::get_next(members_.nodeptr_);
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE list_iterator& operator--()
|
||||
{
|
||||
members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_);
|
||||
return static_cast<list_iterator&> (*this);
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE list_iterator operator--(int)
|
||||
{
|
||||
list_iterator result (*this);
|
||||
members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_);
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator== (const list_iterator& l, const list_iterator& r)
|
||||
{ return l.pointed_node() == r.pointed_node(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator!= (const list_iterator& l, const list_iterator& r)
|
||||
{ return !(l == r); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE reference operator*() const
|
||||
{ return *operator->(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator->() const
|
||||
{ return this->operator_arrow(detail::bool_<stateful_value_traits>()); }
|
||||
|
||||
list_iterator<ValueTraits, false> unconst() const
|
||||
{ return list_iterator<ValueTraits, false>(this->pointed_node(), this->get_value_traits()); }
|
||||
|
||||
private:
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::false_) const
|
||||
{ return ValueTraits::to_value_ptr(members_.nodeptr_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::true_) const
|
||||
{ return this->get_value_traits()->to_value_ptr(members_.nodeptr_); }
|
||||
|
||||
iiterator_members<node_ptr, const_value_traits_ptr, stateful_value_traits> members_;
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_LIST_ITERATOR_HPP
|
||||
@@ -0,0 +1,72 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_NODE_HPP
|
||||
#define BOOST_INTRUSIVE_LIST_NODE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_rebind.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_rebind<VoidPointer, 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 node::node_ptr node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const node>::type const_node_ptr;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_previous(const const_node_ptr & n)
|
||||
{ return n->prev_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_previous(const node_ptr & n)
|
||||
{ return n->prev_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_previous(const node_ptr & n, const node_ptr & prev)
|
||||
{ n->prev_ = prev; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const const_node_ptr & n)
|
||||
{ return n->next_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const node_ptr & n)
|
||||
{ return n->next_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_next(const node_ptr & n, const node_ptr & next)
|
||||
{ n->next_ = next; }
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_LIST_NODE_HPP
|
||||
@@ -0,0 +1,295 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <climits>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
|
||||
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<class Uint>
|
||||
struct builtin_clz_dispatch;
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
template<>
|
||||
struct builtin_clz_dispatch< ::boost::ulong_long_type >
|
||||
{
|
||||
static ::boost::ulong_long_type call(::boost::ulong_long_type n)
|
||||
{ return __builtin_clzll(n); }
|
||||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct builtin_clz_dispatch<unsigned long>
|
||||
{
|
||||
static unsigned long call(unsigned long n)
|
||||
{ return __builtin_clzl(n); }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct builtin_clz_dispatch<unsigned int>
|
||||
{
|
||||
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<std::size_t>::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<std::size_t N>
|
||||
inline std::size_t floor_log2 (std::size_t x, integral_constant<std::size_t, N>)
|
||||
{
|
||||
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_<Size_t_Bits_Power_2>());
|
||||
while(shift){
|
||||
std::size_t tmp = n >> shift;
|
||||
if (tmp){
|
||||
log2 += shift, n = tmp;
|
||||
}
|
||||
shift = floor_log2_get_shift(shift, bool_<Size_t_Bits_Power_2>());
|
||||
}
|
||||
|
||||
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, integral_constant<std::size_t, 32>)
|
||||
{
|
||||
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, integral_constant<std::size_t, 64>)
|
||||
{
|
||||
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, integral_constant<std::size_t, Bits>());
|
||||
}
|
||||
|
||||
#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<float>(log_2);
|
||||
}
|
||||
|
||||
inline bool is_pow2(std::size_t x)
|
||||
{ return (x & (x-1)) == 0; }
|
||||
|
||||
template<std::size_t N>
|
||||
struct static_is_pow2
|
||||
{
|
||||
static const bool value = (N & (N-1)) == 0;
|
||||
};
|
||||
|
||||
inline std::size_t ceil_log2 (std::size_t x)
|
||||
{
|
||||
return static_cast<std::size_t>(!(is_pow2)(x)) + floor_log2(x);
|
||||
}
|
||||
|
||||
inline std::size_t ceil_pow2 (std::size_t x)
|
||||
{
|
||||
return std::size_t(1u) << (ceil_log2)(x);
|
||||
}
|
||||
|
||||
inline std::size_t previous_or_equal_pow2(std::size_t x)
|
||||
{
|
||||
return std::size_t(1u) << 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 SizeType value = 0xb504f334;
|
||||
static const std::size_t pow = 31;
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
|
||||
template <class SizeType>
|
||||
struct sqrt2_pow_max<SizeType, typename enable_if< numbits_eq<SizeType, 64> >::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<std::size_t>::value;
|
||||
const std::size_t pow = (std::size_t)sqrt2_pow_max<std::size_t>::pow;
|
||||
return (value >> (pow - x)) + 1;
|
||||
}
|
||||
|
||||
} //namespace detail
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_MATH_HPP
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2014-2015
|
||||
//
|
||||
// Distributed under the 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_MINIMAL_LESS_EQUAL_HEADER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_MINIMAL_LESS_EQUAL_HEADER_HPP
|
||||
#
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
#
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
#
|
||||
#//Try to avoid including <functional>, as it's quite big in C++11
|
||||
#if defined(BOOST_GNU_STDLIB)
|
||||
# include <bits/stl_function.h>
|
||||
#else
|
||||
# include <functional> //Fallback
|
||||
#endif
|
||||
#
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_MINIMAL_LESS_EQUAL_HEADER_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2014-2015
|
||||
//
|
||||
// Distributed under the 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_MINIMAL_PAIR_HEADER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_MINIMAL_PAIR_HEADER_HPP
|
||||
#
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
#
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
#
|
||||
#//Try to avoid including <utility>, as it's quite big in C++11
|
||||
#if defined(BOOST_GNU_STDLIB)
|
||||
# include <bits/stl_pair.h>
|
||||
#else
|
||||
# include <utility> //Fallback
|
||||
#endif
|
||||
#
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_MINIMAL_PAIR_HEADER_HPP
|
||||
@@ -0,0 +1,206 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2014
|
||||
// (C) Copyright Microsoft Corporation 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_MPL_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_MPL_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/move/detail/type_traits.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
using boost::move_detail::is_same;
|
||||
using boost::move_detail::add_const;
|
||||
using boost::move_detail::remove_const;
|
||||
using boost::move_detail::remove_cv;
|
||||
using boost::move_detail::remove_reference;
|
||||
using boost::move_detail::add_reference;
|
||||
using boost::move_detail::remove_pointer;
|
||||
using boost::move_detail::add_pointer;
|
||||
using boost::move_detail::true_type;
|
||||
using boost::move_detail::false_type;
|
||||
using boost::move_detail::enable_if_c;
|
||||
using boost::move_detail::enable_if;
|
||||
using boost::move_detail::disable_if_c;
|
||||
using boost::move_detail::disable_if;
|
||||
using boost::move_detail::is_convertible;
|
||||
using boost::move_detail::if_c;
|
||||
using boost::move_detail::if_;
|
||||
using boost::move_detail::is_const;
|
||||
using boost::move_detail::identity;
|
||||
using boost::move_detail::alignment_of;
|
||||
using boost::move_detail::is_empty;
|
||||
using boost::move_detail::addressof;
|
||||
using boost::move_detail::integral_constant;
|
||||
using boost::move_detail::enable_if_convertible;
|
||||
using boost::move_detail::disable_if_convertible;
|
||||
using boost::move_detail::bool_;
|
||||
using boost::move_detail::true_;
|
||||
using boost::move_detail::false_;
|
||||
using boost::move_detail::yes_type;
|
||||
using boost::move_detail::no_type;
|
||||
using boost::move_detail::apply;
|
||||
using boost::move_detail::eval_if_c;
|
||||
using boost::move_detail::eval_if;
|
||||
using boost::move_detail::unvoid_ref;
|
||||
using boost::move_detail::add_const_if_c;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
// 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(...); \
|
||||
\
|
||||
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; \
|
||||
}; \
|
||||
//
|
||||
|
||||
#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_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(TNAME)\
|
||||
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(...); \
|
||||
\
|
||||
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_EVAL_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \
|
||||
typename INSTANTIATION_NS_PREFIX \
|
||||
boost_intrusive_eval_default_type_ ## TNAME< T, TIMPL >::type \
|
||||
//
|
||||
|
||||
#define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \
|
||||
template <class T>\
|
||||
struct TRAITS_PREFIX##_bool\
|
||||
{\
|
||||
template<bool Add>\
|
||||
struct two_or_three {yes_type _[2 + Add];};\
|
||||
template <class U> static yes_type test(...);\
|
||||
template <class U> static two_or_three<U::TYPEDEF_TO_FIND> test (int);\
|
||||
static const std::size_t value = sizeof(test<T>(0));\
|
||||
};\
|
||||
\
|
||||
template <class T>\
|
||||
struct TRAITS_PREFIX##_bool_is_true\
|
||||
{\
|
||||
static const bool value = TRAITS_PREFIX##_bool<T>::value > sizeof(yes_type)*2;\
|
||||
};\
|
||||
//
|
||||
|
||||
#define BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(TRAITS_NAME, FUNC_NAME) \
|
||||
template <typename U, typename Signature> \
|
||||
class TRAITS_NAME \
|
||||
{ \
|
||||
private: \
|
||||
template<Signature> struct helper;\
|
||||
template<typename T> \
|
||||
static ::boost::intrusive::detail::yes_type test(helper<&T::FUNC_NAME>*); \
|
||||
template<typename T> static ::boost::intrusive::detail::no_type test(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(test<U>(0)) == sizeof(::boost::intrusive::detail::yes_type); \
|
||||
}; \
|
||||
//
|
||||
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME, FUNC_NAME) \
|
||||
template <typename Type> \
|
||||
struct TRAITS_NAME \
|
||||
{ \
|
||||
struct BaseMixin \
|
||||
{ \
|
||||
void FUNC_NAME(); \
|
||||
}; \
|
||||
struct Base : public Type, public BaseMixin { Base(); }; \
|
||||
template <typename T, T t> class Helper{}; \
|
||||
template <typename U> \
|
||||
static ::boost::intrusive::detail::no_type test(U*, Helper<void (BaseMixin::*)(), &U::FUNC_NAME>* = 0); \
|
||||
static ::boost::intrusive::detail::yes_type test(...); \
|
||||
static const bool value = sizeof(::boost::intrusive::detail::yes_type) == sizeof(test((Base*)(0))); \
|
||||
};\
|
||||
//
|
||||
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(TRAITS_NAME, FUNC_NAME) \
|
||||
BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME##_ignore_signature, FUNC_NAME) \
|
||||
\
|
||||
template <typename Type, class> \
|
||||
struct TRAITS_NAME \
|
||||
: public TRAITS_NAME##_ignore_signature<Type> \
|
||||
{};\
|
||||
//
|
||||
|
||||
} //namespace detail
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP
|
||||
@@ -0,0 +1,105 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_NODE_CLONER_DISPOSER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/link_mode.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/ebo_functor_holder.hpp>
|
||||
#include <boost/intrusive/detail/algo_type.hpp>
|
||||
#include <boost/intrusive/detail/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template<class F, class ValueTraits, algo_types AlgoType, bool IsConst = true>
|
||||
struct node_cloner
|
||||
//Use public inheritance to avoid MSVC bugs with closures
|
||||
: public ebo_functor_holder<F>
|
||||
{
|
||||
typedef ValueTraits value_traits;
|
||||
typedef typename value_traits::node_traits node_traits;
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef ebo_functor_holder<F> base_t;
|
||||
typedef typename get_algo< AlgoType
|
||||
, node_traits>::type node_algorithms;
|
||||
static const bool safemode_or_autounlink =
|
||||
is_safe_autounlink<value_traits::link_mode>::value;
|
||||
typedef typename value_traits::value_type value_type;
|
||||
typedef typename value_traits::pointer pointer;
|
||||
typedef typename value_traits::const_pointer const_pointer;
|
||||
typedef typename node_traits::node node;
|
||||
typedef typename value_traits::const_node_ptr const_node_ptr;
|
||||
typedef typename pointer_traits<pointer>::reference reference;
|
||||
typedef typename pointer_traits
|
||||
<const_pointer>::reference const_reference;
|
||||
typedef typename if_c<IsConst, const_reference, reference>::type reference_type;
|
||||
|
||||
node_cloner(F f, const ValueTraits *traits)
|
||||
: base_t(f), traits_(traits)
|
||||
{}
|
||||
|
||||
// tree-based containers use this method, which is proxy-reference friendly
|
||||
node_ptr operator()(const node_ptr & p)
|
||||
{
|
||||
reference_type v = *traits_->to_value_ptr(p);
|
||||
node_ptr n = traits_->to_node_ptr(*base_t::get()(v));
|
||||
//Cloned node must be in default mode if the linking mode requires it
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(n));
|
||||
return n;
|
||||
}
|
||||
|
||||
const ValueTraits * const traits_;
|
||||
};
|
||||
|
||||
template<class F, class ValueTraits, algo_types AlgoType>
|
||||
struct node_disposer
|
||||
//Use public inheritance to avoid MSVC bugs with closures
|
||||
: public ebo_functor_holder<F>
|
||||
{
|
||||
typedef ValueTraits value_traits;
|
||||
typedef typename value_traits::node_traits node_traits;
|
||||
typedef typename node_traits::node_ptr node_ptr;
|
||||
typedef ebo_functor_holder<F> base_t;
|
||||
typedef typename get_algo< AlgoType
|
||||
, node_traits>::type node_algorithms;
|
||||
static const bool safemode_or_autounlink =
|
||||
is_safe_autounlink<value_traits::link_mode>::value;
|
||||
|
||||
node_disposer(F f, const ValueTraits *cont)
|
||||
: base_t(f), traits_(cont)
|
||||
{}
|
||||
|
||||
void operator()(const node_ptr & p)
|
||||
{
|
||||
if(safemode_or_autounlink)
|
||||
node_algorithms::init(p);
|
||||
base_t::get()(traits_->to_value_ptr(p));
|
||||
}
|
||||
const ValueTraits * const traits_;
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_NODE_HOLDER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_NODE_HOLDER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class Node, class Tag, unsigned int>
|
||||
struct node_holder
|
||||
: public Node
|
||||
{};
|
||||
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_NODE_HOLDER_HPP
|
||||
@@ -0,0 +1,130 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_NODE_TO_VALUE_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/is_stateful_value_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template<class VoidPointer>
|
||||
struct dummy_constptr
|
||||
{
|
||||
typedef typename boost::intrusive::pointer_traits<VoidPointer>::
|
||||
template rebind_pointer<const void>::type ConstVoidPtr;
|
||||
|
||||
explicit dummy_constptr(ConstVoidPtr)
|
||||
{}
|
||||
|
||||
dummy_constptr()
|
||||
{}
|
||||
|
||||
ConstVoidPtr get_ptr() const
|
||||
{ return ConstVoidPtr(); }
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
struct constptr
|
||||
{
|
||||
typedef typename boost::intrusive::pointer_traits<VoidPointer>::
|
||||
template rebind_pointer<const void>::type ConstVoidPtr;
|
||||
|
||||
constptr()
|
||||
{}
|
||||
|
||||
explicit constptr(const ConstVoidPtr &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 if_c
|
||||
< store_ptr
|
||||
, constptr<VoidPointer>
|
||||
, dummy_constptr<VoidPointer>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
|
||||
template<class ValueTraits, bool IsConst>
|
||||
struct node_to_value
|
||||
: public select_constptr
|
||||
< typename pointer_traits
|
||||
<typename ValueTraits::pointer>::template rebind_pointer<void>::type
|
||||
, is_stateful_value_traits<ValueTraits>::value
|
||||
>::type
|
||||
{
|
||||
static const bool stateful_value_traits = is_stateful_value_traits<ValueTraits>::value;
|
||||
typedef typename select_constptr
|
||||
< typename pointer_traits
|
||||
<typename ValueTraits::pointer>::
|
||||
template rebind_pointer<void>::type
|
||||
, stateful_value_traits >::type Base;
|
||||
|
||||
typedef ValueTraits value_traits;
|
||||
typedef typename value_traits::value_type value_type;
|
||||
typedef typename value_traits::node_traits::node node;
|
||||
typedef typename add_const_if_c
|
||||
<value_type, IsConst>::type vtype;
|
||||
typedef typename add_const_if_c
|
||||
<node, IsConst>::type ntype;
|
||||
typedef typename pointer_traits
|
||||
<typename ValueTraits::pointer>::
|
||||
template rebind_pointer<ntype>::type npointer;
|
||||
typedef typename pointer_traits<npointer>::
|
||||
template rebind_pointer<const ValueTraits>::type const_value_traits_ptr;
|
||||
|
||||
node_to_value(const const_value_traits_ptr &ptr)
|
||||
: Base(ptr)
|
||||
{}
|
||||
|
||||
typedef vtype & result_type;
|
||||
typedef ntype & first_argument_type;
|
||||
|
||||
const_value_traits_ptr get_value_traits() const
|
||||
{ return pointer_traits<const_value_traits_ptr>::static_cast_from(Base::get_ptr()); }
|
||||
|
||||
result_type to_value(first_argument_type arg, false_) const
|
||||
{ return *(value_traits::to_value_ptr(pointer_traits<npointer>::pointer_to(arg))); }
|
||||
|
||||
result_type to_value(first_argument_type arg, true_) const
|
||||
{ return *(this->get_value_traits()->to_value_ptr(pointer_traits<npointer>::pointer_to(arg))); }
|
||||
|
||||
result_type operator()(first_argument_type arg) const
|
||||
{ return this->to_value(arg, bool_<stateful_value_traits>()); }
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP
|
||||
@@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-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_DETAIL_PARENT_FROM_MEMBER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER
|
||||
#include <boost/static_assert.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template<class Parent, class Member>
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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_ABI_PTR_TO_MEMBER)
|
||||
|
||||
//MSVC compliant compilers use their the first 32 bits as offset (even in 64 bit mode)
|
||||
union caster_union
|
||||
{
|
||||
const Member Parent::* ptr_to_member;
|
||||
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(int) );
|
||||
|
||||
caster.ptr_to_member = ptr_to_member;
|
||||
return std::ptrdiff_t(caster.offset);
|
||||
//Additional info on MSVC behaviour for the future. For 2/3 int ptr-to-member
|
||||
//types dereference seems to be:
|
||||
//
|
||||
// vboffset = [compile_time_offset if 2-int ptr2memb] /
|
||||
// [ptr2memb.i32[2] if 3-int ptr2memb].
|
||||
// vbtable = *(this + vboffset);
|
||||
// adj = vbtable[ptr2memb.i32[1]];
|
||||
// var = adj + (this + vboffset) + ptr2memb.i32[0];
|
||||
//
|
||||
//To reverse the operation we need to
|
||||
// - obtain vboffset (in 2-int ptr2memb implementation only)
|
||||
// - Go to Parent's vbtable and obtain adjustment at index ptr2memb.i32[1]
|
||||
// - parent = member - adj - vboffset - ptr2memb.i32[0]
|
||||
//
|
||||
//Even accessing to RTTI we might not be able to obtain this information
|
||||
//so anyone who thinks it's possible, please send a patch.
|
||||
|
||||
//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 = static_cast<const char*>(static_cast<const void*>(&(parent->*ptr_to_member)));
|
||||
return std::ptrdiff_t(member - static_cast<const char*>(static_cast<const void*>(parent)));
|
||||
#else
|
||||
//This is the traditional C-front approach: __MWERKS__, __DMC__, __SUNPRO_CC
|
||||
union caster_union
|
||||
{
|
||||
const Member Parent::* ptr_to_member;
|
||||
std::ptrdiff_t offset;
|
||||
} caster;
|
||||
caster.ptr_to_member = ptr_to_member;
|
||||
return caster.offset - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class Parent, class Member>
|
||||
BOOST_INTRUSIVE_FORCEINLINE Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member)
|
||||
{
|
||||
return static_cast<Parent*>
|
||||
(
|
||||
static_cast<void*>
|
||||
(
|
||||
static_cast<char*>(static_cast<void*>(member)) - offset_from_pointer_to_member(ptr_to_member)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
template<class Parent, class Member>
|
||||
BOOST_INTRUSIVE_FORCEINLINE const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
|
||||
{
|
||||
return static_cast<const Parent*>
|
||||
(
|
||||
static_cast<const void*>
|
||||
(
|
||||
static_cast<const char*>(static_cast<const void*>(member)) - offset_from_pointer_to_member(ptr_to_member)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
} //namespace detail {
|
||||
} //namespace intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP
|
||||
@@ -0,0 +1,168 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_POINTER_ELEMENT_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_POINTER_ELEMENT_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail{
|
||||
|
||||
//////////////////////
|
||||
//struct first_param
|
||||
//////////////////////
|
||||
|
||||
template <typename T> struct first_param
|
||||
{ typedef void type; };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_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
|
||||
|
||||
template < template //0arg
|
||||
<class
|
||||
> class TemplateClass, class T
|
||||
>
|
||||
struct first_param
|
||||
< TemplateClass<T> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //1arg
|
||||
<class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //2arg
|
||||
<class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //3arg
|
||||
<class,class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1, class P2>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1, P2> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //4arg
|
||||
<class,class,class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1, class P2, class P3>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1, P2, P3> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //5arg
|
||||
<class,class,class,class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1, class P2, class P3, class P4>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1, P2, P3, P4> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //6arg
|
||||
<class,class,class,class,class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1, class P2, class P3, class P4, class P5>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1, P2, P3, P4, P5> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //7arg
|
||||
<class,class,class,class,class,class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1, class P2, class P3, class P4, class P5, class P6>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1, P2, P3, P4, P5, P6> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //8arg
|
||||
<class,class,class,class,class,class,class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1, P2, P3, P4, P5, P6, P7> >
|
||||
{ typedef T type; };
|
||||
|
||||
template < template //9arg
|
||||
<class,class,class,class,class,class,class,class,class,class
|
||||
> class TemplateClass, class T
|
||||
, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
|
||||
struct first_param
|
||||
< TemplateClass<T, P0, P1, P2, P3, P4, P5, P6, P7, P8> >
|
||||
{ typedef T type; };
|
||||
|
||||
#endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct has_internal_pointer_element
|
||||
{
|
||||
template <typename X>
|
||||
static char test(int, typename X::element_type*);
|
||||
|
||||
template <typename X>
|
||||
static int test(...);
|
||||
|
||||
static const bool value = (1 == sizeof(test<T>(0, 0)));
|
||||
};
|
||||
|
||||
template<class Ptr, bool = has_internal_pointer_element<Ptr>::value>
|
||||
struct pointer_element_impl
|
||||
{
|
||||
typedef typename Ptr::element_type type;
|
||||
};
|
||||
|
||||
template<class Ptr>
|
||||
struct pointer_element_impl<Ptr, false>
|
||||
{
|
||||
typedef typename boost::intrusive::detail::first_param<Ptr>::type type;
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
|
||||
template <typename Ptr>
|
||||
struct pointer_element
|
||||
{
|
||||
typedef typename ::boost::intrusive::detail::pointer_element_impl<Ptr>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct pointer_element<T*>
|
||||
{ typedef T type; };
|
||||
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#endif // defined(BOOST_INTRUSIVE_DETAIL_POINTER_ELEMENT_HPP)
|
||||
@@ -0,0 +1,205 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_RBTREE_NODE_HPP
|
||||
#define BOOST_INTRUSIVE_RBTREE_NODE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_rebind.hpp>
|
||||
#include <boost/intrusive/rbtree_algorithms.hpp>
|
||||
#include <boost/intrusive/pointer_plus_bits.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/tree_node.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 compact_rbtree_node<VoidPointer> node;
|
||||
typedef typename pointer_rebind<VoidPointer, node >::type node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const node >::type const_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 rbtree_node<VoidPointer> node;
|
||||
typedef typename pointer_rebind<VoidPointer, node >::type node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const node >::type const_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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
typedef typename node::color color;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return n->parent_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const node_ptr & n)
|
||||
{ return n->parent_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ n->parent_ = p; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->left_ = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
|
||||
{ n->right_ = r; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color get_color(const const_node_ptr & n)
|
||||
{ return n->color_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color get_color(const node_ptr & n)
|
||||
{ return n->color_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_color(const node_ptr & n, color c)
|
||||
{ n->color_ = c; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color black()
|
||||
{ return node::black_t; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 node::node_ptr node_ptr;
|
||||
typedef typename node::const_node_ptr const_node_ptr;
|
||||
|
||||
typedef pointer_plus_bits<node_ptr, 1> ptr_bit;
|
||||
|
||||
typedef typename node::color color;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return ptr_bit::get_pointer(n->parent_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const node_ptr & n)
|
||||
{ return ptr_bit::get_pointer(n->parent_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ ptr_bit::set_pointer(n->parent_, p); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->left_ = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
|
||||
{ n->right_ = r; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color get_color(const const_node_ptr & n)
|
||||
{ return (color)ptr_bit::get_bits(n->parent_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color get_color(const node_ptr & n)
|
||||
{ return (color)ptr_bit::get_bits(n->parent_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_color(const node_ptr & n, color c)
|
||||
{ ptr_bit::set_bits(n->parent_, c != 0); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static color black()
|
||||
{ return node::black_t; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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 rbtree_node_traits_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
|
||||
@@ -0,0 +1,165 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_REVERSE_ITERATOR_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/iterator.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class It>
|
||||
class reverse_iterator
|
||||
{
|
||||
public:
|
||||
typedef typename boost::intrusive::iterator_traits<It>::pointer pointer;
|
||||
typedef typename boost::intrusive::iterator_traits<It>::reference reference;
|
||||
typedef typename boost::intrusive::iterator_traits<It>::difference_type difference_type;
|
||||
typedef typename boost::intrusive::iterator_traits<It>::iterator_category iterator_category;
|
||||
typedef typename boost::intrusive::iterator_traits<It>::value_type value_type;
|
||||
|
||||
|
||||
typedef It iterator_type;
|
||||
|
||||
reverse_iterator()
|
||||
: m_current() //Value initialization to achieve "null iterators" (N3644)
|
||||
{}
|
||||
|
||||
explicit reverse_iterator(It r)
|
||||
: m_current(r)
|
||||
{}
|
||||
|
||||
reverse_iterator(const reverse_iterator& r)
|
||||
: m_current(r.base())
|
||||
{}
|
||||
|
||||
template<class OtherIt>
|
||||
reverse_iterator( const reverse_iterator<OtherIt>& r
|
||||
, typename boost::intrusive::detail::enable_if_convertible<OtherIt, It>::type* =0
|
||||
)
|
||||
: m_current(r.base())
|
||||
{}
|
||||
|
||||
reverse_iterator & operator=( const reverse_iterator& r)
|
||||
{ m_current = r.base(); return *this; }
|
||||
|
||||
template<class OtherIt>
|
||||
typename boost::intrusive::detail::enable_if_convertible<OtherIt, It, reverse_iterator &>::type
|
||||
operator=( const reverse_iterator<OtherIt>& r)
|
||||
{ m_current = r.base(); return *this; }
|
||||
|
||||
It base() const
|
||||
{ return m_current; }
|
||||
|
||||
reference operator*() const
|
||||
{
|
||||
It temp(m_current);
|
||||
--temp;
|
||||
reference r = *temp;
|
||||
return r;
|
||||
}
|
||||
|
||||
pointer operator->() const
|
||||
{
|
||||
It temp(m_current);
|
||||
--temp;
|
||||
return iterator_arrow_result(temp);
|
||||
}
|
||||
|
||||
reference operator[](difference_type off) const
|
||||
{
|
||||
return this->m_current[-off - 1];
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
reverse_iterator& operator-=(difference_type off)
|
||||
{ m_current += off; return *this; }
|
||||
|
||||
friend reverse_iterator operator+(reverse_iterator l, difference_type off)
|
||||
{ return (l += off); }
|
||||
|
||||
friend reverse_iterator operator+(difference_type off, reverse_iterator r)
|
||||
{ return (r += off); }
|
||||
|
||||
friend reverse_iterator operator-(reverse_iterator l, difference_type off)
|
||||
{ return (l-= off); }
|
||||
|
||||
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 intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP
|
||||
@@ -0,0 +1,50 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_SIMPLE_DISPOSERS_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_SIMPLE_DISPOSERS_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
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); }
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_SIMPLE_DISPOSERS_HPP
|
||||
@@ -0,0 +1,91 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_SIZE_HOLDER_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template<bool ConstantSize, class SizeType, class Tag = void>
|
||||
struct size_holder
|
||||
{
|
||||
static const bool constant_time_size = ConstantSize;
|
||||
typedef SizeType size_type;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE SizeType get_size() const
|
||||
{ return size_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void set_size(SizeType size)
|
||||
{ size_ = size; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void decrement()
|
||||
{ --size_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void increment()
|
||||
{ ++size_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void increase(SizeType n)
|
||||
{ size_ += n; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void decrease(SizeType n)
|
||||
{ size_ -= n; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void swap(size_holder &other)
|
||||
{ SizeType tmp(size_); size_ = other.size_; other.size_ = tmp; }
|
||||
|
||||
SizeType size_;
|
||||
};
|
||||
|
||||
template<class SizeType, class Tag>
|
||||
struct size_holder<false, SizeType, Tag>
|
||||
{
|
||||
static const bool constant_time_size = false;
|
||||
typedef SizeType size_type;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE size_type get_size() const
|
||||
{ return 0; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void set_size(size_type)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void decrement()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void increment()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void increase(SizeType)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void decrease(SizeType)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void swap(size_holder){}
|
||||
};
|
||||
|
||||
} //namespace detail{
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP
|
||||
@@ -0,0 +1,125 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_SLIST_ITERATOR_HPP
|
||||
#define BOOST_INTRUSIVE_SLIST_ITERATOR_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/std_fwd.hpp>
|
||||
#include <boost/intrusive/detail/iiterator.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
|
||||
// slist_iterator provides some basic functions for a
|
||||
// node oriented bidirectional iterator:
|
||||
template<class ValueTraits, bool IsConst>
|
||||
class slist_iterator
|
||||
{
|
||||
private:
|
||||
typedef iiterator
|
||||
<ValueTraits, IsConst, std::forward_iterator_tag> 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_type::difference_type difference_type;
|
||||
typedef typename types_t::iterator_type::value_type value_type;
|
||||
typedef typename types_t::iterator_type::pointer pointer;
|
||||
typedef typename types_t::iterator_type::reference reference;
|
||||
typedef typename types_t::iterator_type::iterator_category iterator_category;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE slist_iterator()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit slist_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr)
|
||||
: members_(nodeptr, traits_ptr)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE slist_iterator(slist_iterator<ValueTraits, false> const& other)
|
||||
: members_(other.pointed_node(), other.get_value_traits())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const node_ptr &pointed_node() const
|
||||
{ return members_.nodeptr_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE slist_iterator &operator=(const node_ptr &node)
|
||||
{ members_.nodeptr_ = node; return static_cast<slist_iterator&>(*this); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const_value_traits_ptr get_value_traits() const
|
||||
{ return members_.get_ptr(); }
|
||||
|
||||
public:
|
||||
BOOST_INTRUSIVE_FORCEINLINE slist_iterator& operator++()
|
||||
{
|
||||
members_.nodeptr_ = node_traits::get_next(members_.nodeptr_);
|
||||
return static_cast<slist_iterator&> (*this);
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE slist_iterator operator++(int)
|
||||
{
|
||||
slist_iterator result (*this);
|
||||
members_.nodeptr_ = node_traits::get_next(members_.nodeptr_);
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator== (const slist_iterator& l, const slist_iterator& r)
|
||||
{ return l.pointed_node() == r.pointed_node(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator!= (const slist_iterator& l, const slist_iterator& r)
|
||||
{ return !(l == r); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE reference operator*() const
|
||||
{ return *operator->(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator->() const
|
||||
{ return this->operator_arrow(detail::bool_<stateful_value_traits>()); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE slist_iterator<ValueTraits, false> unconst() const
|
||||
{ return slist_iterator<ValueTraits, false>(this->pointed_node(), this->get_value_traits()); }
|
||||
|
||||
private:
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::false_) const
|
||||
{ return ValueTraits::to_value_ptr(members_.nodeptr_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::true_) const
|
||||
{ return this->get_value_traits()->to_value_ptr(members_.nodeptr_); }
|
||||
|
||||
iiterator_members<node_ptr, const_value_traits_ptr, stateful_value_traits> members_;
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_SLIST_ITERATOR_HPP
|
||||
@@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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_SLIST_NODE_HPP
|
||||
#define BOOST_INTRUSIVE_SLIST_NODE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_rebind.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class VoidPointer>
|
||||
struct slist_node
|
||||
{
|
||||
typedef typename pointer_rebind<VoidPointer, 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 node::node_ptr node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const node>::type const_node_ptr;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const const_node_ptr & n)
|
||||
{ return n->next_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const node_ptr & n)
|
||||
{ return n->next_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_next(const node_ptr & n, const node_ptr & next)
|
||||
{ n->next_ = next; }
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_SLIST_NODE_HPP
|
||||
@@ -0,0 +1,43 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Standard predeclarations
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/move/detail/std_ns_begin.hpp>
|
||||
BOOST_MOVE_STD_NS_BEG
|
||||
|
||||
template<class T>
|
||||
struct less;
|
||||
|
||||
template<class T>
|
||||
struct equal_to;
|
||||
|
||||
struct input_iterator_tag;
|
||||
struct forward_iterator_tag;
|
||||
struct bidirectional_iterator_tag;
|
||||
struct random_access_iterator_tag;
|
||||
|
||||
BOOST_MOVE_STD_NS_END
|
||||
#include <boost/move/detail/std_ns_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP
|
||||
@@ -0,0 +1,47 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/pointer_element.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template <class T>
|
||||
BOOST_INTRUSIVE_FORCEINLINE T* to_raw_pointer(T* p)
|
||||
{ return p; }
|
||||
|
||||
template <class Pointer>
|
||||
BOOST_INTRUSIVE_FORCEINLINE typename boost::intrusive::pointer_element<Pointer>::type*
|
||||
to_raw_pointer(const Pointer &p)
|
||||
{ return boost::intrusive::detail::to_raw_pointer(p.operator->()); }
|
||||
|
||||
} //namespace detail
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP
|
||||
@@ -0,0 +1,172 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-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_DETAIL_TRANSFORM_ITERATOR_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_TRANSFORM_ITERATOR_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# 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/iterator.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template <class PseudoReference>
|
||||
struct operator_arrow_proxy
|
||||
{
|
||||
BOOST_INTRUSIVE_FORCEINLINE operator_arrow_proxy(const PseudoReference &px)
|
||||
: m_value(px)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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&>
|
||||
{
|
||||
BOOST_INTRUSIVE_FORCEINLINE operator_arrow_proxy(T &px)
|
||||
: m_value(px)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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:
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
typedef typename detail::remove_reference<typename UnaryFunction::result_type>::type value_type;
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef operator_arrow_proxy<typename UnaryFunction::result_type> pointer;
|
||||
typedef typename UnaryFunction::result_type reference;
|
||||
|
||||
explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction())
|
||||
: members_(it, f)
|
||||
{}
|
||||
|
||||
explicit transform_iterator()
|
||||
: members_()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE Iterator get_it() const
|
||||
{ return members_.m_it; }
|
||||
|
||||
//Constructors
|
||||
BOOST_INTRUSIVE_FORCEINLINE transform_iterator& operator++()
|
||||
{ increment(); return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE transform_iterator operator++(int)
|
||||
{
|
||||
transform_iterator result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator== (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return i.equal(i2); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator!= (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE transform_iterator operator+(typename Iterator::difference_type off) const
|
||||
{
|
||||
transform_iterator other(*this);
|
||||
other.advance(off);
|
||||
return other;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend transform_iterator operator+(typename Iterator::difference_type off, const transform_iterator& right)
|
||||
{ return right + off; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE transform_iterator& operator-=(typename Iterator::difference_type off)
|
||||
{ this->advance(-off); return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE transform_iterator operator-(typename Iterator::difference_type off) const
|
||||
{ return *this + (-off); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE typename UnaryFunction::result_type operator*() const
|
||||
{ return dereference(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE operator_arrow_proxy<typename UnaryFunction::result_type>
|
||||
operator->() const
|
||||
{ return operator_arrow_proxy<typename UnaryFunction::result_type>(dereference()); }
|
||||
|
||||
private:
|
||||
struct members
|
||||
: UnaryFunction
|
||||
{
|
||||
BOOST_INTRUSIVE_FORCEINLINE members(const Iterator &it, const UnaryFunction &f)
|
||||
: UnaryFunction(f), m_it(it)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE members()
|
||||
{}
|
||||
|
||||
Iterator m_it;
|
||||
} members_;
|
||||
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void increment()
|
||||
{ ++members_.m_it; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE void decrement()
|
||||
{ --members_.m_it; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool equal(const transform_iterator &other) const
|
||||
{ return members_.m_it == other.members_.m_it; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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)
|
||||
{ boost::intrusive::iterator_advance(members_.m_it, n); }
|
||||
|
||||
typename Iterator::difference_type distance_to(const transform_iterator &other)const
|
||||
{ return boost::intrusive::iterator_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
|
||||
@@ -0,0 +1,172 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-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_TREE_ITERATOR_HPP
|
||||
#define BOOST_INTRUSIVE_TREE_ITERATOR_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/std_fwd.hpp>
|
||||
#include <boost/intrusive/detail/iiterator.hpp>
|
||||
#include <boost/intrusive/detail/bstree_algorithms_base.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Implementation of the tree iterator //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// tree_iterator provides some basic functions for a
|
||||
// node oriented bidirectional iterator:
|
||||
template<class ValueTraits, bool IsConst>
|
||||
class tree_iterator
|
||||
{
|
||||
private:
|
||||
typedef iiterator< ValueTraits, IsConst
|
||||
, std::bidirectional_iterator_tag> types_t;
|
||||
typedef typename types_t::value_traits 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;
|
||||
typedef bstree_algorithms_base<node_traits> node_algorithms;
|
||||
|
||||
static const bool stateful_value_traits = types_t::stateful_value_traits;
|
||||
|
||||
void unspecified_bool_type_func() const {}
|
||||
typedef void (tree_iterator::*unspecified_bool_type)() const;
|
||||
|
||||
public:
|
||||
typedef typename types_t::iterator_type::difference_type difference_type;
|
||||
typedef typename types_t::iterator_type::value_type value_type;
|
||||
typedef typename types_t::iterator_type::pointer pointer;
|
||||
typedef typename types_t::iterator_type::reference reference;
|
||||
typedef typename types_t::iterator_type::iterator_category iterator_category;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_iterator()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit tree_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr)
|
||||
: members_(nodeptr, traits_ptr)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_iterator(tree_iterator<value_traits, false> const& other)
|
||||
: members_(other.pointed_node(), other.get_value_traits())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const node_ptr &pointed_node() const
|
||||
{ return members_.nodeptr_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE 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;
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_left()
|
||||
{
|
||||
members_.nodeptr_ = node_traits::get_left(members_.nodeptr_);
|
||||
return static_cast<tree_iterator&> (*this);
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_right()
|
||||
{
|
||||
members_.nodeptr_ = node_traits::get_right(members_.nodeptr_);
|
||||
return static_cast<tree_iterator&> (*this);
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_parent()
|
||||
{
|
||||
members_.nodeptr_ = node_traits::get_parent(members_.nodeptr_);
|
||||
return static_cast<tree_iterator&> (*this);
|
||||
}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE operator unspecified_bool_type() const
|
||||
{ return members_.nodeptr_ ? &tree_iterator::unspecified_bool_type_func : 0; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator! () const
|
||||
{ return !members_.nodeptr_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator== (const tree_iterator& l, const tree_iterator& r)
|
||||
{ return l.pointed_node() == r.pointed_node(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE friend bool operator!= (const tree_iterator& l, const tree_iterator& r)
|
||||
{ return !(l == r); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE reference operator*() const
|
||||
{ return *operator->(); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator->() const
|
||||
{ return this->operator_arrow(detail::bool_<stateful_value_traits>()); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const_value_traits_ptr get_value_traits() const
|
||||
{ return members_.get_ptr(); }
|
||||
|
||||
tree_iterator end_iterator_from_it() const
|
||||
{
|
||||
return tree_iterator(node_algorithms::get_header(this->pointed_node()), this->get_value_traits());
|
||||
}
|
||||
|
||||
tree_iterator<value_traits, false> unconst() const
|
||||
{ return tree_iterator<value_traits, false>(this->pointed_node(), this->get_value_traits()); }
|
||||
|
||||
private:
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::false_) const
|
||||
{ return ValueTraits::to_value_ptr(members_.nodeptr_); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::true_) const
|
||||
{ return this->get_value_traits()->to_value_ptr(members_.nodeptr_); }
|
||||
|
||||
iiterator_members<node_ptr, const_value_traits_ptr, stateful_value_traits> members_;
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_TREE_ITERATOR_HPP
|
||||
@@ -0,0 +1,80 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-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_TREE_NODE_HPP
|
||||
#define BOOST_INTRUSIVE_TREE_NODE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/pointer_rebind.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
template<class VoidPointer>
|
||||
struct tree_node
|
||||
{
|
||||
typedef typename pointer_rebind<VoidPointer, tree_node>::type node_ptr;
|
||||
|
||||
node_ptr parent_, left_, right_;
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
struct tree_node_traits
|
||||
{
|
||||
typedef tree_node<VoidPointer> node;
|
||||
|
||||
typedef typename node::node_ptr node_ptr;
|
||||
typedef typename pointer_rebind<VoidPointer, const node>::type const_node_ptr;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
|
||||
{ return n->parent_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const node_ptr & n)
|
||||
{ return n->parent_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
|
||||
{ n->parent_ = p; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const node_ptr & n)
|
||||
{ return n->left_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
|
||||
{ n->left_ = l; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const node_ptr & n)
|
||||
{ return n->right_; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
|
||||
{ n->right_ = r; }
|
||||
};
|
||||
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_TREE_NODE_HPP
|
||||
@@ -0,0 +1,163 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2015-2015. Distributed under the 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_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/ebo_functor_holder.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace intrusive{
|
||||
|
||||
//Needed to support smart references to value types
|
||||
template <class From, class ValuePtr>
|
||||
struct disable_if_smartref_to
|
||||
: detail::disable_if_c
|
||||
< detail::is_same
|
||||
<From, typename pointer_traits
|
||||
<ValuePtr>
|
||||
::reference>::value
|
||||
|| detail::is_same
|
||||
<From, typename pointer_traits
|
||||
< typename pointer_rebind
|
||||
<ValuePtr, const typename pointer_element<ValuePtr>::type>::type>
|
||||
::reference>::value
|
||||
>
|
||||
{};
|
||||
|
||||
//This function object takes a KeyCompare function object
|
||||
//and compares values that contains keys using KeyOfValue
|
||||
template< class ValuePtr, class KeyCompare, class KeyOfValue
|
||||
, bool = boost::intrusive::detail::is_same<typename pointer_element<ValuePtr>::type, typename KeyOfValue::type>::value >
|
||||
struct tree_value_compare
|
||||
: public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
|
||||
{
|
||||
typedef typename pointer_element<ValuePtr>::type value_type;
|
||||
typedef KeyCompare key_compare;
|
||||
typedef KeyOfValue key_of_value;
|
||||
typedef typename KeyOfValue::type key_type;
|
||||
|
||||
typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
|
||||
: base_t()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
|
||||
: base_t(kcomp)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
|
||||
: base_t(x.base_t::get())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
|
||||
{ this->base_t::get() = x.base_t::get(); return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
|
||||
{ this->base_t::get() = x; return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
|
||||
{ return static_cast<const key_compare &>(*this); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const key_type &key1, const key_type &key2) const
|
||||
{ return this->key_comp()(key1, key2); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const value_type &value1, const value_type &value2) const
|
||||
{ return this->key_comp()(KeyOfValue()(value1), KeyOfValue()(value2)); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const key_type &key1, const value_type &value2) const
|
||||
{ return this->key_comp()(key1, KeyOfValue()(value2)); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const value_type &value1, const key_type &key2) const
|
||||
{ return this->key_comp()(KeyOfValue()(value1), key2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const key_type &key1, const U &nonkey2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(key1, nonkey2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const U &nonkey1, const key_type &key2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(nonkey1, key2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const value_type &value1, const U &nonvalue2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(KeyOfValue()(value1), nonvalue2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const U &nonvalue1, const value_type &value2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(nonvalue1, KeyOfValue()(value2)); }
|
||||
};
|
||||
|
||||
template<class ValuePtr, class KeyCompare, class KeyOfValue>
|
||||
struct tree_value_compare<ValuePtr, KeyCompare, KeyOfValue, true>
|
||||
: public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
|
||||
{
|
||||
typedef typename pointer_element<ValuePtr>::type value_type;
|
||||
typedef KeyCompare key_compare;
|
||||
typedef KeyOfValue key_of_value;
|
||||
typedef typename KeyOfValue::type key_type;
|
||||
|
||||
typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
|
||||
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
|
||||
: base_t()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
|
||||
: base_t(kcomp)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
|
||||
: base_t(x.base_t::get())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
|
||||
{ this->base_t::get() = x.base_t::get(); return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
|
||||
{ this->base_t::get() = x; return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
|
||||
{ return static_cast<const key_compare &>(*this); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const key_type &key1, const key_type &key2) const
|
||||
{ return this->key_comp()(key1, key2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const key_type &key1, const U &nonkey2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(key1, nonkey2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const U &nonkey1, const key_type &key2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(nonkey1, key2); }
|
||||
};
|
||||
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //#ifdef BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
|
||||
@@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace detail {
|
||||
|
||||
template<class ConstNodePtr>
|
||||
struct uncast_types
|
||||
{
|
||||
typedef typename pointer_traits<ConstNodePtr>::element_type element_type;
|
||||
typedef typename remove_const<element_type>::type non_const_type;
|
||||
typedef typename pointer_traits<ConstNodePtr>::
|
||||
template rebind_pointer<non_const_type>::type non_const_pointer;
|
||||
typedef pointer_traits<non_const_pointer> non_const_traits;
|
||||
};
|
||||
|
||||
template<class ConstNodePtr>
|
||||
static typename uncast_types<ConstNodePtr>::non_const_pointer
|
||||
uncast(const ConstNodePtr & ptr)
|
||||
{
|
||||
return uncast_types<ConstNodePtr>::non_const_traits::const_cast_from(ptr);
|
||||
}
|
||||
|
||||
} //namespace detail {
|
||||
} //namespace intrusive
|
||||
} //namespace boost
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP
|
||||
@@ -0,0 +1,53 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-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/interprocess for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
#include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#define BOOST_INTRUSIVE_PERFECT_FORWARDING
|
||||
#endif
|
||||
|
||||
//Macros for documentation purposes. For code, expands to the argument
|
||||
#define BOOST_INTRUSIVE_IMPDEF(TYPE) TYPE
|
||||
#define BOOST_INTRUSIVE_SEEDOC(TYPE) TYPE
|
||||
#define BOOST_INTRUSIVE_DOC1ST(TYPE1, TYPE2) TYPE2
|
||||
#define BOOST_INTRUSIVE_I ,
|
||||
#define BOOST_INTRUSIVE_DOCIGN(T1) T1
|
||||
|
||||
#define BOOST_INTRUSIVE_DISABLE_FORCEINLINE
|
||||
|
||||
#if defined(BOOST_INTRUSIVE_DISABLE_FORCEINLINE)
|
||||
#define BOOST_INTRUSIVE_FORCEINLINE inline
|
||||
#elif defined(BOOST_INTRUSIVE_FORCEINLINE_IS_BOOST_FORCELINE)
|
||||
#define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE
|
||||
#elif defined(BOOST_MSVC) && defined(_DEBUG)
|
||||
//"__forceinline" and MSVC seems to have some bugs in debug mode
|
||||
#define BOOST_INTRUSIVE_FORCEINLINE inline
|
||||
#elif defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ < 5)))
|
||||
//Older GCCs have problems with forceinline
|
||||
#define BOOST_INTRUSIVE_FORCEINLINE inline
|
||||
#else
|
||||
#define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE
|
||||
#endif
|
||||
|
||||
#endif //#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP
|
||||
Reference in New Issue
Block a user