Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / core / locator / concepts.cpp
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 // FIXME: Avoid Clang's flooding of non-disableable warnings like:
9 // "T does not declare any constructor to initialize its non-modifiable members"
10 // when compiling with concepts check enabled.
11 // See https://bugs.llvm.org/show_bug.cgi?id=41759
12 #if !defined(BOOST_GIL_USE_CONCEPT_CHECK) && !defined(__clang__)
13 #error Compile with BOOST_GIL_USE_CONCEPT_CHECK defined
14 #endif
15 #include <boost/gil/concepts.hpp>
16 #include <boost/gil/locator.hpp>
17 #include <boost/gil/planar_pixel_reference.hpp>
18 #include <boost/gil/typedefs.hpp>
19 #include <boost/gil/virtual_locator.hpp>
20
21 #include <boost/concept_check.hpp>
22
23 namespace gil = boost::gil;
24 using boost::function_requires;
25
26 template <typename Locator>
27 void test_immutable()
28 {
29     function_requires<gil::PixelLocatorConcept<Locator>>();
30     function_requires<gil::HasDynamicXStepTypeConcept<Locator>>();
31     function_requires<gil::HasDynamicYStepTypeConcept<Locator>>();
32 }
33
34 template <typename Locator>
35 void test_mutable()
36 {
37     function_requires<gil::MutablePixelLocatorConcept<Locator>>();
38     function_requires<gil::HasDynamicXStepTypeConcept<Locator>>();
39     function_requires<gil::HasDynamicYStepTypeConcept<Locator>>();
40 }
41
42 template <typename Pixel>
43 struct archetype_pixel_dereference
44 {
45     using point_t = gil::point_t;
46     using const_t = archetype_pixel_dereference;
47     using value_type = Pixel;
48     using reference = value_type;
49     using const_reference = value_type;
50     using argument_type = gil::point_t;
51     using result_type = reference;
52     static constexpr bool is_mutable = false;
53     result_type operator()(argument_type const&) const { return result_type{}; }
54 };
55
56 template <typename Pixel>
57 using virtual_locator = gil::virtual_2d_locator<archetype_pixel_dereference<Pixel>, false>;
58
59 int main()
60 {
61     test_mutable<gil::gray8_loc_t>();
62     test_mutable<gil::gray8_step_loc_t>();
63     test_mutable<gil::gray16_loc_t>();
64     test_mutable<gil::gray16_step_loc_t>();
65     test_mutable<gil::gray32_loc_t>();
66     test_mutable<gil::gray32_step_loc_t>();
67     test_mutable<gil::gray32f_loc_t>();
68     test_mutable<gil::gray32f_step_loc_t>();
69     test_immutable<gil::gray8c_loc_t>();
70     test_immutable<gil::gray8c_step_loc_t>();
71     test_immutable<gil::gray16c_loc_t>();
72     test_immutable<gil::gray16c_step_loc_t>();
73     test_immutable<gil::gray32c_loc_t>();
74     test_immutable<gil::gray32c_step_loc_t>();
75     test_immutable<gil::gray32fc_loc_t>();
76     test_immutable<gil::gray32fc_step_loc_t>();
77
78     test_mutable<gil::memory_based_2d_locator<gil::gray8_step_ptr_t>>();
79     test_immutable<gil::memory_based_2d_locator<gil::gray8c_step_ptr_t>>();
80     test_mutable<virtual_locator<gil::gray8_pixel_t>>();
81     test_immutable<virtual_locator<gil::gray8c_pixel_t>>();
82
83     test_mutable<gil::abgr8_loc_t>();
84     test_mutable<gil::abgr8_step_loc_t>();
85     test_mutable<gil::memory_based_2d_locator<gil::abgr8_step_ptr_t>>();
86     test_mutable<gil::abgr16_loc_t>();
87     test_mutable<gil::abgr16_step_loc_t>();
88     test_mutable<gil::abgr32_loc_t>();
89     test_mutable<gil::abgr32_step_loc_t>();
90     test_mutable<gil::abgr32f_loc_t>();
91     test_mutable<gil::abgr32f_step_loc_t>();
92     test_immutable<gil::abgr8c_loc_t>();
93     test_immutable<gil::abgr8c_step_loc_t>();
94     test_immutable<gil::memory_based_2d_locator<gil::abgr8c_step_ptr_t>>();
95     test_immutable<gil::abgr16c_loc_t>();
96     test_immutable<gil::abgr16c_step_loc_t>();
97     test_immutable<gil::abgr32c_loc_t>();
98     test_immutable<gil::abgr32c_step_loc_t>();
99     test_immutable<gil::abgr32fc_loc_t>();
100     test_immutable<gil::abgr32fc_step_loc_t>();
101
102     test_mutable<gil::argb8_loc_t>();
103     test_mutable<gil::argb8_step_loc_t>();
104     test_mutable<gil::memory_based_2d_locator<gil::argb8_step_ptr_t>>();
105     test_mutable<gil::argb16_loc_t>();
106     test_mutable<gil::argb16_step_loc_t>();
107     test_mutable<gil::argb32_loc_t>();
108     test_mutable<gil::argb32_step_loc_t>();
109     test_mutable<gil::argb32f_loc_t>();
110     test_mutable<gil::argb32f_step_loc_t>();
111
112     test_mutable<gil::bgr8_loc_t>();
113     test_mutable<gil::bgr8_step_loc_t>();
114     test_mutable<gil::memory_based_2d_locator<gil::bgr8_step_ptr_t>>();
115     test_mutable<gil::bgr16_loc_t>();
116     test_mutable<gil::bgr16_step_loc_t>();
117     test_mutable<gil::bgr32_loc_t>();
118     test_mutable<gil::bgr32_step_loc_t>();
119     test_mutable<gil::bgr32f_loc_t>();
120     test_mutable<gil::bgr32f_step_loc_t>();
121
122     test_mutable<gil::bgra8_loc_t>();
123     test_mutable<gil::bgra8_step_loc_t>();
124     test_mutable<gil::memory_based_2d_locator<gil::bgra8_step_ptr_t>>();
125     test_mutable<gil::bgra16_loc_t>();
126     test_mutable<gil::bgra16_step_loc_t>();
127     test_mutable<gil::bgra32_loc_t>();
128     test_mutable<gil::bgra32_step_loc_t>();
129     test_mutable<gil::bgra32f_loc_t>();
130     test_mutable<gil::bgra32f_step_loc_t>();
131
132     test_mutable<gil::rgb8_loc_t>();
133     test_mutable<gil::rgb8_step_loc_t>();
134     test_mutable<gil::rgb8_planar_loc_t>();
135     test_mutable<gil::rgb8_planar_step_loc_t>();
136     test_mutable<gil::rgb16_loc_t>();
137     test_mutable<gil::rgb16_step_loc_t>();
138     test_mutable<gil::rgb16_planar_loc_t>();
139     test_mutable<gil::rgb16_planar_step_loc_t>();
140     test_mutable<gil::rgb32_loc_t>();
141     test_mutable<gil::rgb32_step_loc_t>();
142     test_mutable<gil::rgb32_planar_loc_t>();
143     test_mutable<gil::rgb32_planar_step_loc_t>();
144     test_mutable<gil::rgb32f_loc_t>();
145     test_mutable<gil::rgb32f_step_loc_t>();
146     test_mutable<gil::rgb32f_planar_loc_t>();
147     test_mutable<gil::rgb32f_planar_step_loc_t>();
148     test_immutable<gil::rgb8c_loc_t>();
149     test_immutable<gil::rgb8c_step_loc_t>();
150     test_immutable<gil::rgb16c_loc_t>();
151     test_immutable<gil::rgb16c_step_loc_t>();
152     test_immutable<gil::rgb32c_loc_t>();
153     test_immutable<gil::rgb32c_step_loc_t>();
154     test_immutable<gil::rgb32fc_loc_t>();
155     test_immutable<gil::rgb32fc_step_loc_t>();
156
157     test_mutable<gil::memory_based_2d_locator<gil::rgb8_step_ptr_t>>();
158     test_immutable<gil::memory_based_2d_locator<gil::rgb8c_step_ptr_t>>();
159     test_mutable<virtual_locator<gil::rgb8_pixel_t>>();
160     test_immutable<virtual_locator<gil::rgb8c_pixel_t>>();
161
162     test_mutable<gil::rgba8_loc_t>();
163     test_mutable<gil::rgba8_step_loc_t>();
164     test_mutable<gil::rgba8_planar_loc_t>();
165     test_mutable<gil::rgba8_planar_step_loc_t>();
166     test_mutable<gil::memory_based_2d_locator<gil::rgba8_step_ptr_t>>();
167     test_mutable<gil::rgba16_loc_t>();
168     test_mutable<gil::rgba16_step_loc_t>();
169     test_mutable<gil::rgba16_planar_loc_t>();
170     test_mutable<gil::rgba16_planar_step_loc_t>();
171     test_mutable<gil::rgba32_loc_t>();
172     test_mutable<gil::rgba32_step_loc_t>();
173     test_mutable<gil::rgba32_planar_loc_t>();
174     test_mutable<gil::rgba32_planar_step_loc_t>();
175     test_mutable<gil::rgba32f_loc_t>();
176     test_mutable<gil::rgba32f_step_loc_t>();
177     test_mutable<gil::rgba32f_planar_loc_t>();
178     test_mutable<gil::rgba32f_planar_step_loc_t>();
179
180     test_mutable<gil::cmyk8_loc_t>();
181     test_mutable<gil::cmyk8_step_loc_t>();
182     test_mutable<gil::cmyk8_planar_loc_t>();
183     test_mutable<gil::cmyk8_planar_step_loc_t>();
184     test_mutable<gil::memory_based_2d_locator<gil::cmyk8_step_ptr_t>>();
185     test_mutable<gil::cmyk16_loc_t>();
186     test_mutable<gil::cmyk16_step_loc_t>();
187     test_mutable<gil::cmyk16_planar_loc_t>();
188     test_mutable<gil::cmyk16_planar_step_loc_t>();
189     test_mutable<gil::cmyk32_loc_t>();
190     test_mutable<gil::cmyk32_step_loc_t>();
191     test_mutable<gil::cmyk32_planar_loc_t>();
192     test_mutable<gil::cmyk32_planar_step_loc_t>();
193     test_mutable<gil::cmyk32f_loc_t>();
194     test_mutable<gil::cmyk32f_step_loc_t>();
195     test_mutable<gil::cmyk32f_planar_loc_t>();
196     test_mutable<gil::cmyk32f_planar_step_loc_t>();
197     test_immutable<gil::cmyk8c_loc_t>();
198     test_immutable<gil::cmyk8c_step_loc_t>();
199     test_immutable<gil::cmyk8c_planar_loc_t>();
200     test_immutable<gil::cmyk8c_planar_step_loc_t>();
201     test_immutable<gil::memory_based_2d_locator<gil::cmyk8c_step_ptr_t>>();
202 }