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 #include <boost/gil/channel.hpp>
9 #include <boost/gil/typedefs.hpp>
10 #include <boost/gil/detail/is_channel_integral.hpp>
11
12 #include <type_traits>
13
14 namespace gil = boost::gil;
15
main()16 int main()
17 {
18 static_assert(gil::detail::is_channel_integral
19 <
20 gil::packed_channel_value<1>
21 >::value,
22 "1-bit packed_channel_value should be recognized as integral");
23
24 static_assert(gil::detail::is_channel_integral
25 <
26 gil::packed_channel_value<8>
27 >::value,
28 "8-bit packed_channel_value should be recognized as integral");
29
30 static_assert(gil::detail::is_channel_integral
31 <
32 gil::packed_channel_reference
33 <
34 std::uint8_t, 0, 3, true
35 >
36 >::value,
37 "3-bit packed_channel_reference should be recognized as integral");
38
39 static_assert(gil::detail::is_channel_integral
40 <
41 gil::packed_dynamic_channel_reference
42 <
43 std::uint8_t, 2, true
44 >
45 >::value,
46 "2-bit packed_dynamic_channel_reference should be recognized as integral");
47
48 static_assert(gil::detail::is_channel_integral
49 <
50 gil::packed_dynamic_channel_reference
51 <
52 std::uint16_t, 15, true
53 >
54 >::value,
55 "15-bit packed_dynamic_channel_reference should be recognized as integral");
56
57
58 struct int_minus_value { static std::int8_t apply() { return -64; } };
59 struct int_plus_value { static std::int8_t apply() { return 64; } };
60 static_assert(gil::detail::is_channel_integral
61 <
62 gil::scoped_channel_value
63 <
64 std::uint8_t, int_minus_value, int_plus_value
65 >
66 >::value,
67 "integer-based scoped_channel_value should be recognized as integral");
68
69 static_assert(!gil::detail::is_channel_integral<gil::float32_t>::value,
70 "float-based packed_channel_value should not be recognized as integral");
71
72 static_assert(!gil::detail::is_channel_integral<gil::float64_t>::value,
73 "float-based packed_channel_value should not be recognized as integral");
74 }
75