Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / extension / toolbox / metafunctions / pixel_bit_size.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_PIXEL_BIT_SIZE_HPP
9 #define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_PIXEL_BIT_SIZE_HPP
10
11 #include <boost/gil/bit_aligned_pixel_reference.hpp>
12 #include <boost/gil/packed_pixel.hpp>
13
14 namespace boost{ namespace gil {
15
16 /// pixel_bit_size metafunctions
17 /// \brief Accumulates the all channel size.
18 ///
19 /// \code
20 /// using image_t = bit_aligned_image5_type<16, 16, 16, 8, 8, devicen_layout_t<5>>::type;
21 /// const int size = pixel_bit_size<image_t::view_t::reference>::value;
22 /// \endcode
23 template< typename PixelRef>
24 struct pixel_bit_size : std::integral_constant<int, 0> {};
25
26 template <typename B, typename C, typename L, bool M>
27 struct pixel_bit_size<bit_aligned_pixel_reference<B, C, L, M>>
28     : mp11::mp_fold
29     <
30         C,
31         std::integral_constant<int, 0>,
32         mp11::mp_plus
33     >
34 {};
35
36 template <typename B, typename C, typename L, bool M>
37 struct pixel_bit_size<bit_aligned_pixel_reference<B, C, L, M> const>
38     : mp11::mp_fold
39     <
40         C,
41         std::integral_constant<int, 0>,
42         mp11::mp_plus
43     >
44 {};
45
46 template <typename B, typename C, typename L>
47 struct pixel_bit_size<packed_pixel<B, C, L>>
48     : mp11::mp_fold
49     <
50         C,
51         std::integral_constant<int, 0>,
52         mp11::mp_plus
53     >
54
55 {};
56
57 template <typename B, typename C, typename L>
58 struct pixel_bit_size<const packed_pixel<B,C,L> >
59     : mp11::mp_fold
60     <
61         C,
62         std::integral_constant<int, 0>,
63         mp11::mp_plus
64     >
65 {};
66
67 }} // namespace boost::gil
68
69 #endif