MPL11
 All Classes Namespaces Files Typedefs Macros Groups Pages
variadic_sum.hpp
Go to the documentation of this file.
1 
12 #ifndef BOOST_MPL11_DETAIL_COUNT_IF_VARIADIC_SUM_HPP
13 #define BOOST_MPL11_DETAIL_COUNT_IF_VARIADIC_SUM_HPP
14 
16 #include <boost/mpl11/integer.hpp>
17 
18 
19 namespace boost { namespace mpl11 { namespace detail { namespace count_if {
20  template <std_size_t N>
21  constexpr std_size_t homogeneous_sum(const bool (&array)[N]) {
22  std_size_t s = 0;
23  for (std_size_t i = 0; i < N; ++i)
24  s += array[i];
25  return s;
26  }
27 
33  template <template <typename ...> class predicate, typename ...xs>
34  using variadic_sum = size_t<
35  // Avoid empty arrays
36  homogeneous_sum<sizeof...(xs)+1>(
37  {false, (bool)predicate<xs>::type::value...}
38  )
39  >;
40 }}}} // end namespace boost::mpl11::detail::count_if
41 
42 #endif // !BOOST_MPL11_DETAIL_COUNT_IF_VARIADIC_SUM_HPP
Defines the Integer datatype.
Defines boost::mpl11::detail::std_size_t.