diff --git a/include/boost/mp11/detail/mp_count.hpp b/include/boost/mp11/detail/mp_count.hpp index 09cb0f6..bc8aed9 100644 --- a/include/boost/mp11/detail/mp_count.hpp +++ b/include/boost/mp11/detail/mp_count.hpp @@ -90,11 +90,25 @@ namespace detail template class P> struct mp_count_if_impl; -#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) +#if defined( BOOST_MP11_HAS_CXX14_CONSTEXPR ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) + +template class P, class... T> constexpr std::size_t cx_count_if() +{ + constexpr bool a[] = { false, static_cast( P::value )... }; + + std::size_t r = 0; + + for( std::size_t i = 0; i < sizeof...(T); ++i ) + { + r += a[ i+1 ]; + } + + return r; +} template class L, class... T, template class P> struct mp_count_if_impl, P> { - using type = mp_size_t<(mp_to_bool>::value + ... + 0)>; + using type = mp_size_t()>; }; #elif !defined( BOOST_MP11_NO_CONSTEXPR )