Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/intrusive/detail/key_nodeptr_comp.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga  2014-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_KEY_NODEPTR_COMP_HPP
0014 #define BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_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/mpl.hpp>
0025 #include <boost/intrusive/detail/ebo_functor_holder.hpp>
0026 #include <boost/intrusive/detail/tree_value_compare.hpp>
0027 
0028 
0029 namespace boost {
0030 namespace intrusive {
0031 namespace detail {
0032 
0033 template < class KeyTypeKeyCompare
0034          , class ValueTraits
0035          , class KeyOfValue
0036          >
0037 struct key_nodeptr_comp_types
0038 {
0039    typedef ValueTraits                                   value_traits;
0040    typedef typename value_traits::value_type             value_type;
0041    typedef typename value_traits::node_ptr               node_ptr;
0042    typedef typename value_traits::const_node_ptr         const_node_ptr;
0043    typedef typename detail::if_c
0044             < detail::is_same<KeyOfValue, void>::value
0045             , detail::identity<value_type>
0046             , KeyOfValue
0047             >::type                                      key_of_value;
0048    typedef tree_value_compare
0049       <typename ValueTraits::pointer, KeyTypeKeyCompare, key_of_value>      base_t;
0050 };
0051 
0052 //This function object transforms a key comparison type to
0053 //a function that can compare nodes or nodes with nodes or keys.
0054 template < class KeyTypeKeyCompare
0055          , class ValueTraits
0056          , class KeyOfValue = void
0057          >
0058 struct key_nodeptr_comp
0059    //Use public inheritance to avoid MSVC bugs with closures
0060    :  public key_nodeptr_comp_types<KeyTypeKeyCompare, ValueTraits, KeyOfValue>::base_t
0061 {
0062 private:
0063    struct sfinae_type;
0064 
0065 public:
0066    typedef key_nodeptr_comp_types<KeyTypeKeyCompare, ValueTraits, KeyOfValue> types_t;
0067    typedef typename types_t::value_traits          value_traits;
0068    typedef typename types_t::value_type            value_type;
0069    typedef typename types_t::node_ptr              node_ptr;
0070    typedef typename types_t::const_node_ptr        const_node_ptr;
0071    typedef typename types_t::base_t                base_t;
0072    typedef typename types_t::key_of_value          key_of_value;
0073 
0074    template <class P1>
0075    struct is_same_or_nodeptr_convertible
0076    {
0077       static const bool same_type = is_same<P1,const_node_ptr>::value || is_same<P1,node_ptr>::value;
0078       static const bool value = same_type || is_convertible<P1, const_node_ptr>::value;
0079    };
0080 
0081    inline base_t base() const
0082    {  return static_cast<const base_t&>(*this); }
0083 
0084    inline key_nodeptr_comp(KeyTypeKeyCompare kcomp, const ValueTraits *traits)
0085       :  base_t(kcomp), traits_(traits)
0086    {}
0087 
0088    //pred(pnode)
0089    template<class T1>
0090    inline bool operator()(const T1 &t1, typename enable_if_c< is_same_or_nodeptr_convertible<T1>::value, sfinae_type* >::type = 0) const
0091    {  return base().get()(key_of_value()(*traits_->to_value_ptr(t1)));  }
0092 
0093    //operator() 2 arg
0094    //pred(pnode, pnode)
0095    template<class T1, class T2>
0096    inline bool operator()
0097       (const T1 &t1, const T2 &t2, typename enable_if_c< is_same_or_nodeptr_convertible<T1>::value && is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
0098    {  return base()(*traits_->to_value_ptr(t1), *traits_->to_value_ptr(t2));  }
0099 
0100    //pred(pnode, key)
0101    template<class T1, class T2>
0102    inline bool operator()
0103       (const T1 &t1, const T2 &t2, typename enable_if_c< is_same_or_nodeptr_convertible<T1>::value && !is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
0104    {  return base()(*traits_->to_value_ptr(t1), t2);  }
0105 
0106    //pred(key, pnode)
0107    template<class T1, class T2>
0108    inline bool operator()
0109       (const T1 &t1, const T2 &t2, typename enable_if_c< !is_same_or_nodeptr_convertible<T1>::value && is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
0110    {  return base()(t1, *traits_->to_value_ptr(t2));  }
0111 
0112    //pred(key, key)
0113    template<class T1, class T2>
0114    inline bool operator()
0115       (const T1 &t1, const T2 &t2, typename enable_if_c< !is_same_or_nodeptr_convertible<T1>::value && !is_same_or_nodeptr_convertible<T2>::value, sfinae_type* >::type = 0) const
0116    {  return base()(t1, t2);  }
0117 
0118    const ValueTraits *const traits_;
0119 };
0120 
0121 }  //namespace detail{
0122 }  //namespace intrusive{
0123 }  //namespace boost{
0124 
0125 #endif //BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP