std_fill.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Copyright 2018 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. #ifdef BOOST_GIL_USE_CONCEPT_CHECK
  9. // FIXME: Range as pixel does not seem to fulfill pixel concepts due to no specializations required:
  10. // pixel.hpp(50) : error C2039 : 'type' : is not a member of 'boost::gil::color_space_type<P>
  11. #undef BOOST_GIL_USE_CONCEPT_CHECK
  12. #endif
  13. #include <boost/gil/algorithm.hpp>
  14. #include <boost/gil/image.hpp>
  15. #include <boost/gil/image_view.hpp>
  16. #include <boost/array.hpp>
  17. #include <boost/core/lightweight_test.hpp>
  18. #include <boost/range/algorithm/fill_n.hpp>
  19. #include <array>
  20. #include <cstdint>
  21. namespace gil = boost::gil;
  22. template <typename ArrayPixel>
  23. void test_array_as_range()
  24. {
  25. static_assert(ArrayPixel().size() == 2, "two-element array expected");
  26. gil::image<ArrayPixel> img(1, 1);
  27. std::fill(gil::view(img).begin(), gil::view(img).end(), ArrayPixel{0, 1});
  28. BOOST_TEST(*gil::view(img).at(0,0) == (ArrayPixel{0, 1}));
  29. }
  30. int main()
  31. {
  32. test_array_as_range<boost::array<int, 2>>();
  33. test_array_as_range<std::array<int, 2>>();
  34. return boost::report_errors();
  35. }