]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/graph/include/boost/pending/indirect_cmp.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / graph / include / boost / pending / indirect_cmp.hpp
CommitLineData
7c673cae
FG
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
19namespace boost {
20
21 //: indirect_cmp
22 //
23 // could also do this with compose_f_gx_hx, and the member binder...
24 //
25 //!category: functors
26 //!component: type
27 //!tparam: ReadablePropertyMap - a model of ReadablePropertyMap
28 //!definition: functor.h
29 template <class ReadablePropertyMap, class Compare>
30 class indirect_cmp {
31 public:
32 typedef typename boost::property_traits<ReadablePropertyMap>::value_type T;
33 typedef typename boost::property_traits<ReadablePropertyMap>::key_type K;
34 typedef K first_argument_type;
35 typedef K second_argument_type;
36 typedef bool result_type;
37 inline indirect_cmp(const ReadablePropertyMap& df, const Compare& c = Compare())
38 : d(df), cmp(c) { }
39
40 template <class A, class B>
41 inline bool
42 operator()(const A& u, const B& v) const {
43 const T& du = get(d, u);
44 const T& dv = get(d, v);
45 return cmp(du, dv);
46 }
47 protected:
48 ReadablePropertyMap d;
49 Compare cmp;
50 };
51
52 template <typename Compare, typename ReadablePropertyMap>
53 indirect_cmp<ReadablePropertyMap, Compare>
54 make_indirect_cmp(const Compare& cmp, ReadablePropertyMap pmap) {
55 indirect_cmp<ReadablePropertyMap, Compare> p(pmap, cmp);
56 return p;
57 }
58
59 template <class ReadablePropertyMap>
60 class indirect_pmap {
61 public:
62 typedef typename boost::property_traits<ReadablePropertyMap>::value_type T;
63 typedef typename boost::property_traits<ReadablePropertyMap>::key_type K;
64 typedef K argument_type;
65 typedef T result_type;
66 inline indirect_pmap(const ReadablePropertyMap& df)
67 : d(df) { }
68
69 inline T operator()(const K& u) const {
70 return get(d, u);
71 }
72 protected:
73 ReadablePropertyMap d;
74 };
75
76 template <typename ReadablePropertyMap>
77 indirect_pmap<ReadablePropertyMap>
78 make_indirect_pmap(ReadablePropertyMap pmap) {
79 indirect_pmap<ReadablePropertyMap> f(pmap);
80 return f;
81 }
82
83
84} // namespace boost
85
86
87#endif // GGCL_INDIRECT_CMP_HPP