///////////////////////////////////////////////////////////////////////////// // // (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_DERIVATION_VALUE_TRAITS_HPP #define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP #include #include #include #include #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif 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 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 pointer_traits:: template rebind_pointer::type pointer; typedef typename pointer_traits:: template rebind_pointer::type const_pointer; typedef typename boost::intrusive:: pointer_traits::reference reference; typedef typename boost::intrusive:: pointer_traits::reference const_reference; static const link_mode_type link_mode = LinkMode; BOOST_INTRUSIVE_FORCEINLINE static node_ptr to_node_ptr(reference value) BOOST_NOEXCEPT { return node_ptr(&value); } BOOST_INTRUSIVE_FORCEINLINE static const_node_ptr to_node_ptr(const_reference value) BOOST_NOEXCEPT { return node_ptr(&value); } BOOST_INTRUSIVE_FORCEINLINE static pointer to_value_ptr(node_ptr n) BOOST_NOEXCEPT { return pointer_traits::pointer_to(static_cast(*n)); } BOOST_INTRUSIVE_FORCEINLINE static const_pointer to_value_ptr(const_node_ptr n) BOOST_NOEXCEPT { return pointer_traits::pointer_to(static_cast(*n)); } }; } //namespace intrusive } //namespace boost #include #endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP