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

◆ convert

auto eve::convert = functor<convert_t>
inlineconstexpr

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
template<value T, scalar_value Target> Target convert( T x, as_<Target> t) noexcept; //1
// Semantic option
constexpr auto convert[saturated](/* any of the above overloads */) noexcept; // 2
}
constexpr auto convert
Converts a value to another type.
Definition convert.hpp:83
EVE Main Namespace.
Definition abi.hpp:18

Parameters

Return value

  1. Elementwise conversion of x in the Target type is returned.
  2. The expression convert[saturated](x,t) computes a saturated conversion of x to the type wrapped by t
Note
In scalar mode Conversions operated by convert, follow the regular rules of C++ type conversion, including the cases leading to Undefined Behaviors.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.4, -1.0, -2.0, -3.0, -4.1};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 700u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> convert(wf0, as<int>()) = " << eve::convert(wf0, eve::as<int>()) << "\n";
std::cout << "-> convert(wu0, as<char>()) = " << eve::convert(wu0, eve::as<char>()) << "\n";
std::cout << "-> convert[saturated](wu0, as<char>()) = " << eve::convert[eve::saturated](wu0, eve::as<char>()) << "\n";
}
Lightweight type-wrapper.
Definition as.hpp:29
Wrapper for SIMD registers.
Definition wide.hpp:86