E.V.E
v2023.02.15
Loading...
Searching...
No Matches

◆ last_true

auto eve::last_true = functor<last_true_t>
inlineconstexpr
#include <eve/module/core.hpp>

Callable Signatures

template <relaxed_logical_value L>
std::optional<std::ptrdiff_t> last_true(L m) noexcept; // 1
template <logical_simd_value L>
std::optional<std::ptrdiff_t> last_true(top_bits<L> m) noexcept; // 1
// lane masking
std::optional<std::ptrdiff_t> last_true[conditional_expr auto c](/* any of the above */) noexcept; // 2
std::optional<std::ptrdiff_t> last_true[logical_value auto c](/* any of the above */) noexcept; // 2
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
constexpr auto last_true
Returns the index of the last element in the input which evaluates to true, if there is one.
Definition last_true.hpp:84
The cheapest to get bitset for simd logical.
Definition top_bits.hpp:80

Parameters

Return value

  1. An std::optional containing the index of the last element which evaluates to true, std::nullopt if there are none.
  2. Same as 1. but masked elements are ignored during the search.

Should you check for any?

The function is considering the case when nothing is set to be likely, checking for eve::any before hand is not going to be helpful. At the moment there isn't a function that would do otherwise.

What if I know there is a match?

We would recommend eve::last_true(m) - this is likely to trigger compiler optimizations, based on it being UB otherwise.

Example