Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:31

0001 //
0002 //=======================================================================
0003 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
0004 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
0005 //
0006 // Distributed under the Boost Software License, Version 1.0. (See
0007 // accompanying file LICENSE_1_0.txt or copy at
0008 // http://www.boost.org/LICENSE_1_0.txt)
0009 //=======================================================================
0010 //
0011 
0012 #ifndef BOOST_INDIRECT_CMP_HPP
0013 #define BOOST_INDIRECT_CMP_HPP
0014 
0015 #include <functional>
0016 #include <boost/config.hpp>
0017 #include <boost/property_map/property_map.hpp>
0018 
0019 namespace boost
0020 {
0021 
0022 //: indirect_cmp
0023 //
0024 // could also do this with compose_f_gx_hx, and the member binder...
0025 //
0026 //! category: functors
0027 //! component: type
0028 //! tparam: ReadablePropertyMap - a model of ReadablePropertyMap
0029 //! definition: functor.h
0030 template < class ReadablePropertyMap, class Compare > class indirect_cmp
0031 {
0032 public:
0033     typedef
0034         typename boost::property_traits< ReadablePropertyMap >::value_type T;
0035     typedef typename boost::property_traits< ReadablePropertyMap >::key_type K;
0036     typedef K first_argument_type;
0037     typedef K second_argument_type;
0038     typedef bool result_type;
0039     inline indirect_cmp(
0040         const ReadablePropertyMap& df, const Compare& c = Compare())
0041     : d(df), cmp(c)
0042     {
0043     }
0044 
0045     template < class A, class B >
0046     inline bool operator()(const A& u, const B& v) const
0047     {
0048         const T& du = get(d, u);
0049         const T& dv = get(d, v);
0050         return cmp(du, dv);
0051     }
0052 
0053 protected:
0054     ReadablePropertyMap d;
0055     Compare cmp;
0056 };
0057 
0058 template < typename Compare, typename ReadablePropertyMap >
0059 indirect_cmp< ReadablePropertyMap, Compare > make_indirect_cmp(
0060     const Compare& cmp, ReadablePropertyMap pmap)
0061 {
0062     indirect_cmp< ReadablePropertyMap, Compare > p(pmap, cmp);
0063     return p;
0064 }
0065 
0066 template < class ReadablePropertyMap > class indirect_pmap
0067 {
0068 public:
0069     typedef
0070         typename boost::property_traits< ReadablePropertyMap >::value_type T;
0071     typedef typename boost::property_traits< ReadablePropertyMap >::key_type K;
0072     typedef K argument_type;
0073     typedef T result_type;
0074     inline indirect_pmap(const ReadablePropertyMap& df) : d(df) {}
0075 
0076     inline T operator()(const K& u) const { return get(d, u); }
0077 
0078 protected:
0079     ReadablePropertyMap d;
0080 };
0081 
0082 template < typename ReadablePropertyMap >
0083 indirect_pmap< ReadablePropertyMap > make_indirect_pmap(
0084     ReadablePropertyMap pmap)
0085 {
0086     indirect_pmap< ReadablePropertyMap > f(pmap);
0087     return f;
0088 }
0089 
0090 } // namespace boost
0091 
0092 #endif // GGCL_INDIRECT_CMP_HPP