2 //=======================================================================
3 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
4 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
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 //=======================================================================
12 #ifndef BOOST_INDIRECT_CMP_HPP
13 #define BOOST_INDIRECT_CMP_HPP
16 #include <boost/config.hpp>
17 #include <boost/property_map/property_map.hpp>
24 // could also do this with compose_f_gx_hx, and the member binder...
26 //! category: functors
28 //! tparam: ReadablePropertyMap - a model of ReadablePropertyMap
29 //! definition: functor.h
30 template < class ReadablePropertyMap, class Compare > class indirect_cmp
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;
40 const ReadablePropertyMap& df, const Compare& c = Compare())
45 template < class A, class B >
46 inline bool operator()(const A& u, const B& v) const
48 const T& du = get(d, u);
49 const T& dv = get(d, v);
54 ReadablePropertyMap d;
58 template < typename Compare, typename ReadablePropertyMap >
59 indirect_cmp< ReadablePropertyMap, Compare > make_indirect_cmp(
60 const Compare& cmp, ReadablePropertyMap pmap)
62 indirect_cmp< ReadablePropertyMap, Compare > p(pmap, cmp);
66 template < class ReadablePropertyMap > class indirect_pmap
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) {}
76 inline T operator()(const K& u) const { return get(d, u); }
79 ReadablePropertyMap d;
82 template < typename ReadablePropertyMap >
83 indirect_pmap< ReadablePropertyMap > make_indirect_pmap(
84 ReadablePropertyMap pmap)
86 indirect_pmap< ReadablePropertyMap > f(pmap);
92 #endif // GGCL_INDIRECT_CMP_HPP