MPL11
 All Classes Namespaces Files Typedefs Macros Groups Pages
variadic_sizeof.hpp
Go to the documentation of this file.
1 
12 #ifndef BOOST_MPL11_DETAIL_COUNT_IF_VARIADIC_SIZEOF_HPP
13 #define BOOST_MPL11_DETAIL_COUNT_IF_VARIADIC_SIZEOF_HPP
14 
17 #include <boost/mpl11/integer.hpp>
18 
19 
20 namespace boost { namespace mpl11 { namespace detail { namespace count_if {
21  template <std_size_t, bool> struct count_helper { };
22  template <std_size_t n> struct count_helper<n, true> { char c[10]; };
23 
24  template <
25  template <typename ...> class pred,
26  typename index,
27  typename ...xs>
28  struct sizeof_impl;
29 
30  template <
31  template <typename ...> class pred,
32  std_size_t ...index,
33  typename ...xs>
34  struct sizeof_impl<pred, std_index_sequence<index...>, xs...>
35  : count_helper<index, (bool)pred<xs>::type::value>...
36  { };
37 
43  template <template <typename ...> class predicate, typename ...xs>
44  using variadic_sizeof = size_t<sizeof...(xs) == 0 ? 0 :
45  sizeof(
46  sizeof_impl<
47  predicate,
48  typename make_std_index_sequence<sizeof...(xs)>::type,
49  xs...
50  >
51  ) / sizeof(count_helper<0, true>)
52  >;
53 }}}} // end namespace boost::mpl11::detail::count_if
54 
55 #endif // !BOOST_MPL11_DETAIL_COUNT_IF_VARIADIC_SIZEOF_HPP
Defines the Integer datatype.
Defines boost::mpl11::detail::std_size_t.
Defines boost::mpl11::detail::std_index_sequence.