Chris@102: ///////////////////////////////////////////////////////////////////////////// Chris@102: // Chris@102: // (C) Copyright Ion Gaztanaga 2014-2014 Chris@102: // Chris@102: // Distributed under the Boost Software License, Version 1.0. Chris@102: // (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: // See http://www.boost.org/libs/intrusive for documentation. Chris@102: // Chris@102: ///////////////////////////////////////////////////////////////////////////// Chris@102: Chris@102: #ifndef BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP Chris@102: #define BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP Chris@102: Chris@102: #ifndef BOOST_CONFIG_HPP Chris@102: # include Chris@102: #endif Chris@102: Chris@102: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost { Chris@102: namespace intrusive { Chris@102: namespace detail { Chris@102: Chris@102: // trivial header node holder Chris@102: template < typename NodeTraits > Chris@102: struct default_header_holder : public NodeTraits::node Chris@102: { Chris@102: typedef NodeTraits node_traits; Chris@102: typedef typename node_traits::node node; Chris@102: typedef typename node_traits::node_ptr node_ptr; Chris@102: typedef typename node_traits::const_node_ptr const_node_ptr; Chris@102: Chris@102: default_header_holder() : node() {} Chris@102: Chris@102: const_node_ptr get_node() const Chris@102: { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); } Chris@102: Chris@102: node_ptr get_node() Chris@102: { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); } Chris@102: Chris@102: // (unsafe) downcast used to implement container-from-iterator Chris@102: static default_header_holder* get_holder(const node_ptr &p) Chris@102: { return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); } Chris@102: }; Chris@102: Chris@102: // type function producing the header node holder Chris@102: template < typename Value_Traits, typename HeaderHolder > Chris@102: struct get_header_holder_type Chris@102: { Chris@102: typedef HeaderHolder type; Chris@102: }; Chris@102: template < typename Value_Traits > Chris@102: struct get_header_holder_type< Value_Traits, void > Chris@102: { Chris@102: typedef default_header_holder< typename Value_Traits::node_traits > type; Chris@102: }; Chris@102: Chris@102: } //namespace detail Chris@102: } //namespace intrusive Chris@102: } //namespace boost Chris@102: Chris@102: #endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP