File: std_fill.cpp

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (55 lines) | stat: -rw-r--r-- 1,434 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Copyright 2018-2020 Mateusz Loskot <mateusz at loskot dot net>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#ifdef BOOST_GIL_USE_CONCEPT_CHECK
// FIXME: Range as pixel does not seem to fulfill pixel concepts due to no specializations required:
//        pixel.hpp(50) : error C2039 : 'type' : is not a member of 'boost::gil::color_space_type<P>
#undef BOOST_GIL_USE_CONCEPT_CHECK
#endif
#include <boost/gil/algorithm.hpp>
#include <boost/gil/image.hpp>
#include <boost/gil/image_view.hpp>

#include <boost/array.hpp>
#include <boost/mp11.hpp>
#include <boost/core/lightweight_test.hpp>

#include <array>
#include <cstdint>

namespace gil = boost::gil;

using array_pixel_types = ::boost::mp11::mp_list
<
    boost::array<int, 2>,
    std::array<int, 2>
>;

struct test_array_as_pixel
{
    template <typename Pixel>
    void operator()(Pixel const&)
    {
        using pixel_t = Pixel;
        gil::image<pixel_t> img(1, 1);
        std::fill(gil::view(img).begin(), gil::view(img).end(), pixel_t{0, 1});
        auto a = *gil::view(img).at(0, 0);
        auto e = pixel_t{0, 1};
        BOOST_TEST(a == e);
    }
    static void run()
    {
        boost::mp11::mp_for_each<array_pixel_types>(test_array_as_pixel{});
    }
};

int main()
{
    test_array_as_pixel::run();

    return ::boost::report_errors();
}