1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/pending/indirect_cmp.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,86 @@
1.4 +//
1.5 +//=======================================================================
1.6 +// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
1.7 +// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
1.8 +//
1.9 +// Distributed under the Boost Software License, Version 1.0. (See
1.10 +// accompanying file LICENSE_1_0.txt or copy at
1.11 +// http://www.boost.org/LICENSE_1_0.txt)
1.12 +//=======================================================================
1.13 +//
1.14 +
1.15 +#ifndef BOOST_INDIRECT_CMP_HPP
1.16 +#define BOOST_INDIRECT_CMP_HPP
1.17 +
1.18 +#include <functional>
1.19 +#include <boost/config.hpp>
1.20 +#include <boost/property_map.hpp>
1.21 +
1.22 +namespace boost {
1.23 +
1.24 + //: indirect_cmp
1.25 + //
1.26 + // could also do this with compose_f_gx_hx, and the member binder...
1.27 + //
1.28 + //!category: functors
1.29 + //!component: type
1.30 + //!tparam: ReadablePropertyMap - a model of ReadablePropertyMap
1.31 + //!definition: functor.h
1.32 + template <class ReadablePropertyMap, class Compare>
1.33 + class indirect_cmp {
1.34 + public:
1.35 + typedef typename boost::property_traits<ReadablePropertyMap>::value_type T;
1.36 + typedef typename boost::property_traits<ReadablePropertyMap>::key_type K;
1.37 + typedef K first_argument_type;
1.38 + typedef K second_argument_type;
1.39 + typedef T result_type;
1.40 + inline indirect_cmp(const ReadablePropertyMap& df, const Compare& c = Compare())
1.41 + : d(df), cmp(c) { }
1.42 +
1.43 + template <class A, class B>
1.44 + inline bool
1.45 + operator()(const A& u, const B& v) const {
1.46 + T du = get(d, u), dv = get(d, v);
1.47 + return cmp(du, dv);
1.48 + }
1.49 + protected:
1.50 + ReadablePropertyMap d;
1.51 + Compare cmp;
1.52 + };
1.53 +
1.54 + template <typename Compare, typename ReadablePropertyMap>
1.55 + indirect_cmp<ReadablePropertyMap, Compare>
1.56 + make_indirect_cmp(const Compare& cmp, ReadablePropertyMap pmap) {
1.57 + indirect_cmp<ReadablePropertyMap, Compare> p(pmap, cmp);
1.58 + return p;
1.59 + }
1.60 +
1.61 + template <class ReadablePropertyMap>
1.62 + class indirect_pmap {
1.63 + public:
1.64 + typedef typename boost::property_traits<ReadablePropertyMap>::value_type T;
1.65 + typedef typename boost::property_traits<ReadablePropertyMap>::key_type K;
1.66 + typedef K argument_type;
1.67 + typedef T result_type;
1.68 + inline indirect_pmap(const ReadablePropertyMap& df)
1.69 + : d(df) { }
1.70 +
1.71 + inline bool operator()(const K& u) const {
1.72 + return get(d, u);
1.73 + }
1.74 + protected:
1.75 + ReadablePropertyMap d;
1.76 + };
1.77 +
1.78 + template <typename ReadablePropertyMap>
1.79 + indirect_pmap<ReadablePropertyMap>
1.80 + make_indirect_pmap(ReadablePropertyMap pmap) {
1.81 + indirect_pmap<ReadablePropertyMap> f(pmap);
1.82 + return f;
1.83 + }
1.84 +
1.85 +
1.86 +} // namespace boost
1.87 +
1.88 +
1.89 +#endif // GGCL_INDIRECT_CMP_HPP