◆ clamp
Callable object clamping a value between two others. Required header: Members Functions
template< real_value T, real_value U, real_value V > auto operator()( T x, U lo, V hi ) const noexcept
requires compatible< T, U > && compatible< T, V >;
constexpr callable_hi_ hi Callable object computing the higher part of the values. Definition: hi.hpp:59 constexpr callable_lo_ lo Callable object computing the lower part of the values. Definition: lo.hpp:59 Parameters
Return value Each element of the result contains:
The result type is the common compatible type of the three parameters.
auto operator[]( conditional_expression auto cond ) const noexcept;
Higher-order function generating a masked version of eve::clamp Parameters
Return value A Callable object so that the expression Supported decorators
ExampleSee it live on Compiler Explorer #include <eve/function/clamp.hpp>
#include <eve/wide.hpp>
#include <iostream>
using wide_t = eve::wide<float, eve::fixed<4>>;
int main()
{
wide_t xi = {2, -3, 0, 4};
wide_t lo = {3, -2, -10, 0};
wide_t hi = {4, -1, 0, 5};
std::cout << "---- ximd" << '\n'
<< " <- xi = " << xi << '\n'
float sxi = 3, slo = 3, shi = 4;
std::cout << "---- scalar" << '\n'
<< " sxi = " << sxi << '\n'
<< " slo = " << slo << '\n'
<< " shi = " << shi << '\n'
return 0;
}
constexpr callable_clamp_ clamp Callable object clamping a value between two others. Definition: clamp.hpp:104 |