#ifndef BOOST_MP11_DETAIL_MP_COUNT_HPP_INCLUDED #define BOOST_MP11_DETAIL_MP_COUNT_HPP_INCLUDED // Copyright 2015, 2016 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include #include #include namespace boost { namespace mp11 { // mp_count namespace detail { #if !defined( BOOST_MP11_NO_CONSTEXPR ) constexpr std::size_t cx_plus() { return 0; } template constexpr std::size_t cx_plus(T1 t1, T... t) { return static_cast(t1) + cx_plus(t...); } template constexpr std::size_t cx_plus(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T... t) { return static_cast(t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10) + cx_plus(t...); } #endif template struct mp_count_impl; #if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) template class L, class... T, class V> struct mp_count_impl, V> { using type = mp_size_t<(std::is_same::value + ... + 0)>; }; #elif !defined( BOOST_MP11_NO_CONSTEXPR ) template class L, class... T, class V> struct mp_count_impl, V> { using type = mp_size_t::value...)>; }; #else template class L, class... T, class V> struct mp_count_impl, V> { using type = mp_size_t...>::value>; }; #endif } // namespace detail template using mp_count = typename detail::mp_count_impl::type; // mp_count_if namespace detail { template class P> struct mp_count_if_impl; #if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) template class L, class... T, template class P> struct mp_count_if_impl, P> { using type = mp_size_t<(mp_to_bool>::value + ... + 0)>; }; #elif !defined( BOOST_MP11_NO_CONSTEXPR ) template class L, class... T, template class P> struct mp_count_if_impl, P> { using type = mp_size_t>::value...)>; }; #else template class L, class... T, template class P> struct mp_count_if_impl, P> { #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template struct _f { using type = mp_to_bool>; }; using type = mp_size_t::type...>::value>; #else using type = mp_size_t>...>::value>; #endif }; #endif } // namespace detail template class P> using mp_count_if = typename detail::mp_count_if_impl::type; template using mp_count_if_q = mp_count_if; } // namespace mp11 } // namespace boost #endif // #ifndef BOOST_MP11_DETAIL_MP_COUNT_HPP_INCLUDED