extent_range.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2002 The Trustees of Indiana University.
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Boost.MultiArray Library
  6. // Authors: Ronald Garcia
  7. // Jeremy Siek
  8. // Andrew Lumsdaine
  9. // See http://www.boost.org/libs/multi_array for documentation.
  10. #ifndef BOOST_MULTI_ARRAY_EXTENT_RANGE_HPP
  11. #define BOOST_MULTI_ARRAY_EXTENT_RANGE_HPP
  12. #include <utility>
  13. namespace boost {
  14. namespace detail {
  15. namespace multi_array {
  16. template <typename Extent, typename SizeType>
  17. class extent_range : private std::pair<Extent,Extent> {
  18. typedef std::pair<Extent,Extent> super_type;
  19. public:
  20. typedef Extent index;
  21. typedef SizeType size_type;
  22. extent_range(index start, index finish) :
  23. super_type(start,finish) { }
  24. extent_range(index finish) :
  25. super_type(0,finish) { }
  26. extent_range() : super_type(0,0) { }
  27. index start() const { return super_type::first; }
  28. index finish() const { return super_type::second; }
  29. size_type size() const { return super_type::second - super_type::first; }
  30. };
  31. } // namespace multi_array
  32. } // namespace detail
  33. } // namespace boost
  34. #endif