E.V.E  0.1-beta

◆ bit_shl

eve::bit_shl = {}
inline

Callable object computing the logical left shift operation.

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

Members Functions

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

template< value T, integral_real_value U > auto operator()( T x, U n ) const noexcept requires bit_compatible< T, U >;

Parameters

x: An instance of a value.

n: An instance of an integral_value.

Return value

Computes the elementwise logical left shift of the first parameter by the second one.

the call bit_shl(x, n) is equivalent to x << n if x is an simd value.

The types must share the same cardinal or be scalar and if \(N\) is the size in bits of the element type of T, all elements of n must belong to the interval: \([0, N[\) or the result is undefined.


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/bit_shl.hpp>
#include <eve/literals.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t pi = {3, 2, 3, 4}, qi = {4, 1, 2, 0};
std::uint32_t z = 5;
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " <- z = " << z << '\n'
<< " -> bit_shl(pi, qi) = " << eve::bit_shl(pi, qi) << '\n'
<< " -> bit_shl(z, qi) = " << eve::bit_shl(z, qi) << '\n'
<< " -> bit_shl(pi, z ) = " << eve::bit_shl(pi, z) << '\n';
std::uint32_t a = 1;
std::uint32_t n = 4;
std::cout << "---- scalar" << '\n'
<< " <- a = " << a << '\n'
<< " <- n = " << n << '\n'
<< " -> bit_shl(a, n) = " << eve::bit_shl(a, n) << '\n';
return 0;
}
detail::callable_object< tag::shl_ > const bit_shl
Callable object computing the logical left shift operation.
Definition: bit_shl.hpp:81
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
Wrapper for SIMD registers.
Definition: wide.hpp:65