Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70659 - trunk/boost/intrusive/detail
From: igaztanaga_at_[hidden]
Date: 2011-03-28 04:50:37


Author: igaztanaga
Date: 2011-03-28 04:50:35 EDT (Mon, 28 Mar 2011)
New Revision: 70659
URL: http://svn.boost.org/trac/boost/changeset/70659

Log:
Fixes when using pointers as key_type
Text files modified:
   trunk/boost/intrusive/detail/utilities.hpp | 39 ++++++++++++++++++++-------------------
   1 files changed, 20 insertions(+), 19 deletions(-)

Modified: trunk/boost/intrusive/detail/utilities.hpp
==============================================================================
--- trunk/boost/intrusive/detail/utilities.hpp (original)
+++ trunk/boost/intrusive/detail/utilities.hpp 2011-03-28 04:50:35 EDT (Mon, 28 Mar 2011)
@@ -207,32 +207,33 @@
    : private detail::ebo_functor_holder<KeyValueCompare>
 {
    typedef typename Container::real_value_traits real_value_traits;
+ typedef typename Container::value_type value_type;
    typedef typename real_value_traits::node_ptr node_ptr;
    typedef typename real_value_traits::const_node_ptr const_node_ptr;
    typedef detail::ebo_functor_holder<KeyValueCompare> base_t;
    key_nodeptr_comp(KeyValueCompare kcomp, const Container *cont)
       : base_t(kcomp), cont_(cont)
    {}
+
+ template<class T>
+ struct is_node_ptr
+ {
+ static const bool value = is_same<T, const_node_ptr>::value || is_same<T, node_ptr>::value;
+ };
 
- template<class KeyType>
- bool operator()( const_node_ptr node, const KeyType &key
- , typename enable_if_c
- <!is_convertible<KeyType, const_node_ptr>::value>::type * = 0) const
- { return base_t::get()(*cont_->get_real_value_traits().to_value_ptr(node), key); }
-
- template<class KeyType>
- bool operator()(const KeyType &key, const_node_ptr node
- , typename enable_if_c
- <!is_convertible<KeyType, const_node_ptr>::value>::type * = 0) const
- { return base_t::get()(key, *cont_->get_real_value_traits().to_value_ptr(node)); }
-
- bool operator()(const_node_ptr node1, const_node_ptr node2) const
- {
- return base_t::get()
- ( *cont_->get_real_value_traits().to_value_ptr(node1)
- , *cont_->get_real_value_traits().to_value_ptr(node2)
- );
- }
+ template<class T>
+ typename enable_if_c<is_node_ptr<T>::value, const value_type &>::type
+ key_forward(const T &node) const
+ { return *cont_->get_real_value_traits().to_value_ptr(node); }
+
+ template<class T>
+ typename enable_if_c<!is_node_ptr<T>::value, const T &>::type
+ key_forward(const T &key) const
+ { return key;}
+
+ template<class KeyType, class KeyType2>
+ bool operator()(const KeyType &key1, const KeyType2 &key2) const
+ { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); }
 
    const Container *cont_;
 };


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk