Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / core / algorithm / std_fill.cpp
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
17 #include <boost/array.hpp>
18 #include <boost/core/lightweight_test.hpp>
19 #include <boost/range/algorithm/fill_n.hpp>
20
21 #include <array>
22 #include <cstdint>
23
24 namespace gil = boost::gil;
25
26 template <typename ArrayPixel>
27 void test_array_as_range()
28 {
29     static_assert(ArrayPixel().size() == 2, "two-element array expected");
30
31     gil::image<ArrayPixel> img(1, 1);
32     std::fill(gil::view(img).begin(), gil::view(img).end(), ArrayPixel{0, 1});
33     BOOST_TEST(*gil::view(img).at(0,0) == (ArrayPixel{0, 1}));
34 }
35
36 int main()
37 {
38     test_array_as_range<boost::array<int, 2>>();
39     test_array_as_range<std::array<int, 2>>();
40
41     return boost::report_errors();
42 }