Chris@102
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@102
|
2 //
|
Chris@102
|
3 // (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost
|
Chris@102
|
4 // Software License, Version 1.0. (See accompanying file
|
Chris@102
|
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
6 //
|
Chris@102
|
7 // See http://www.boost.org/libs/container for documentation.
|
Chris@102
|
8 //
|
Chris@102
|
9 ///////////////////////////////////////////////////////////////////////////////
|
Chris@102
|
10
|
Chris@102
|
11 #ifndef BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP
|
Chris@102
|
12 #define BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP
|
Chris@102
|
13
|
Chris@102
|
14 #ifndef BOOST_CONFIG_HPP
|
Chris@102
|
15 # include <boost/config.hpp>
|
Chris@102
|
16 #endif
|
Chris@102
|
17
|
Chris@102
|
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@102
|
19 # pragma once
|
Chris@102
|
20 #endif
|
Chris@102
|
21
|
Chris@102
|
22 namespace boost {
|
Chris@102
|
23 namespace container {
|
Chris@102
|
24
|
Chris@102
|
25 template<class Allocator>
|
Chris@102
|
26 class equal_to_value
|
Chris@102
|
27 {
|
Chris@102
|
28 typedef typename Allocator::value_type value_type;
|
Chris@102
|
29 const value_type &t_;
|
Chris@102
|
30
|
Chris@102
|
31 public:
|
Chris@102
|
32 explicit equal_to_value(const value_type &t)
|
Chris@102
|
33 : t_(t)
|
Chris@102
|
34 {}
|
Chris@102
|
35
|
Chris@102
|
36 bool operator()(const value_type &t)const
|
Chris@102
|
37 { return t_ == t; }
|
Chris@102
|
38 };
|
Chris@102
|
39
|
Chris@102
|
40 template<class Node, class Pred>
|
Chris@102
|
41 struct value_to_node_compare
|
Chris@102
|
42 : Pred
|
Chris@102
|
43 {
|
Chris@102
|
44 typedef Pred predicate_type;
|
Chris@102
|
45 typedef Node node_type;
|
Chris@102
|
46
|
Chris@102
|
47 value_to_node_compare()
|
Chris@102
|
48 : Pred()
|
Chris@102
|
49 {}
|
Chris@102
|
50
|
Chris@102
|
51 explicit value_to_node_compare(Pred pred)
|
Chris@102
|
52 : Pred(pred)
|
Chris@102
|
53 {}
|
Chris@102
|
54
|
Chris@102
|
55 bool operator()(const Node &a, const Node &b) const
|
Chris@102
|
56 { return static_cast<const Pred&>(*this)(a.m_data, b.m_data); }
|
Chris@102
|
57
|
Chris@102
|
58 bool operator()(const Node &a) const
|
Chris@102
|
59 { return static_cast<const Pred&>(*this)(a.m_data); }
|
Chris@102
|
60
|
Chris@102
|
61 bool operator()(const Node &a, const Node &b)
|
Chris@102
|
62 { return static_cast<Pred&>(*this)(a.m_data, b.m_data); }
|
Chris@102
|
63
|
Chris@102
|
64 bool operator()(const Node &a)
|
Chris@102
|
65 { return static_cast<Pred&>(*this)(a.m_data); }
|
Chris@102
|
66
|
Chris@102
|
67 predicate_type & predicate() { return static_cast<predicate_type&>(*this); }
|
Chris@102
|
68 const predicate_type & predicate() const { return static_cast<predicate_type&>(*this); }
|
Chris@102
|
69 };
|
Chris@102
|
70
|
Chris@102
|
71 } //namespace container {
|
Chris@102
|
72 } //namespace boost {
|
Chris@102
|
73
|
Chris@102
|
74 #endif //BOOST_CONTAINER_DETAIL_COMPARE_FUNCTORS_HPP
|