/////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/container for documentation. // /////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP #define BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP #ifndef BOOST_CONFIG_HPP # include #endif #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include namespace boost { namespace container { template class equal_to_value { typedef ValueType value_type; const value_type &t_; public: inline explicit equal_to_value(const value_type &t) : t_(t) {} inline bool operator()(const value_type &t)const { return t_ == t; } }; template struct value_to_node_compare : Pred { typedef Pred predicate_type; typedef Node node_type; inline value_to_node_compare() : Pred() {} inline explicit value_to_node_compare(Pred pred) : Pred(pred) {} inline Ret operator()(const Node &a, const Node &b) const { return static_cast(*this)(a.get_data(), b.get_data()); } inline Ret operator()(const Node &a) const { return static_cast(*this)(a.get_data()); } inline Ret operator()(const Node &a, const Node &b) { return static_cast(*this)(a.get_data(), b.get_data()); } inline Ret operator()(const Node &a) { return static_cast(*this)(a.get_data()); } inline predicate_type & predicate() { return static_cast(*this); } inline const predicate_type & predicate() const { return static_cast(*this); } }; template struct key_node_pred : public boost::intrusive::detail::ebo_functor_holder { inline explicit key_node_pred(const KeyPred &comp) : base_t(comp) {} inline explicit key_node_pred() {} typedef boost::intrusive::detail::ebo_functor_holder base_t; typedef KeyPred key_predicate; typedef KeyOfValue key_of_value; typedef typename KeyOfValue::type key_type; inline static const key_type &key_from(const Node &n) { return key_of_value()(n.get_data()); } template inline static const T & key_from(const T &t) { return t; } inline const key_predicate &key_pred() const { return static_cast(*this); } inline key_predicate &key_pred() { return static_cast(*this); } inline Ret operator()(const key_type &key) const { return this->key_pred()(key); } template inline Ret operator()(const U &nonkey) const { return this->key_pred()(this->key_from(nonkey)); } inline bool operator()(const key_type &key1, const key_type &key2) const { return this->key_pred()(key1, key2); } template inline bool operator()(const key_type &key1, const U &nonkey2) const { return this->key_pred()(key1, this->key_from(nonkey2)); } template inline bool operator()(const U &nonkey1, const key_type &key2) const { return this->key_pred()(this->key_from(nonkey1), key2); } template inline bool operator()(const U &nonkey1, const V &nonkey2) const { return this->key_pred()(this->key_from(nonkey1), this->key_from(nonkey2)); } }; } //namespace container { } //namespace boost { #endif //BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP