Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:58:07

0001 //
0002 //=======================================================================
0003 // Author: Philipp Moeller
0004 //
0005 // Copyright 2012, Philipp Moeller
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See
0008 // accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 //=======================================================================
0011 //
0012 
0013 #ifndef BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP
0014 #define BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP
0015 
0016 #include <boost/config.hpp>
0017 #include <boost/property_map/property_map.hpp>
0018 #include <boost/type_traits.hpp>
0019 #include <boost/utility/result_of.hpp>
0020 #include <boost/mpl/and.hpp>
0021 #include <boost/mpl/not.hpp>
0022 #include <utility>
0023 
0024 namespace boost {
0025 
0026 template<typename Func, typename PM, typename Ret = typename boost::result_of<const Func(typename property_traits<PM>::reference)>::type>
0027 class transform_value_property_map: public put_get_helper<Ret, transform_value_property_map<Func, PM, Ret> > {
0028   public:
0029   typedef typename property_traits<PM>::key_type key_type;
0030   typedef Ret reference;
0031   typedef typename boost::remove_cv<typename boost::remove_reference<Ret>::type>::type value_type;
0032 
0033   typedef typename boost::mpl::if_<
0034                      boost::mpl::and_<
0035                        boost::is_reference<Ret>,
0036                        boost::mpl::not_<boost::is_const<Ret> >
0037                      >,
0038                      boost::lvalue_property_map_tag,
0039                      boost::readable_property_map_tag>::type
0040     category;
0041 
0042   transform_value_property_map(Func f, PM pm) : f(f), pm(pm) {}
0043 
0044   reference operator[](const key_type& k) const {
0045     return f(get(pm, k));
0046   }
0047 
0048   private:
0049   Func f;
0050   PM pm;
0051 };
0052 
0053 template<typename PM, typename Func>
0054 transform_value_property_map<Func, PM>
0055 make_transform_value_property_map(const Func& f, const PM& pm) {
0056   return transform_value_property_map<Func, PM>(f, pm);
0057 }
0058 
0059 template<typename Ret, typename PM, typename Func>
0060 transform_value_property_map<Func, PM, Ret>
0061 make_transform_value_property_map(const Func& f, const PM& pm) {
0062   return transform_value_property_map<Func, PM, Ret>(f, pm);
0063 }
0064 
0065 } // boost
0066 
0067 #endif /* BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP */