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

◆ bit_set

eve::bit_set = functor<bit_set_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_set(integral_value auto x, integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto bit_set[conditional_expr auto c](integral_value, auto x integral_value auto n) noexcept; // 2
constexpr auto bit_set[logical_value auto m](integral_value auto x, integral_value auto n) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:51
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 bit_set
strict_elementwise_callable object setting to 1 the ith bit of each element.
Definition bit_set.hpp:68
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition translation.hpp:107
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

  1. The value of the parameter is returned with the ith bit set to 1. If the index is out of range the call will assert.
  2. The operation is performed conditionnaly.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide pi = {1, 3, 7, 15, 31, 63, 127, 255};
std::cout << "<- pi = " << pi << '\n';
std::cout << "-> bit_set(pi, 1) = " << eve::bit_set(pi, 1) << '\n';
std::cout << "-> bit_set(pi, 2) = " << eve::bit_set(pi, 2) << '\n';
std::cout << "-> bit_set(pi, 3) = " << eve::bit_set(pi, 3) << '\n';
std::cout << "-> bit_set(pi, 4) = " << eve::bit_set(pi, 4) << '\n';
std::cout << "-> bit_set(pi, 8) = " << eve::bit_set(pi, 8) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 1) = " << eve::bit_set[pi > 15](pi, 1) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 2) = " << eve::bit_set[pi > 15](pi, 2) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 3) = " << eve::bit_set[pi > 15](pi, 3) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 4) = " << eve::bit_set[pi > 15](pi, 4) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 8) = " << eve::bit_set[pi > 15](pi, 8) << '\n';
}
Wrapper for SIMD registers.
Definition wide.hpp:94