E.V.E  0.1-beta

◆ bit_cast

eve::bit_cast = {}
inlineconstexpr

Callable object computing a bitwise reinterpretation of the object.

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

Members Functions

Member Effect
operator() Obtain a value of type To by reinterpreting the object representation of from

template<real_value From, scalar_real_value To>
auto operator()(From x, as<To> t) const noexcept;
Lightweight type-wrapper.
Definition: as.hpp:29
Parameters
xinstance of a value to be casted
Template Parameters
To[value] to which x is casted

Return value

Obtain a value of type To by reinterpreting the object representation of from. Every bit in the value representation of the returned To object is equal to the corresponding bit in the object representation of from.


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/bit_cast.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
using iT = std::int32_t;
using wide_it = eve::wide<iT, eve::fixed<4>>;
int main()
{
wide_ft pf = {1.0f, 2.0f, -1.0f, 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> eve::bit_cast(pf,as<wide_it>()) = " << std::hex << eve::bit_cast(pf, eve::as<wide_it>()) << '\n';
float xf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> eve::bit_cast(xf, as<iT>()) = " << std::hex << eve::bit_cast(xf, eve::as<iT>()) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65