forked from boostorg/intrusive
[@https://svn.boost.org/trac/boost/ticket/3439 #3439], [@https://svn.boost.org/trac/boost/ticket/3846 #3846], [@https://svn.boost.org/trac/boost/ticket/3947 #3947], [@https://svn.boost.org/trac/boost/ticket/3985 #3985]. Intrusive: [@https://svn.boost.org/trac/boost/ticket/3668 #3668], [@https://svn.boost.org/trac/boost/ticket/3339 #3688], [@https://svn.boost.org/trac/boost/ticket/3698 #3698], [@https://svn.boost.org/trac/boost/ticket/3706 #3706], [@https://svn.boost.org/trac/boost/ticket/3721 #3721]. [@https://svn.boost.org/trac/boost/ticket/3729 #3729], [@https://svn.boost.org/trac/boost/ticket/3746 #3746], [@https://svn.boost.org/trac/boost/ticket/3781 #3781], [@https://svn.boost.org/trac/boost/ticket/3829 #3829], [@https://svn.boost.org/trac/boost/ticket/3840 #3840], [@https://svn.boost.org/trac/boost/ticket/3339 #3339], [@https://svn.boost.org/trac/boost/ticket/3419 #3419], [@https://svn.boost.org/trac/boost/ticket/3431 #3431], [SVN r60514]
57 lines
2.2 KiB
C++
57 lines
2.2 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// (C) Copyright Ion Gaztanaga 2006-2009
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
// See http://www.boost.org/libs/intrusive for documentation.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
|
|
#define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
|
|
|
|
#include <boost/intrusive/link_mode.hpp>
|
|
#include <iterator>
|
|
|
|
namespace boost {
|
|
namespace intrusive {
|
|
|
|
//!This value traits template is used to create value traits
|
|
//!from user defined node traits where value_traits::value_type will
|
|
//!derive from node_traits::node
|
|
template<class T, class NodeTraits, link_mode_type LinkMode = safe_link>
|
|
struct derivation_value_traits
|
|
{
|
|
public:
|
|
typedef NodeTraits node_traits;
|
|
typedef T value_type;
|
|
typedef typename node_traits::node node;
|
|
typedef typename node_traits::node_ptr node_ptr;
|
|
typedef typename node_traits::const_node_ptr const_node_ptr;
|
|
typedef typename boost::pointer_to_other<node_ptr, T>::type pointer;
|
|
typedef typename boost::pointer_to_other<node_ptr, const T>::type const_pointer;
|
|
typedef typename std::iterator_traits<pointer>::reference reference;
|
|
typedef typename std::iterator_traits<const_pointer>::reference const_reference;
|
|
static const link_mode_type link_mode = LinkMode;
|
|
|
|
static node_ptr to_node_ptr(reference value)
|
|
{ return node_ptr(&value); }
|
|
|
|
static const_node_ptr to_node_ptr(const_reference value)
|
|
{ return node_ptr(&value); }
|
|
|
|
static pointer to_value_ptr(node_ptr n)
|
|
{ return pointer(static_cast<T*>(detail::boost_intrusive_get_pointer(n))); }
|
|
|
|
static const_pointer to_value_ptr(const_node_ptr n)
|
|
{ return const_pointer(static_cast<const T*>(detail::boost_intrusive_get_pointer(n))); }
|
|
};
|
|
|
|
} //namespace intrusive
|
|
} //namespace boost
|
|
|
|
#endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
|