E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches
eve::comparisons< T > Struct Template Reference

Extension point for ordering and equality computation. More...

#include <eve/traits/comparisons.hpp>

Detailed Description

template<typename T>
struct eve::comparisons< T >

Required header: #include <eve/traits/comparisons.hpp>

eve::comparisons is an extension point for user-defined product type that may requires specific equality or ordering computations. It is meant to be specialized on scalar user-defined type to provide a set of class function members performing said operations.

To be considered valid, a specialization of eve::comparisons should provide either/or :

  • Functions called equal and not_equal that take an eve::callable_options and two values of the product type.
  • Functions called less, less_equal, greater and greater_equal that take an eve::callable_options and two values of the product type

Depending on the set of functions provided, said type will be said to satisfy either the eve::has_equality_support and/or the eve::has_ordering_support concept.

Template Parameters
TType to process

Example

#include <iostream>
#include <eve/eve.hpp>
namespace udt
{
struct point : eve::struct_support<point, int, float> {};
}
// Specialize eve::comparisons so that only position is used for equality
template<> struct eve::comparisons<udt::point>
{
static constexpr auto equal(auto const& a, auto const& b) noexcept
{
}
static constexpr auto not_equal(auto const& a, auto const& b) noexcept
{
}
};
int main()
{
eve::wide<float, eve::fixed<8>> a{1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9}, b{0.2,0.2,0.4,0.4,0.6,0.6,0.7,0.7};
eve::wide<int , eve::fixed<8>> i{1,2,3,4,5,6,7,8};
std::cout << p1 << "\n";
std::cout << p2 << "\n";
std::cout << "p1 == p2 : " << (p1 == p2) << "\n";
std::cout << "p1 != p2 : " << (p1 != p2) << "\n";
std::cout << "eve::is_equal(p1, p2) : " << eve::is_equal(p1, p2) << "\n";
std::cout << "eve::is_not_equal(p1, p2) : " << eve::is_not_equal(p1, p2) << "\n";
}
constexpr auto is_not_equal
elementwise callable returning a logical true if and only if the element values are not equal.
Definition is_not_equal.hpp:89
constexpr auto is_equal
elementwise callable returning a logical true if and only if the element values are equal.
Definition is_equal.hpp:92
constexpr auto zip
Callable for SoA value constructions.
Definition zip.hpp:85
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition translation.hpp:107
Extension point for ordering and equality computation.
Definition comparisons.hpp:43
CRTP base-class to declare operators for user-defined product type.
Definition product_type.hpp:154