Chris@16: ///////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2006-2013 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/intrusive for documentation. Chris@16: // Chris@16: ///////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP Chris@16: #define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP Chris@16: Chris@101: #include Chris@101: #include Chris@16: #include Chris@101: #include Chris@101: Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@101: # pragma once Chris@101: #endif Chris@16: Chris@16: namespace boost { Chris@16: namespace intrusive { Chris@16: Chris@16: //!This value traits template is used to create value traits Chris@16: //!from user defined node traits where value_traits::value_type will Chris@16: //!derive from node_traits::node Chris@101: Chris@101: template Chris@16: struct derivation_value_traits Chris@16: { Chris@16: public: Chris@16: typedef NodeTraits node_traits; Chris@16: typedef T value_type; Chris@16: typedef typename node_traits::node node; Chris@16: typedef typename node_traits::node_ptr node_ptr; Chris@16: typedef typename node_traits::const_node_ptr const_node_ptr; Chris@101: typedef typename pointer_traits:: Chris@101: template rebind_pointer::type pointer; Chris@101: typedef typename pointer_traits:: Chris@101: template rebind_pointer::type const_pointer; Chris@16: typedef typename boost::intrusive:: Chris@16: pointer_traits::reference reference; Chris@16: typedef typename boost::intrusive:: Chris@16: pointer_traits::reference const_reference; Chris@16: static const link_mode_type link_mode = LinkMode; Chris@16: Chris@16: static node_ptr to_node_ptr(reference value) Chris@16: { return node_ptr(&value); } Chris@16: Chris@16: static const_node_ptr to_node_ptr(const_reference value) Chris@16: { return node_ptr(&value); } Chris@16: Chris@16: static pointer to_value_ptr(const node_ptr &n) Chris@16: { Chris@101: return pointer_traits::pointer_to(static_cast(*n)); Chris@16: } Chris@16: Chris@16: static const_pointer to_value_ptr(const const_node_ptr &n) Chris@16: { Chris@101: return pointer_traits::pointer_to(static_cast(*n)); Chris@16: } Chris@16: }; Chris@16: Chris@16: } //namespace intrusive Chris@16: } //namespace boost Chris@16: Chris@101: #include Chris@101: Chris@16: #endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP