template<template< typename > class Func, typename OptionsValues, typename... Options>
struct eve::constant_callable< Func, OptionsValues, Options >
Defined in Header
#include <eve/traits/overload.hpp>
Constants functions in EVE are built using a very common pattern. Inheriting from eve::constant_callable simplifies the implementation of such eve::callable by just requiring your eve::callable type to implement a static value
member function that provides the constant value using two parameters:
- an eve::options pack containing potential decorators passed to the constant.
- an eve::as instance to specify the translated element type of the output.
Constant functions in EVE also supports masking, which is directly implemented in eve::constant_callable.
- Note
- The deferred overload named in the EVE_CALLABLE_OBJECT macro process is still available if an architecture specific implementation of any given constant is required.
- Template Parameters
-
Func | Type of current Callable Object being implemented. |
OptionsValues | Type of stored options. |
Options | List of supported option specifications. |
#include <iostream>
#include <type_traits>
#include <eve/traits/overload.hpp>
#include <eve/wide.hpp>
{
template<typename Options>
{
template<typename T>
static EVE_FORCEINLINE T
value(
eve::as<T> const&,
auto) {
return static_cast<T
>(3.14159216); }
template<eve::floating_value T>
};
};
int main()
{
std::cout << eve::some_pi(
eve::as(1.0)) <<
"\n";
std::cout << "Is Pi(as<float>) supported: "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<eve::some_pi>,
eve::as<float>>
<< "\n";
std::cout << "Is Pi(float) supported: "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<eve::some_pi>, float>
<< "\n";
std::cout << "Is Pi(as<wide<unsigned char>>) supported: "
<< "\n";
}
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
#define EVE_CALLABLE_OBJECT(TYPE, NAME)
Generate the generic function interface for an actual eve::callable.
Definition protocol.hpp:131
constexpr auto functor
EVE's Callable Object generator.
Definition supports.hpp:89
#define EVE_DISPATCH_CALL(...)
Generate the proper call to current EVE's Callable Object implementation.
Definition protocol.hpp:148
EVE Main Namespace.
Definition abi.hpp:18
Lightweight type-wrapper.
Definition as.hpp:29
CRTP base class giving an EVE's Callable Object the constant function semantic.
Definition default_behaviors.hpp:313
constexpr auto else_(V const &v) const
Extends a conditional expression with an alternative value.
Definition conditional.hpp:489
Conditional expression keeping all lanes between two position.
Definition conditional.hpp:523
Wrapper for SIMD registers.
Definition wide.hpp:86