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