remove_extent.hpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // Boost.Range library
  2. //
  3. // Copyright Jonathan Turkanis 2005. Use, modification and
  4. // distribution is subject to the Boost Software License, Version
  5. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // For more information, see http://www.boost.org/libs/range/
  9. //
  10. #ifndef BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
  11. #define BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
  12. #include <boost/config.hpp> // MSVC, NO_INTRINSIC_WCHAR_T, put size_t in std.
  13. #include <cstddef>
  14. #include <boost/mpl/eval_if.hpp>
  15. #include <boost/mpl/identity.hpp>
  16. #include <boost/type_traits/is_same.hpp>
  17. namespace boost
  18. {
  19. namespace range_detail
  20. {
  21. template< typename Case1 = mpl::true_,
  22. typename Type1 = mpl::void_,
  23. typename Case2 = mpl::true_,
  24. typename Type2 = mpl::void_,
  25. typename Case3 = mpl::true_,
  26. typename Type3 = mpl::void_,
  27. typename Case4 = mpl::true_,
  28. typename Type4 = mpl::void_,
  29. typename Case5 = mpl::true_,
  30. typename Type5 = mpl::void_,
  31. typename Case6 = mpl::true_,
  32. typename Type6 = mpl::void_,
  33. typename Case7 = mpl::true_,
  34. typename Type7 = mpl::void_,
  35. typename Case8 = mpl::true_,
  36. typename Type8 = mpl::void_,
  37. typename Case9 = mpl::true_,
  38. typename Type9 = mpl::void_,
  39. typename Case10 = mpl::true_,
  40. typename Type10 = mpl::void_,
  41. typename Case11 = mpl::true_,
  42. typename Type11 = mpl::void_,
  43. typename Case12 = mpl::true_,
  44. typename Type12 = mpl::void_,
  45. typename Case13 = mpl::true_,
  46. typename Type13 = mpl::void_,
  47. typename Case14 = mpl::true_,
  48. typename Type14 = mpl::void_,
  49. typename Case15 = mpl::true_,
  50. typename Type15 = mpl::void_,
  51. typename Case16 = mpl::true_,
  52. typename Type16 = mpl::void_,
  53. typename Case17 = mpl::true_,
  54. typename Type17 = mpl::void_,
  55. typename Case18 = mpl::true_,
  56. typename Type18 = mpl::void_,
  57. typename Case19 = mpl::true_,
  58. typename Type19 = mpl::void_,
  59. typename Case20 = mpl::true_,
  60. typename Type20 = mpl::void_>
  61. struct select {
  62. typedef typename
  63. mpl::eval_if<
  64. Case1, mpl::identity<Type1>, mpl::eval_if<
  65. Case2, mpl::identity<Type2>, mpl::eval_if<
  66. Case3, mpl::identity<Type3>, mpl::eval_if<
  67. Case4, mpl::identity<Type4>, mpl::eval_if<
  68. Case5, mpl::identity<Type5>, mpl::eval_if<
  69. Case6, mpl::identity<Type6>, mpl::eval_if<
  70. Case7, mpl::identity<Type7>, mpl::eval_if<
  71. Case8, mpl::identity<Type8>, mpl::eval_if<
  72. Case9, mpl::identity<Type9>, mpl::if_<
  73. Case10, Type10, mpl::void_ > > > > > > > > >
  74. >::type result1;
  75. typedef typename
  76. mpl::eval_if<
  77. Case11, mpl::identity<Type11>, mpl::eval_if<
  78. Case12, mpl::identity<Type12>, mpl::eval_if<
  79. Case13, mpl::identity<Type13>, mpl::eval_if<
  80. Case14, mpl::identity<Type14>, mpl::eval_if<
  81. Case15, mpl::identity<Type15>, mpl::eval_if<
  82. Case16, mpl::identity<Type16>, mpl::eval_if<
  83. Case17, mpl::identity<Type17>, mpl::eval_if<
  84. Case18, mpl::identity<Type18>, mpl::eval_if<
  85. Case19, mpl::identity<Type19>, mpl::if_<
  86. Case20, Type20, mpl::void_ > > > > > > > > >
  87. > result2;
  88. typedef typename
  89. mpl::eval_if<
  90. is_same<result1, mpl::void_>,
  91. result2,
  92. mpl::identity<result1>
  93. >::type type;
  94. };
  95. template<typename T>
  96. struct remove_extent {
  97. static T* ar;
  98. BOOST_STATIC_CONSTANT(std::size_t, size = sizeof(*ar) / sizeof((*ar)[0]));
  99. typedef typename
  100. select<
  101. is_same<T, bool[size]>, bool,
  102. is_same<T, char[size]>, char,
  103. is_same<T, signed char[size]>, signed char,
  104. is_same<T, unsigned char[size]>, unsigned char,
  105. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  106. is_same<T, wchar_t[size]>, wchar_t,
  107. #endif
  108. is_same<T, short[size]>, short,
  109. is_same<T, unsigned short[size]>, unsigned short,
  110. is_same<T, int[size]>, int,
  111. is_same<T, unsigned int[size]>, unsigned int,
  112. is_same<T, long[size]>, long,
  113. is_same<T, unsigned long[size]>, unsigned long,
  114. is_same<T, float[size]>, float,
  115. is_same<T, double[size]>, double,
  116. is_same<T, long double[size]>, long double
  117. >::type result1;
  118. typedef typename
  119. select<
  120. is_same<T, const bool[size]>, const bool,
  121. is_same<T, const char[size]>, const char,
  122. is_same<T, const signed char[size]>, const signed char,
  123. is_same<T, const unsigned char[size]>, const unsigned char,
  124. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  125. is_same<T, const wchar_t[size]>, const wchar_t,
  126. #endif
  127. is_same<T, const short[size]>, const short,
  128. is_same<T, const unsigned short[size]>, const unsigned short,
  129. is_same<T, const int[size]>, const int,
  130. is_same<T, const unsigned int[size]>, const unsigned int,
  131. is_same<T, const long[size]>, const long,
  132. is_same<T, const unsigned long[size]>, const unsigned long,
  133. is_same<T, const float[size]>, const float,
  134. is_same<T, const double[size]>, const double,
  135. is_same<T, const long double[size]>, const long double
  136. > result2;
  137. typedef typename
  138. mpl::eval_if<
  139. is_same<result1, mpl::void_>,
  140. result2,
  141. mpl::identity<result1>
  142. >::type type;
  143. };
  144. } // namespace 'range_detail'
  145. } // namespace 'boost'
  146. #endif