summaryrefslogtreecommitdiff
path: root/boost/intrusive/detail/key_nodeptr_comp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/intrusive/detail/key_nodeptr_comp.hpp')
-rw-r--r--boost/intrusive/detail/key_nodeptr_comp.hpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/boost/intrusive/detail/key_nodeptr_comp.hpp b/boost/intrusive/detail/key_nodeptr_comp.hpp
index 8c456634e5..df2b895db9 100644
--- a/boost/intrusive/detail/key_nodeptr_comp.hpp
+++ b/boost/intrusive/detail/key_nodeptr_comp.hpp
@@ -28,18 +28,27 @@ namespace boost {
namespace intrusive {
namespace detail {
-template<class KeyValueCompare, class ValueTraits>
+template < class KeyTypeKeyCompare
+ , class ValueTraits
+ , class KeyOfValue = void
+ >
struct key_nodeptr_comp
//Use public inheritance to avoid MSVC bugs with closures
- : public ebo_functor_holder<KeyValueCompare>
+ : public ebo_functor_holder<KeyTypeKeyCompare>
{
typedef ValueTraits value_traits;
typedef typename value_traits::value_type value_type;
typedef typename value_traits::node_ptr node_ptr;
typedef typename value_traits::const_node_ptr const_node_ptr;
- typedef ebo_functor_holder<KeyValueCompare> base_t;
-
- key_nodeptr_comp(KeyValueCompare kcomp, const ValueTraits *traits)
+ typedef ebo_functor_holder<KeyTypeKeyCompare> base_t;
+ typedef typename detail::if_c
+ < detail::is_same<KeyOfValue, void>::value
+ , detail::identity<value_type>
+ , KeyOfValue
+ >::type key_of_value;
+ typedef typename key_of_value::type key_type;
+
+ key_nodeptr_comp(KeyTypeKeyCompare kcomp, const ValueTraits *traits)
: base_t(kcomp), traits_(traits)
{}
@@ -51,12 +60,13 @@ struct key_nodeptr_comp
//key_forward
template<class T>
- const value_type & key_forward
- (const T &node, typename enable_if_c<is_node_ptr<T>::value>::type * = 0) const
- { return *traits_->to_value_ptr(node); }
+ typename enable_if<is_node_ptr<T>, const key_type &>::type
+ key_forward(const T &node) const
+ { return key_of_value()(*traits_->to_value_ptr(node)); }
template<class T>
- const T & key_forward(const T &key, typename enable_if_c<!is_node_ptr<T>::value>::type* = 0) const
+ typename disable_if<is_node_ptr<T>, const T &>::type
+ const key_forward(const T &key) const
{ return key; }
//operator() 1 arg