forked from boostorg/mp11
Use C++14 constexpr in cx_find_index as it's much less taxing for large N
This commit is contained in:
@@ -576,11 +576,30 @@ template<template<class...> class L, class V> struct mp_find_impl<L<>, V>
|
|||||||
using type = mp_size_t<0>;
|
using type = mp_size_t<0>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined( BOOST_NO_CXX14_CONSTEXPR )
|
||||||
|
|
||||||
|
constexpr std::size_t cx_find_index( bool const * first, bool const * last )
|
||||||
|
{
|
||||||
|
std::size_t m = 0;
|
||||||
|
|
||||||
|
while( first != last && !*first )
|
||||||
|
{
|
||||||
|
++m;
|
||||||
|
++first;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
constexpr std::size_t cx_find_index( bool const * first, bool const * last )
|
constexpr std::size_t cx_find_index( bool const * first, bool const * last )
|
||||||
{
|
{
|
||||||
return first == last || *first? 0: 1 + cx_find_index( first + 1, last );
|
return first == last || *first? 0: 1 + cx_find_index( first + 1, last );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
template<template<class...> class L, class... T, class V> struct mp_find_impl<L<T...>, V>
|
template<template<class...> class L, class... T, class V> struct mp_find_impl<L<T...>, V>
|
||||||
{
|
{
|
||||||
static constexpr bool _v[] = { std::is_same<T, V>::value... };
|
static constexpr bool _v[] = { std::is_same<T, V>::value... };
|
||||||
|
Reference in New Issue
Block a user