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

◆ bit_cast

auto eve::bit_cast = functor<bit_cast_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto bit_cast operator()(value x, as<scalar_value> t) noexcept;
}
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto bit_cast
Computes a bitwise reinterpretation of an object.
Definition bit_cast.hpp:63
EVE Main Namespace.
Definition abi.hpp:18
Lightweight type-wrapper.
Definition as.hpp:29

Parameters

Template parameters

  • To: scalar type to which each element of x is casted

Return value

The bits of x of type From reinterpreted as being those of a variable of type To is returned.

Every bit in the value representation of the returned To object is equal to the corresponding bit in the object representation of from. The values of padding bits in the returned To object are unspecified.

If there is no value of type To corresponding to the value representation produced, the behavior is undefined. If there are multiple such values, which value is produced is unspecified.

External reference

Example

// revision 2
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0f, 1.0f, 2.0f, 3.0f, -1.0f, -2.0f, -3.0f, -4.0f};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_cast(wf0, as(wu)) = " << eve::bit_cast(wf0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wf0, as(wu0))= " << eve::bit_cast(wf0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wi0, as(wu0))= " << eve::bit_cast(wi0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wu0, as(wi0))= " << eve::bit_cast(wu0, eve::as(wi0)) << "\n";
std::cout << "-> bit_cast(wi0, as(wu0))= " << eve::bit_cast(wi0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wu, as(wi0)) = " << eve::bit_cast(wu0, eve::as(wi0)) << "\n";
}
Wrapper for SIMD registers.
Definition wide.hpp:86