change support python version
[platform/upstream/boost.git] / boost / bimap / container_adaptor / detail / comparison_adaptor.hpp
1 // Boost.Bimap
2 //
3 // Copyright (c) 2006-2007 Matias Capeletto
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 /// \file container_adaptor/detail/comparison_adaptor.hpp
10 /// \brief Comparison adaptor.
11
12 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
13 #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
14
15 #if defined(_MSC_VER)
16 #pragma once
17 #endif
18
19 #include <boost/config.hpp>
20
21 #include <boost/call_traits.hpp>
22
23 namespace boost {
24 namespace bimaps {
25 namespace container_adaptor {
26 namespace detail {
27
28 /// \brief Comparison adaptor
29 /**
30
31 A simple comparison adaptor.
32                                                                                     **/
33
34 template < class Compare, class NewType, class Converter >
35 struct comparison_adaptor
36 {
37     typedef NewType first_argument_type;
38     typedef NewType second_argument_type;
39     typedef bool result_type;
40
41     comparison_adaptor( const Compare & comp, const Converter & conv)
42         : compare(comp), converter(conv) {}
43
44     bool operator()( BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type x,
45                      BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type y) const
46     {
47         return compare( converter(x), converter(y) );
48     }
49
50     private:
51     Compare     compare;
52     Converter   converter;
53 };
54
55 template < class Compare, class NewType, class Converter >
56 struct compatible_comparison_adaptor
57 {
58     typedef NewType first_argument_type;
59     typedef NewType second_argument_type;
60     typedef bool result_type;
61
62     compatible_comparison_adaptor( const Compare & comp, const Converter & conv)
63         : compare(comp), converter(conv) {}
64
65     template< class CompatibleTypeLeft, class CompatibleTypeRight >
66     bool operator()( const CompatibleTypeLeft  & x,
67                      const CompatibleTypeRight & y) const
68     {
69         return compare( converter(x), converter(y) );
70     }
71
72     private:
73     Compare     compare;
74     Converter   converter;
75 };
76
77
78 /// \brief Unary Check adaptor
79 /**
80
81 A simple unary check adaptor.
82                                                                                     **/
83
84 template < class Compare, class NewType, class Converter >
85 struct unary_check_adaptor
86 {
87     typedef BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type argument_type;
88     typedef bool result_type;
89
90     unary_check_adaptor( const Compare & comp, const Converter & conv ) :
91         compare(comp), converter(conv) {}
92
93     bool operator()( BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type x) const
94     {
95         return compare( converter(x) );
96     }
97
98     private:
99     Compare   compare;
100     Converter converter;
101 };
102
103 } // namespace detail
104 } // namespace container_adaptor
105 } // namespace bimaps
106 } // namespace boost
107
108
109 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
110
111