Chris@102: ///////////////////////////////////////////////////////////////////////////// Chris@102: // Chris@102: // (C) Copyright Ion Gaztanaga 2014-2014 Chris@102: // Chris@102: // Distributed under the Boost Software License, Version 1.0. Chris@102: // (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: // See http://www.boost.org/libs/intrusive for documentation. Chris@102: // Chris@102: ///////////////////////////////////////////////////////////////////////////// Chris@102: Chris@102: #ifndef BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP Chris@102: #define BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP Chris@102: Chris@102: #ifndef BOOST_CONFIG_HPP Chris@102: # include Chris@102: #endif Chris@102: Chris@102: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost { Chris@102: namespace intrusive { Chris@102: namespace detail { Chris@102: Chris@102: template Chris@102: struct key_nodeptr_comp Chris@102: //Use public inheritance to avoid MSVC bugs with closures Chris@102: : public ebo_functor_holder Chris@102: { Chris@102: typedef ValueTraits value_traits; Chris@102: typedef typename value_traits::value_type value_type; Chris@102: typedef typename value_traits::node_ptr node_ptr; Chris@102: typedef typename value_traits::const_node_ptr const_node_ptr; Chris@102: typedef ebo_functor_holder base_t; Chris@102: Chris@102: key_nodeptr_comp(KeyValueCompare kcomp, const ValueTraits *traits) Chris@102: : base_t(kcomp), traits_(traits) Chris@102: {} Chris@102: Chris@102: template Chris@102: struct is_node_ptr Chris@102: { Chris@102: static const bool value = is_same::value || is_same::value; Chris@102: }; Chris@102: Chris@102: //key_forward Chris@102: template Chris@102: const value_type & key_forward Chris@102: (const T &node, typename enable_if_c::value>::type * = 0) const Chris@102: { return *traits_->to_value_ptr(node); } Chris@102: Chris@102: template Chris@102: const T & key_forward(const T &key, typename enable_if_c::value>::type* = 0) const Chris@102: { return key; } Chris@102: Chris@102: //operator() 1 arg Chris@102: template Chris@102: bool operator()(const KeyType &key1) const Chris@102: { return base_t::get()(this->key_forward(key1)); } Chris@102: Chris@102: template Chris@102: bool operator()(const KeyType &key1) Chris@102: { return base_t::get()(this->key_forward(key1)); } Chris@102: Chris@102: //operator() 2 arg Chris@102: template Chris@102: bool operator()(const KeyType &key1, const KeyType2 &key2) const Chris@102: { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); } Chris@102: Chris@102: template Chris@102: bool operator()(const KeyType &key1, const KeyType2 &key2) Chris@102: { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); } Chris@102: Chris@102: const ValueTraits *const traits_; Chris@102: }; Chris@102: Chris@102: } //namespace detail{ Chris@102: } //namespace intrusive{ Chris@102: } //namespace boost{ Chris@102: Chris@102: #endif //BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP