range_list.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 RANGE_LIST_RG072501_HPP
  11. #define RANGE_LIST_RG072501_HPP
  12. //
  13. // range_list.hpp - helper to build boost::arrays for *_set types
  14. //
  15. #include "boost/array.hpp"
  16. namespace boost {
  17. namespace detail {
  18. namespace multi_array {
  19. /////////////////////////////////////////////////////////////////////////
  20. // choose range list begins
  21. //
  22. struct choose_range_list_n {
  23. template <typename T, std::size_t NumRanges>
  24. struct bind {
  25. typedef boost::array<T,NumRanges> type;
  26. };
  27. };
  28. struct choose_range_list_zero {
  29. template <typename T, std::size_t NumRanges>
  30. struct bind {
  31. typedef boost::array<T,1> type;
  32. };
  33. };
  34. template <std::size_t NumRanges>
  35. struct range_list_gen_helper {
  36. typedef choose_range_list_n choice;
  37. };
  38. template <>
  39. struct range_list_gen_helper<0> {
  40. typedef choose_range_list_zero choice;
  41. };
  42. template <typename T, std::size_t NumRanges>
  43. struct range_list_generator {
  44. private:
  45. typedef typename range_list_gen_helper<NumRanges>::choice Choice;
  46. public:
  47. typedef typename Choice::template bind<T,NumRanges>::type type;
  48. };
  49. //
  50. // choose range list ends
  51. /////////////////////////////////////////////////////////////////////////
  52. } // namespace multi_array
  53. } // namespace detail
  54. } // namespace boost
  55. #endif // RANGE_LIST_RG072501_HPP