From 848c2ff82ca81046acc0a8343b7892a7738f0af1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 23 Mar 2017 19:34:43 +0200 Subject: [PATCH] Add fold expr implementations of mp_count, mp_count_if --- include/boost/mp11/detail/mp_count.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/include/boost/mp11/detail/mp_count.hpp b/include/boost/mp11/detail/mp_count.hpp index 12bde18..ef97827 100644 --- a/include/boost/mp11/detail/mp_count.hpp +++ b/include/boost/mp11/detail/mp_count.hpp @@ -24,7 +24,14 @@ namespace detail template struct mp_count_impl; -#if !defined( BOOST_MP11_NO_CONSTEXPR ) +#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) + +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 ) constexpr std::size_t cx_plus() { @@ -66,7 +73,14 @@ namespace detail template class P> struct mp_count_if_impl; -#if !defined( BOOST_MP11_NO_CONSTEXPR ) +#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) + +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> {