Skip to content

Commit

Permalink
Do not use fold expressions for mp_find and mp_find_if
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Dec 21, 2024
1 parent 35435bf commit 82533c4
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions include/boost/mp11/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,37 +719,7 @@ namespace detail

template<class L, class V> struct mp_find_impl;

#if BOOST_MP11_CLANG && defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS )

struct mp_index_holder
{
std::size_t i_;
bool f_;
};

constexpr inline mp_index_holder operator+( mp_index_holder const & v, bool f )
{
if( v.f_ )
{
return v;
}
else if( f )
{
return { v.i_, true };
}
else
{
return { v.i_ + 1, false };
}
}

template<template<class...> class L, class... T, class V> struct mp_find_impl<L<T...>, V>
{
static constexpr mp_index_holder _v{ 0, false };
using type = mp_size_t< (_v + ... + std::is_same<T, V>::value).i_ >;
};

#elif !defined( BOOST_MP11_NO_CONSTEXPR )
#if !defined( BOOST_MP11_NO_CONSTEXPR )

template<template<class...> class L, class V> struct mp_find_impl<L<>, V>
{
Expand Down Expand Up @@ -828,15 +798,7 @@ namespace detail

template<class L, template<class...> class P> struct mp_find_if_impl;

#if BOOST_MP11_CLANG && defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS )

template<template<class...> class L, class... T, template<class...> class P> struct mp_find_if_impl<L<T...>, P>
{
static constexpr mp_index_holder _v{ 0, false };
using type = mp_size_t< (_v + ... + P<T>::value).i_ >;
};

#elif !defined( BOOST_MP11_NO_CONSTEXPR )
#if !defined( BOOST_MP11_NO_CONSTEXPR )

template<template<class...> class L, template<class...> class P> struct mp_find_if_impl<L<>, P>
{
Expand Down

0 comments on commit 82533c4

Please sign in to comment.