fix doc example typo
[boost.git] / boost / intrusive / derivation_value_traits.hpp
blob58467d5589caf6d014c09f21124307cc47be8df0
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2006-2008
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // See http://www.boost.org/libs/intrusive for documentation.
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
14 #define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
16 #include <boost/intrusive/link_mode.hpp>
17 #include <iterator>
19 namespace boost {
20 namespace intrusive {
22 //!This value traits template is used to create value traits
23 //!from user defined node traits where value_traits::value_type will
24 //!derive from node_traits::node
25 template<class T, class NodeTraits, link_mode_type LinkMode = safe_link>
26 struct derivation_value_traits
28 public:
29 typedef NodeTraits node_traits;
30 typedef T value_type;
31 typedef typename node_traits::node node;
32 typedef typename node_traits::node_ptr node_ptr;
33 typedef typename node_traits::const_node_ptr const_node_ptr;
34 typedef typename boost::pointer_to_other<node_ptr, T>::type pointer;
35 typedef typename boost::pointer_to_other<node_ptr, const T>::type const_pointer;
36 typedef typename std::iterator_traits<pointer>::reference reference;
37 typedef typename std::iterator_traits<const_pointer>::reference const_reference;
38 static const link_mode_type link_mode = LinkMode;
40 static node_ptr to_node_ptr(reference value)
41 { return node_ptr(&value); }
43 static const_node_ptr to_node_ptr(const_reference value)
44 { return node_ptr(&value); }
46 static pointer to_value_ptr(node_ptr n)
47 { return pointer(static_cast<T*>(detail::get_pointer(n))); }
49 static const_pointer to_value_ptr(const_node_ptr n)
50 { return const_pointer(static_cast<T*>(detail::get_pointer(n))); }
53 } //namespace intrusive
54 } //namespace boost
56 #endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP