Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:16

0001 //  Copyright (C) 2009 Trustees of Indiana University
0002 //  Authors: Jeremiah Willcock, Andrew Lumsdaine
0003 
0004 // Distributed under the Boost Software License, Version 1.0. (See
0005 // accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 //  See http://www.boost.org/libs/property_map for documentation.
0009 
0010 #ifndef BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP
0011 #define BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP
0012 
0013 #include <boost/smart_ptr/shared_array.hpp>
0014 #include <boost/property_map/property_map.hpp>
0015 
0016 namespace boost {
0017 
0018 template <class T, class IndexMap>
0019 class shared_array_property_map
0020   : public boost::put_get_helper<T&, shared_array_property_map<T, IndexMap> >
0021 {
0022   public:
0023   typedef typename property_traits<IndexMap>::key_type key_type;
0024   typedef T value_type;
0025   typedef T& reference;
0026   typedef boost::lvalue_property_map_tag category;
0027 
0028   inline shared_array_property_map(): data(), index() {}
0029 
0030   explicit inline shared_array_property_map(
0031     size_t n,
0032     const IndexMap& _id = IndexMap())
0033   : data(new T[n]), index(_id) {}
0034 
0035   inline T& operator[](key_type v) const {
0036     return data[get(index, v)];
0037   }
0038 
0039   private:
0040   boost::shared_array<T> data;
0041   IndexMap index;
0042 };
0043 
0044 template <class T, class IndexMap>
0045 shared_array_property_map<T, IndexMap>
0046 make_shared_array_property_map(size_t n, const T&, const IndexMap& index) {
0047   return shared_array_property_map<T, IndexMap>(n, index);
0048 }
0049 
0050 } // end namespace boost
0051 
0052 #endif // BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP