Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-02 08:15:41

0001 /////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga  2006-2014
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // See http://www.boost.org/libs/intrusive for documentation.
0010 //
0011 /////////////////////////////////////////////////////////////////////////////
0012 
0013 #ifndef BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP
0014 #define BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP
0015 
0016 #ifndef BOOST_CONFIG_HPP
0017 #  include <boost/config.hpp>
0018 #endif
0019 
0020 #if defined(BOOST_HAS_PRAGMA_ONCE)
0021 #  pragma once
0022 #endif
0023 
0024 #include <boost/intrusive/detail/workaround.hpp>
0025 #include <boost/intrusive/pointer_traits.hpp>
0026 #include <boost/intrusive/detail/parent_from_member.hpp>
0027 #include <boost/intrusive/link_mode.hpp>
0028 #include <boost/intrusive/detail/mpl.hpp>
0029 #include <boost/move/detail/to_raw_pointer.hpp>
0030 #include <boost/intrusive/detail/node_holder.hpp>
0031 
0032 namespace boost {
0033 namespace intrusive {
0034 
0035 template<class T, class NodePtr, class Tag, unsigned int Type>
0036 struct bhtraits_base
0037 {
0038    public:
0039    typedef NodePtr                                                   node_ptr;
0040    typedef typename pointer_traits<node_ptr>::element_type           node;
0041    typedef node_holder<node, Tag, Type>                              node_holder_type;
0042    typedef T                                                         value_type;
0043    typedef typename pointer_traits<node_ptr>::
0044       template rebind_pointer<const node>::type                      const_node_ptr;
0045    typedef typename pointer_traits<node_ptr>::
0046       template rebind_pointer<T>::type                               pointer;
0047    typedef typename pointer_traits<node_ptr>::
0048       template rebind_pointer<const T>::type                         const_pointer;
0049    typedef typename pointer_traits<node_ptr>::
0050       template rebind_pointer<node_holder_type>::type                node_holder_ptr;
0051    typedef typename pointer_traits<node_ptr>::
0052       template rebind_pointer<const node_holder_type>::type          const_node_holder_ptr;
0053    typedef T &                                                       reference;
0054    typedef const T &                                                 const_reference;
0055    typedef node_holder_type &                                        node_holder_reference;
0056    typedef const node_holder_type &                                  const_node_holder_reference;
0057    typedef node&                                                     node_reference;
0058    typedef const node &                                              const_node_reference;
0059 
0060    inline static pointer to_value_ptr(node_ptr n)
0061    {
0062       return pointer_traits<pointer>::
0063          static_cast_from(pointer_traits<node_holder_ptr>::static_cast_from(n));
0064    }
0065 
0066    inline static const_pointer to_value_ptr(const_node_ptr n)
0067    {
0068       return pointer_traits<const_pointer>::
0069          static_cast_from(pointer_traits<const_node_holder_ptr>::static_cast_from(n));
0070    }
0071 
0072    inline static node_ptr to_node_ptr(reference value)
0073    {
0074       node_ptr p = pointer_traits<node_ptr>::pointer_to
0075          (static_cast<node_reference>(static_cast<node_holder_reference>(value)));
0076       return p;
0077    }
0078 
0079    inline static const_node_ptr to_node_ptr(const_reference value)
0080    {
0081       const_node_ptr p = pointer_traits<const_node_ptr>::pointer_to
0082          (static_cast<const_node_reference>(static_cast<const_node_holder_reference>(value)));
0083       return p;
0084    }
0085 };
0086 
0087 template<class T, class NodeTraits, link_mode_type LinkMode, class Tag, unsigned int Type>
0088 struct bhtraits
0089    : public bhtraits_base<T, typename NodeTraits::node_ptr, Tag, Type>
0090 {
0091    static const link_mode_type link_mode = LinkMode;
0092    typedef NodeTraits node_traits;
0093 };
0094 
0095 
0096 template<class T, class Hook, Hook T::* P>
0097 struct mhtraits
0098 {
0099    public:
0100    typedef Hook                                                      hook_type;
0101    typedef typename hook_type::hooktags::node_traits                 node_traits;
0102    typedef typename node_traits::node                                node;
0103    typedef T                                                         value_type;
0104    typedef typename node_traits::node_ptr                            node_ptr;
0105    typedef typename node_traits::const_node_ptr                      const_node_ptr;
0106    typedef typename pointer_traits<node_ptr>::
0107       template rebind_pointer<T>::type                               pointer;
0108    typedef typename pointer_traits<node_ptr>::
0109       template rebind_pointer<const T>::type                         const_pointer;
0110    typedef T &                                                       reference;
0111    typedef const T &                                                 const_reference;
0112    typedef node&                                                     node_reference;
0113    typedef const node &                                              const_node_reference;
0114    typedef hook_type&                                                hook_reference;
0115    typedef const hook_type &                                         const_hook_reference;
0116 
0117    static const link_mode_type link_mode = Hook::hooktags::link_mode;
0118 
0119    inline static node_ptr to_node_ptr(reference value)
0120    {
0121       return pointer_traits<node_ptr>::pointer_to
0122          (static_cast<node_reference>(static_cast<hook_reference>(value.*P)));
0123    }
0124 
0125    inline static const_node_ptr to_node_ptr(const_reference value)
0126    {
0127       return pointer_traits<const_node_ptr>::pointer_to
0128          (static_cast<const_node_reference>(static_cast<const_hook_reference>(value.*P)));
0129    }
0130 
0131    inline static pointer to_value_ptr(node_ptr n)
0132    {
0133       return pointer_traits<pointer>::pointer_to
0134          (*detail::parent_from_member<T, Hook>
0135             (static_cast<Hook*>(boost::movelib::to_raw_pointer(n)), P));
0136    }
0137 
0138    inline static const_pointer to_value_ptr(const_node_ptr n)
0139    {
0140       return pointer_traits<const_pointer>::pointer_to
0141          (*detail::parent_from_member<T, Hook>
0142             (static_cast<const Hook*>(boost::movelib::to_raw_pointer(n)), P));
0143    }
0144 };
0145 
0146 
0147 template<class Functor>
0148 struct fhtraits
0149 {
0150    public:
0151    typedef typename Functor::hook_type                               hook_type;
0152    typedef typename Functor::hook_ptr                                hook_ptr;
0153    typedef typename Functor::const_hook_ptr                          const_hook_ptr;
0154    typedef typename hook_type::hooktags::node_traits                 node_traits;
0155    typedef typename node_traits::node                                node;
0156    typedef typename Functor::value_type                              value_type;
0157    typedef typename node_traits::node_ptr                            node_ptr;
0158    typedef typename node_traits::const_node_ptr                      const_node_ptr;
0159    typedef typename pointer_traits<node_ptr>::
0160       template rebind_pointer<value_type>::type                      pointer;
0161    typedef typename pointer_traits<node_ptr>::
0162       template rebind_pointer<const value_type>::type                const_pointer;
0163    typedef value_type &                                              reference;
0164    typedef const value_type &                                        const_reference;
0165    static const link_mode_type link_mode = hook_type::hooktags::link_mode;
0166 
0167    inline static node_ptr to_node_ptr(reference value)
0168    {  return static_cast<node*>(boost::movelib::to_raw_pointer(Functor::to_hook_ptr(value)));  }
0169 
0170    inline static const_node_ptr to_node_ptr(const_reference value)
0171    {  return static_cast<const node*>(boost::movelib::to_raw_pointer(Functor::to_hook_ptr(value)));  }
0172 
0173    inline static pointer to_value_ptr(node_ptr n)
0174    {  return Functor::to_value_ptr(to_hook_ptr(n));  }
0175 
0176    inline static const_pointer to_value_ptr(const_node_ptr n)
0177    {  return Functor::to_value_ptr(to_hook_ptr(n));  }
0178 
0179    private:
0180    inline static hook_ptr to_hook_ptr(node_ptr n)
0181    {  return hook_ptr(&*static_cast<hook_type*>(&*n));  }
0182 
0183    inline static const_hook_ptr to_hook_ptr(const_node_ptr n)
0184    {  return const_hook_ptr(&*static_cast<const hook_type*>(&*n));  }
0185 };
0186 
0187 
0188 } //namespace intrusive
0189 } //namespace boost
0190 
0191 #endif //BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP