1 | ////////////////////////////////////////////////////////////////////////////// |
2 | // |
3 | // (C) Copyright Ion Gaztanaga 2015-2016. |
4 | // Distributed under the Boost Software License, Version 1.0. |
5 | // (See accompanying file LICENSE_1_0.txt or copy at |
6 | // http://www.boost.org/LICENSE_1_0.txt) |
7 | // |
8 | // See http://www.boost.org/libs/move for documentation. |
9 | // |
10 | ////////////////////////////////////////////////////////////////////////////// |
11 | #ifndef BOOST_MOVE_ALGO_PREDICATE_HPP |
12 | #define BOOST_MOVE_ALGO_PREDICATE_HPP |
13 | |
14 | #include <boost/move/algo/move.hpp> |
15 | #include <boost/move/adl_move_swap.hpp> |
16 | #include <boost/move/algo/detail/basic_op.hpp> |
17 | #include <boost/move/detail/iterator_traits.hpp> |
18 | #include <boost/move/detail/destruct_n.hpp> |
19 | #include <boost/assert.hpp> |
20 | |
21 | namespace boost { |
22 | namespace movelib { |
23 | |
24 | template<class Comp> |
25 | struct antistable |
26 | { |
27 | explicit antistable(Comp &comp) |
28 | : m_comp(comp) |
29 | {} |
30 | |
31 | template<class U, class V> |
32 | bool operator()(const U &u, const V & v) |
33 | { return !m_comp(v, u); } |
34 | |
35 | private: |
36 | antistable & operator=(const antistable &); |
37 | Comp &m_comp; |
38 | }; |
39 | |
40 | template <class Comp> |
41 | class negate |
42 | { |
43 | public: |
44 | negate() |
45 | {} |
46 | |
47 | explicit negate(Comp comp) |
48 | : m_comp(comp) |
49 | {} |
50 | |
51 | template <class T1, class T2> |
52 | bool operator()(const T1& l, const T2& r) |
53 | { |
54 | return !m_comp(l, r); |
55 | } |
56 | |
57 | private: |
58 | Comp m_comp; |
59 | }; |
60 | |
61 | |
62 | template <class Comp> |
63 | class inverse |
64 | { |
65 | public: |
66 | inverse() |
67 | {} |
68 | |
69 | explicit inverse(Comp comp) |
70 | : m_comp(comp) |
71 | {} |
72 | |
73 | template <class T1, class T2> |
74 | bool operator()(const T1& l, const T2& r) |
75 | { |
76 | return m_comp(r, l); |
77 | } |
78 | |
79 | private: |
80 | Comp m_comp; |
81 | }; |
82 | |
83 | } //namespace movelib { |
84 | } //namespace boost { |
85 | |
86 | #endif //#define BOOST_MOVE_ALGO_PREDICATE_HPP |
87 | |