Chris@16: // Copyright (C) 2009 Trustees of Indiana University Chris@16: // Authors: Jeremiah Willcock, Andrew Lumsdaine 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: // See http://www.boost.org/libs/property_map for documentation. Chris@16: Chris@16: #ifndef BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP Chris@16: #define BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: template Chris@16: class shared_array_property_map Chris@16: : public boost::put_get_helper > Chris@16: { Chris@16: public: Chris@16: typedef typename property_traits::key_type key_type; Chris@16: typedef T value_type; Chris@16: typedef T& reference; Chris@16: typedef boost::lvalue_property_map_tag category; Chris@16: Chris@16: inline shared_array_property_map(): data(), index() {} Chris@16: Chris@16: explicit inline shared_array_property_map( Chris@16: size_t n, Chris@16: const IndexMap& _id = IndexMap()) Chris@16: : data(new T[n]), index(_id) {} Chris@16: Chris@16: inline T& operator[](key_type v) const { Chris@16: return data[get(index, v)]; Chris@16: } Chris@16: Chris@16: private: Chris@16: boost::shared_array data; Chris@16: IndexMap index; Chris@16: }; Chris@16: Chris@16: template Chris@16: shared_array_property_map Chris@16: make_shared_array_property_map(size_t n, const T&, const IndexMap& index) { Chris@16: return shared_array_property_map(n, index); Chris@16: } Chris@16: Chris@16: } // end namespace boost Chris@16: Chris@16: #endif // BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP