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/channel.hpp>
9 #include <boost/gil/typedefs.hpp>
10 #include <boost/gil/detail/is_channel_integral.hpp>
12 #include <type_traits>
14 namespace gil = boost::gil;
18 static_assert(gil::detail::is_channel_integral
20 gil::packed_channel_value<1>
22 "1-bit packed_channel_value should be recognized as integral");
24 static_assert(gil::detail::is_channel_integral
26 gil::packed_channel_value<8>
28 "8-bit packed_channel_value should be recognized as integral");
30 static_assert(gil::detail::is_channel_integral
32 gil::packed_channel_reference
34 std::uint8_t, 0, 3, true
37 "3-bit packed_channel_reference should be recognized as integral");
39 static_assert(gil::detail::is_channel_integral
41 gil::packed_dynamic_channel_reference
46 "2-bit packed_dynamic_channel_reference should be recognized as integral");
48 static_assert(gil::detail::is_channel_integral
50 gil::packed_dynamic_channel_reference
52 std::uint16_t, 15, true
55 "15-bit packed_dynamic_channel_reference should be recognized as integral");
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
62 gil::scoped_channel_value
64 std::uint8_t, int_minus_value, int_plus_value
67 "integer-based scoped_channel_value should be recognized as integral");
69 static_assert(!gil::detail::is_channel_integral<gil::float32_t>::value,
70 "float-based packed_channel_value should not be recognized as integral");
72 static_assert(!gil::detail::is_channel_integral<gil::float64_t>::value,
73 "float-based packed_channel_value should not be recognized as integral");