2 // Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
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 #ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
9 #define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
11 #include <boost/gil/channel.hpp>
12 #include <boost/gil/detail/is_channel_integral.hpp>
13 #include <boost/gil/detail/mp11.hpp>
15 #include <type_traits>
17 namespace boost{ namespace gil {
19 /// get_num_bits metafunctions
20 /// \brief Determines the numbers of bits for the given channel type.
22 template <typename T, class = void>
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>
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>
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>
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>
46 struct get_num_bits<packed_channel_value<N>> : std::integral_constant<int, N>
50 struct get_num_bits<packed_channel_value<N> const> : std::integral_constant<int, N>
57 typename std::enable_if
61 detail::is_channel_integral<T>,
62 mp11::mp_not<std::is_class<T>>
66 : std::integral_constant<std::size_t, sizeof(T) * 8>
69 }} // namespace boost::gil