Chris@16: // Chris@16: //======================================================================= Chris@16: // Author: Philipp Moeller Chris@16: // Chris@16: // Copyright 2012, Philipp Moeller Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: //======================================================================= Chris@16: // Chris@16: Chris@16: #ifndef BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP Chris@16: #define BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: template::type> Chris@16: class function_property_map: public put_get_helper > { Chris@16: public: Chris@16: typedef Key key_type; Chris@16: typedef Ret reference; Chris@16: typedef typename boost::remove_cv::type>::type value_type; Chris@16: Chris@16: typedef typename boost::mpl::if_< Chris@16: boost::mpl::and_< Chris@16: boost::is_reference, Chris@16: boost::mpl::not_ > Chris@16: >, Chris@16: boost::lvalue_property_map_tag, Chris@16: boost::readable_property_map_tag>::type Chris@16: category; Chris@16: Chris@16: function_property_map(Func f = Func()) : f(f) {} Chris@16: Chris@16: reference operator[](const Key& k) const { Chris@16: return f(k); Chris@16: } Chris@16: Chris@16: private: Chris@16: Func f; Chris@16: }; Chris@16: Chris@16: template Chris@16: function_property_map Chris@16: make_function_property_map(const Func& f) { Chris@16: return function_property_map(f); Chris@16: } Chris@16: Chris@16: template Chris@16: function_property_map Chris@16: make_function_property_map(const Func& f) { Chris@16: return function_property_map(f); Chris@16: } Chris@16: Chris@16: } // boost Chris@16: Chris@16: #endif /* BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP */