Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:05

0001 // Copyright 2002 The Trustees of Indiana University.
0002 
0003 // Use, modification and distribution is subject to the Boost Software 
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 //  Boost.MultiArray Library
0008 //  Authors: Ronald Garcia
0009 //           Jeremy Siek
0010 //           Andrew Lumsdaine
0011 //  See http://www.boost.org/libs/multi_array for documentation.
0012 
0013 #ifndef BOOST_MULTI_ARRAY_EXTENT_GEN_HPP
0014 #define BOOST_MULTI_ARRAY_EXTENT_GEN_HPP
0015 
0016 #include "boost/multi_array/extent_range.hpp"
0017 #include "boost/multi_array/range_list.hpp"
0018 #include "boost/multi_array/types.hpp"
0019 #include "boost/array.hpp"
0020 #include <algorithm>
0021 
0022 namespace boost {
0023 namespace detail {
0024 namespace multi_array {
0025 
0026 
0027 template <std::size_t NumRanges>
0028 class extent_gen {
0029 public:
0030   typedef boost::detail::multi_array::index index;
0031   typedef boost::detail::multi_array::size_type size_type;
0032   typedef extent_range<index,size_type> range;
0033 private:
0034   typedef typename range_list_generator<range,NumRanges>::type range_list;
0035 public:
0036   template <std::size_t Ranges>
0037   struct gen_type {
0038     typedef extent_gen<Ranges> type;
0039   };
0040 
0041   range_list ranges_;
0042 
0043   extent_gen() { }
0044 
0045   // Used by operator[] to expand extent_gens
0046   extent_gen(const extent_gen<NumRanges-1>& rhs,
0047             const range& a_range)
0048   {
0049     std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
0050     *ranges_.rbegin() = a_range;
0051   }
0052 
0053   extent_gen<NumRanges+1>
0054   operator[](const range& a_range)
0055   {
0056     return extent_gen<NumRanges+1>(*this,a_range);    
0057   }
0058 
0059   extent_gen<NumRanges+1>
0060   operator[](index idx)
0061   {
0062     return extent_gen<NumRanges+1>(*this,range(0,idx));    
0063   }    
0064 
0065   static extent_gen<0> extents() {
0066     return extent_gen<0>();
0067   }
0068 };
0069 
0070 } // namespace multi_array
0071 } // namespace detail
0072 } // namespace boost
0073 
0074 
0075 #endif