]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/gil/extension/toolbox/metafunctions/get_num_bits.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / gil / extension / toolbox / metafunctions / get_num_bits.hpp
1 //
2 // Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
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 #ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
9 #define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
10
11 #include <boost/gil/channel.hpp>
12 #include <boost/gil/detail/is_channel_integral.hpp>
13 #include <boost/gil/detail/mp11.hpp>
14
15 #include <type_traits>
16
17 namespace boost{ namespace gil {
18
19 /// get_num_bits metafunctions
20 /// \brief Determines the numbers of bits for the given channel type.
21
22 template <typename T, class = void>
23 struct get_num_bits;
24
25 template<typename B, int I, int S, bool M>
26 struct get_num_bits<packed_channel_reference<B, I, S, M>>
27 : std::integral_constant<int, S>
28 {};
29
30 template<typename B, int I, int S, bool M>
31 struct get_num_bits<packed_channel_reference<B, I, S, M> const>
32 : std::integral_constant<int, S>
33 {};
34
35 template<typename B, int I, bool M>
36 struct get_num_bits<packed_dynamic_channel_reference<B, I, M>>
37 : std::integral_constant<int, I>
38 {};
39
40 template<typename B, int I, bool M>
41 struct get_num_bits<packed_dynamic_channel_reference<B, I, M> const>
42 : std::integral_constant<int, I>
43 {};
44
45 template<int N>
46 struct get_num_bits<packed_channel_value<N>> : std::integral_constant<int, N>
47 {};
48
49 template<int N>
50 struct get_num_bits<packed_channel_value<N> const> : std::integral_constant<int, N>
51 {};
52
53 template <typename T>
54 struct get_num_bits
55 <
56 T,
57 typename std::enable_if
58 <
59 mp11::mp_and
60 <
61 detail::is_channel_integral<T>,
62 mp11::mp_not<std::is_class<T>>
63 >::value
64 >::type
65 >
66 : std::integral_constant<std::size_t, sizeof(T) * 8>
67 {};
68
69 }} // namespace boost::gil
70
71 #endif