dynamic_step.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #include <boost/gil/dynamic_step.hpp>
  9. #include <boost/gil/color_base.hpp> // kth_element_type
  10. #include <boost/gil/pixel.hpp> // kth_element_type
  11. #include <boost/gil/pixel_iterator.hpp>
  12. #include <boost/gil/pixel_iterator_adaptor.hpp>
  13. #include <boost/gil/planar_pixel_iterator.hpp> // kth_element_type
  14. #include <boost/gil/planar_pixel_reference.hpp> // kth_element_type
  15. #include <boost/gil/step_iterator.hpp>
  16. #include <boost/gil/typedefs.hpp>
  17. #include <type_traits>
  18. namespace gil = boost::gil;
  19. // NOTE: Iterator does not model HasDynamicYStepTypeConcept
  20. // TODO: Add compile-fail tests to verify that.
  21. template <typename Iterator>
  22. void test_non_step()
  23. {
  24. static_assert(std::is_same
  25. <
  26. gil::memory_based_step_iterator<Iterator>,
  27. typename gil::dynamic_x_step_type<Iterator>::type
  28. >::value, "iterator does not model HasDynamicXStepTypeConcept");
  29. static_assert(!std::is_same
  30. <
  31. Iterator,
  32. typename gil::dynamic_x_step_type<Iterator>::type
  33. >::value, "dynamic_x_step_type yields X step iterator, not X iterator");
  34. }
  35. template <typename Iterator>
  36. void test_step()
  37. {
  38. static_assert(std::is_same
  39. <
  40. Iterator,
  41. typename gil::dynamic_x_step_type<Iterator>::type
  42. >::value, "iterator does not model HasDynamicXStepTypeConcept");
  43. static_assert(!std::is_same
  44. <
  45. typename Iterator::x_iterator,
  46. typename gil::dynamic_x_step_type<gil::gray8_step_ptr_t>::type
  47. >::value, "dynamic_x_step_type yields X step iterator, not X iterator");
  48. }
  49. int main()
  50. {
  51. test_non_step<gil::gray8_ptr_t>();
  52. test_non_step<gil::gray8c_ptr_t>();
  53. test_non_step<gil::gray16_ptr_t>();
  54. test_non_step<gil::gray16c_ptr_t>();
  55. test_non_step<gil::gray32_ptr_t>();
  56. test_non_step<gil::gray32c_ptr_t>();
  57. test_non_step<gil::gray32f_ptr_t>();
  58. test_step<gil::gray8_step_ptr_t>();
  59. test_step<gil::gray8c_step_ptr_t>();
  60. test_step<gil::gray16_step_ptr_t>();
  61. test_step<gil::gray16c_step_ptr_t>();
  62. test_step<gil::gray32_step_ptr_t>();
  63. test_step<gil::gray32c_step_ptr_t>();
  64. test_step<gil::gray32f_step_ptr_t>();
  65. test_non_step<gil::abgr8_ptr_t>();
  66. test_non_step<gil::abgr16_ptr_t>();
  67. test_non_step<gil::abgr32_ptr_t>();
  68. test_non_step<gil::abgr32f_ptr_t>();
  69. test_step<gil::abgr8_step_ptr_t>();
  70. test_step<gil::abgr16_step_ptr_t>();
  71. test_step<gil::abgr32_step_ptr_t>();
  72. test_step<gil::abgr32f_step_ptr_t>();
  73. test_non_step<gil::argb8_ptr_t>();
  74. test_non_step<gil::argb16_ptr_t>();
  75. test_non_step<gil::argb32_ptr_t>();
  76. test_non_step<gil::argb32f_ptr_t>();
  77. test_step<gil::argb8_step_ptr_t>();
  78. test_step<gil::argb16_step_ptr_t>();
  79. test_step<gil::argb32_step_ptr_t>();
  80. test_step<gil::argb32f_step_ptr_t>();
  81. test_non_step<gil::bgr8_ptr_t>();
  82. test_non_step<gil::bgr16_ptr_t>();
  83. test_non_step<gil::bgr32_ptr_t>();
  84. test_non_step<gil::bgr32f_ptr_t>();
  85. test_step<gil::bgr8_step_ptr_t>();
  86. test_step<gil::bgr16_step_ptr_t>();
  87. test_step<gil::bgr32_step_ptr_t>();
  88. test_step<gil::bgr32f_step_ptr_t>();
  89. test_non_step<gil::bgra8_ptr_t>();
  90. test_non_step<gil::bgra16_ptr_t>();
  91. test_non_step<gil::bgra32_ptr_t>();
  92. test_non_step<gil::bgra32f_ptr_t>();
  93. test_step<gil::bgra8_step_ptr_t>();
  94. test_step<gil::bgra16_step_ptr_t>();
  95. test_step<gil::bgra32_step_ptr_t>();
  96. test_step<gil::bgra32f_step_ptr_t>();
  97. test_non_step<gil::rgb8_ptr_t>();
  98. test_non_step<gil::rgb8_planar_ptr_t>();
  99. test_non_step<gil::rgb16_ptr_t>();
  100. test_non_step<gil::rgb16_planar_ptr_t>();
  101. test_non_step<gil::rgb32_ptr_t>();
  102. test_non_step<gil::rgb32_planar_ptr_t>();
  103. test_non_step<gil::rgb32f_ptr_t>();
  104. test_non_step<gil::rgb32f_planar_ptr_t>();
  105. test_step<gil::rgb8_step_ptr_t>();
  106. test_step<gil::rgb8_planar_step_ptr_t>();
  107. test_step<gil::rgb16_step_ptr_t>();
  108. test_step<gil::rgb16_planar_step_ptr_t>();
  109. test_step<gil::rgb32_step_ptr_t>();
  110. test_step<gil::rgb32_planar_step_ptr_t>();
  111. test_step<gil::rgb32f_step_ptr_t>();
  112. test_step<gil::rgb32f_planar_step_ptr_t>();
  113. test_non_step<gil::rgba8_ptr_t>();
  114. test_non_step<gil::rgba8_planar_ptr_t>();
  115. test_non_step<gil::rgba16_ptr_t>();
  116. test_non_step<gil::rgba16_planar_ptr_t>();
  117. test_non_step<gil::rgba32_ptr_t>();
  118. test_non_step<gil::rgba32_planar_ptr_t>();
  119. test_non_step<gil::rgba32f_ptr_t>();
  120. test_non_step<gil::rgba32f_planar_ptr_t>();
  121. test_step<gil::rgba8_step_ptr_t>();
  122. test_step<gil::rgba8_planar_step_ptr_t>();
  123. test_step<gil::rgba16_step_ptr_t>();
  124. test_step<gil::rgba16_planar_step_ptr_t>();
  125. test_step<gil::rgba32_step_ptr_t>();
  126. test_step<gil::rgba32_planar_step_ptr_t>();
  127. test_step<gil::rgba32f_step_ptr_t>();
  128. test_step<gil::rgba32f_planar_step_ptr_t>();
  129. test_non_step<gil::cmyk8_ptr_t>();
  130. test_non_step<gil::cmyk8_planar_ptr_t>();
  131. test_non_step<gil::cmyk16_ptr_t>();
  132. test_non_step<gil::cmyk16_planar_ptr_t>();
  133. test_non_step<gil::cmyk32_ptr_t>();
  134. test_non_step<gil::cmyk32_planar_ptr_t>();
  135. test_non_step<gil::cmyk32f_ptr_t>();
  136. test_non_step<gil::cmyk32f_planar_ptr_t>();
  137. test_step<gil::cmyk8_step_ptr_t>();
  138. test_step<gil::cmyk8_planar_step_ptr_t>();
  139. test_step<gil::cmyk16_step_ptr_t>();
  140. test_step<gil::cmyk16_planar_step_ptr_t>();
  141. test_step<gil::cmyk32_step_ptr_t>();
  142. test_step<gil::cmyk32_planar_step_ptr_t>();
  143. test_step<gil::cmyk32f_step_ptr_t>();
  144. test_step<gil::cmyk32f_planar_step_ptr_t>();
  145. }