summaryrefslogtreecommitdiff
path: root/boost/intrusive/detail/default_header_holder.hpp
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/intrusive/detail/default_header_holder.hpp
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/intrusive/detail/default_header_holder.hpp')
-rw-r--r--boost/intrusive/detail/default_header_holder.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/boost/intrusive/detail/default_header_holder.hpp b/boost/intrusive/detail/default_header_holder.hpp
new file mode 100644
index 0000000000..c471691640
--- /dev/null
+++ b/boost/intrusive/detail/default_header_holder.hpp
@@ -0,0 +1,65 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (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
+
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
+#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() {}
+
+ const_node_ptr get_node() const
+ { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); }
+
+ node_ptr get_node()
+ { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); }
+
+ // (unsafe) downcast used to implement container-from-iterator
+ 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 Value_Traits, typename HeaderHolder >
+struct get_header_holder_type
+{
+ typedef HeaderHolder type;
+};
+template < typename Value_Traits >
+struct get_header_holder_type< Value_Traits, void >
+{
+ typedef default_header_holder< typename Value_Traits::node_traits > type;
+};
+
+} //namespace detail
+} //namespace intrusive
+} //namespace boost
+
+#endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP