2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
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
8 #include <boost/gil/pixel.hpp>
9 #include <boost/gil/concepts/pixel.hpp>
10 #include <boost/gil/typedefs.hpp>
12 #include <boost/mp11.hpp>
14 #include <type_traits>
16 namespace gil
= boost::gil
;
17 using namespace boost::mp11
;
19 template <typename Pixel
>
20 struct assert_compatible
22 template <typename CompatiblePixel
>
23 void operator()(CompatiblePixel
&&)
25 using result_t
= typename
gil::pixels_are_compatible
<Pixel
, CompatiblePixel
>::type
;
26 static_assert(result_t::value
, "pixels should be compatible");
28 // TODO: Refine after MPL -> MP11 switch
30 std::is_same
<result_t
, std::true_type
>::value
,
31 "pixels_are_compatible result type should be std::true_type");
34 !std::is_same
<result_t
, std::false_type
>::value
,
35 "pixels_are_compatible result type should no be std::false_type");
39 template <typename Pixel
>
40 struct assert_not_compatible
42 template <typename NotCompatiblePixel
>
43 void operator()(NotCompatiblePixel
&&)
46 !gil::pixels_are_compatible
<Pixel
, NotCompatiblePixel
>::value
,
47 "pixels should not be compatible");
51 template <typename Pixel
, typename
... CompatiblePixels
>
52 void test_compatible()
54 mp_for_each
<CompatiblePixels
...>(assert_compatible
<Pixel
>());
57 template <typename Pixel
, typename
... CompatiblePixels
>
58 void test_not_compatible()
60 mp_for_each
<CompatiblePixels
...>(assert_not_compatible
<Pixel
>());
65 test_compatible
<gil::gray8_pixel_t
, mp_list
<
67 gil::gray8c_pixel_t
>>();
68 test_compatible
<gil::gray8s_pixel_t
, mp_list
<
70 gil::gray8sc_pixel_t
>>();
71 test_not_compatible
<gil::gray8_pixel_t
, mp_list
<
73 gil::gray8sc_pixel_t
>>();
75 test_compatible
<gil::gray16_pixel_t
, mp_list
<
77 gil::gray16c_pixel_t
>>();
78 test_compatible
<gil::gray16s_pixel_t
, mp_list
<
80 gil::gray16sc_pixel_t
>>();
81 test_not_compatible
<gil::gray16_pixel_t
, mp_list
<
83 gil::gray16sc_pixel_t
>>();
85 test_compatible
<gil::rgb8_pixel_t
, mp_list
<
89 gil::rgb8c_pixel_t
>>();
90 test_compatible
<gil::rgb8s_pixel_t
, mp_list
<
94 gil::rgb8sc_pixel_t
>>();
95 test_not_compatible
<gil::rgb8_pixel_t
, mp_list
<
102 gil::rgb8sc_pixel_t
>>();
104 test_compatible
<gil::rgba8_pixel_t
, mp_list
<
110 gil::rgba8c_pixel_t
>>();
111 test_not_compatible
<gil::rgba8_pixel_t
, mp_list
<
116 gil::cmyk16_pixel_t
>>();
118 test_compatible
<gil::cmyk8_pixel_t
, mp_list
<
120 gil::cmyk8c_pixel_t
>>();
121 test_compatible
<gil::cmyk8s_pixel_t
, mp_list
<
123 gil::cmyk8sc_pixel_t
>>();
124 test_not_compatible
<gil::cmyk8_pixel_t
, mp_list
<
126 gil::cmyk8sc_pixel_t
>>();
128 test_compatible
<gil::cmyk32f_pixel_t
, mp_list
<
129 gil::cmyk32f_pixel_t
,
130 gil::cmyk32fc_pixel_t
>>();