]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/pending/indirect_cmp.hpp
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / boost / pending / indirect_cmp.hpp
1 //
2 //=======================================================================
3 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
4 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
5 //
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //=======================================================================
10 //
11
12 #ifndef BOOST_INDIRECT_CMP_HPP
13 #define BOOST_INDIRECT_CMP_HPP
14
15 #include <functional>
16 #include <boost/config.hpp>
17 #include <boost/property_map/property_map.hpp>
18
19 namespace boost
20 {
21
22 //: indirect_cmp
23 //
24 // could also do this with compose_f_gx_hx, and the member binder...
25 //
26 //! category: functors
27 //! component: type
28 //! tparam: ReadablePropertyMap - a model of ReadablePropertyMap
29 //! definition: functor.h
30 template < class ReadablePropertyMap, class Compare > class indirect_cmp
31 {
32 public:
33 typedef
34 typename boost::property_traits< ReadablePropertyMap >::value_type T;
35 typedef typename boost::property_traits< ReadablePropertyMap >::key_type K;
36 typedef K first_argument_type;
37 typedef K second_argument_type;
38 typedef bool result_type;
39 inline indirect_cmp(
40 const ReadablePropertyMap& df, const Compare& c = Compare())
41 : d(df), cmp(c)
42 {
43 }
44
45 template < class A, class B >
46 inline bool operator()(const A& u, const B& v) const
47 {
48 const T& du = get(d, u);
49 const T& dv = get(d, v);
50 return cmp(du, dv);
51 }
52
53 protected:
54 ReadablePropertyMap d;
55 Compare cmp;
56 };
57
58 template < typename Compare, typename ReadablePropertyMap >
59 indirect_cmp< ReadablePropertyMap, Compare > make_indirect_cmp(
60 const Compare& cmp, ReadablePropertyMap pmap)
61 {
62 indirect_cmp< ReadablePropertyMap, Compare > p(pmap, cmp);
63 return p;
64 }
65
66 template < class ReadablePropertyMap > class indirect_pmap
67 {
68 public:
69 typedef
70 typename boost::property_traits< ReadablePropertyMap >::value_type T;
71 typedef typename boost::property_traits< ReadablePropertyMap >::key_type K;
72 typedef K argument_type;
73 typedef T result_type;
74 inline indirect_pmap(const ReadablePropertyMap& df) : d(df) {}
75
76 inline T operator()(const K& u) const { return get(d, u); }
77
78 protected:
79 ReadablePropertyMap d;
80 };
81
82 template < typename ReadablePropertyMap >
83 indirect_pmap< ReadablePropertyMap > make_indirect_pmap(
84 ReadablePropertyMap pmap)
85 {
86 indirect_pmap< ReadablePropertyMap > f(pmap);
87 return f;
88 }
89
90 } // namespace boost
91
92 #endif // GGCL_INDIRECT_CMP_HPP