E.V.E  0.1-beta

◆ fls

eve::fls = {}
inlineconstexpr

Callable object computing the fls operation.

Required header: #include <eve/function/fls.hpp>

Members Functions

Member Effect
operator() the fls operation
operator[] Construct a conditional version of current function object

auto operator()( unsigned_value auto x ) const noexcept;
Definition: value.hpp:63

Parameters

x: unsigned value.

Return value

Computes elementwise the index or position of the last significant bit set to one in the word counting from the least significant bit position. The result is undefined for a zero input if the pedantic decorator is not used.


auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::fls

Parameters

cond : conditional expression

Return value

A Callable object so that the expression fls[cond](x, ...) is equivalent to if_else(cond,fls(x, ...),x)


Supported decorators

  • eve::pedantic

    Required header: #include <eve/function/pedantic/abs.hpp>

    The expression pedantic(fls)(x) returns the size of the element type (an out of range index) if the input is zero.

Example

See it live on Compiler Explorer

#include <eve/function/pedantic/fls.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_it pi = {14, 1, 3, 7, 20, 23000, 0, 27};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> fls(pi) = " << eve::fls(pi) << '\n'
<< "-> pedantic(fls)(pi) = " << eve::pedantic(eve::fls)(pi) << '\n';
std::uint32_t xf = 48;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> fls(xf) = " << eve::fls(xf) << '\n';
return 0;
}
constexpr callable_fls_ fls
Callable object computing the fls operation.
Definition: fls.hpp:80
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
Wrapper for SIMD registers.
Definition: wide.hpp:65