template<typename Self, typename ... Fields>
struct eve::struct_support< Self, Fields >
Required header: #include <eve/traits/product_type.hpp>
eve::struct_support
is a CRTP based helper class to define product type like user-defined type. If Self
is this type that inherits from eve::struct_supports<Self,Fields...>
, it will behave as a structure containing members of type Fields...
and provides supports for operators based on the implementation of Self
.
Generated operators include:
- Member-wise equality is provided by default
- Lexicographial order is provided unless
eve::supports_ordering<Self>::value
evaluates to false
- Binary operators are provided if the corresponding compound assignment operator is provided. E.g
operator+
will be generated if Self::operator+=
is defined. Note that no operators is generated by combining existing operator (like operator-= b from operator+= and operator-) to maximize optimization opportunities.
eve::struct_support
also automatically generates the data member for Self
that are stored within a kumi::tuple
and accessible via get<N>(*this)
.
- Template Parameters
-
Self | Type to use as CRTP derived class |
Fields | Variadic list describing the data member of Self |
#include <eve/traits/product_type.hpp>
#include <eve/wide.hpp>
#include <iostream>
{
{
return get<0>(std::forward<decltype(self)>(self));
}
{
return get<1>(std::forward<decltype(self)>(self));
}
{
return get<2>(std::forward<decltype(self)>(self));
}
)
{
x(self) += x(other);
y(self) += y(other);
z(self) += z(other);
return self;
}
)
{
x(self) -= x(other);
y(self) -= y(other);
z(self) -= z(other);
return self;
}
friend std::ostream& operator<<( std::ostream& os,
eve::like<vec3> auto const& self )
{
return os << "{" << x(self) << ", " << y(self) << ", " << z(self) << "}";
}
};
int main()
{
{
return vec3{1.f+i,4.f-i,1.f/(1+i)};
}
);
std::cout << p << "\n";
p = p + p;
std::cout << p << "\n";
p -= vec3{1,1,1};
std::cout << p << "\n";
}
Specifies semantic compatibility between wrapper/wrapped types.
Definition product_type.hpp:107
CRTP base-class to declare operators for user-defined product type.
Definition product_type.hpp:154
Wrapper for SIMD registers.
Definition wide.hpp:70