The base class for functor traits. More...
#include <FunctorTraits.hpp>
Public Types | |
using | Functor = F |
The described functor. More... | |
using | Inverse = void |
The inverse of this functor. More... | |
using | GroupInverseOf = void |
The functor defining a group that this functor is an inverse of. More... | |
using | UnaryGroupInverse = void |
The functor that acts as the unary inverse for this functor. More... | |
using | BinaryGroupInverse = void |
The functor that acts as the binary inverse for this functor. More... | |
Static Public Attributes | |
static constexpr bool | Total = false |
The function is defined for all input tuples (division is not). More... | |
static constexpr bool | Even = false |
f(-x) = f(x). More... | |
static constexpr bool | Odd = false |
f(-x) = -f(x). More... | |
static constexpr bool | Associative = false |
f(f(a, b), c) = f(a, f(b, c)). More... | |
static constexpr bool | Commutative = false |
f(a, b) = f(b, a). More... | |
static constexpr bool | Anticommutative = false |
f(a, b) = -f(b, a). More... | |
static constexpr bool | Invertible = false |
For all x, there exists y such that f(x, y) = f(y, x) = IdentityValue. More... | |
static constexpr bool | HasIdentity = false |
The functor has an identity, c, such that f(x, c) = x. More... | |
static constexpr bool | HasAbsorbingElement = false |
The functor has an absorbing element, c, such that f(c, x) = c. More... | |
template<typename G > | |
static constexpr bool | LeftDistributiveOver = CRTP::template RightDistributiveOver<G> && CRTP::Commutative |
The functor is left-distributes under g. More... | |
template<typename G > | |
static constexpr bool | RightDistributiveOver = false |
The functor is right-distributes under g. More... | |
static constexpr bool | Involutory = std::is_same_v<typename CRTP::Inverse, Functor> |
f(f(x)) = x. More... | |
static constexpr bool | Monoid = CRTP::Total && CRTP::Associative && CRTP::HasIdentity |
Simultaneously total, associative, and with identity. More... | |
static constexpr bool | Group = Monoid && Invertible |
An invertible monoid. More... | |
static constexpr bool | AbelianMonoid = Monoid && CRTP::Commutative |
A commutative monoid. More... | |
static constexpr bool | AbelianGroup = Group && CRTP::Commutative |
A commutative group. More... | |
The base class for functor traits.
The function being described is documented as being called f.
This should only be subclassed by Traits and its specializations, which should override any members for which the default is not appropriate. The defaults are chosen so that failure to override represents "no information".
CRTP | A curiously recurring template parameter. |
F | The functor being described. |
using sp::f::TraitsBase< CRTP, F >::BinaryGroupInverse = void |
The functor that acts as the binary inverse for this functor.
BinaryGroupInverse(x, y) = f(x, UnaryGroupInverse(y)).
using sp::f::TraitsBase< CRTP, F >::Functor = F |
The described functor.
using sp::f::TraitsBase< CRTP, F >::GroupInverseOf = void |
The functor defining a group that this functor is an inverse of.
That functor such that InvertOf::UnaryGroupInverse is f, or InvertOf::BinaryGroupInverse is f.
using sp::f::TraitsBase< CRTP, F >::Inverse = void |
The inverse of this functor.
The functor, g, such that g(f(x)) = x.
Not to be confused with UnaryGroupInverse or Invertible.
using sp::f::TraitsBase< CRTP, F >::UnaryGroupInverse = void |
The functor that acts as the unary inverse for this functor.
f(x, UnaryGroupInverse(x)) = IdentityValue and UnaryGroupInverse is involutory.
Not to be confused with Inverse.
|
staticconstexpr |
A commutative group.
|
staticconstexpr |
A commutative monoid.
|
staticconstexpr |
f(a, b) = -f(b, a).
|
staticconstexpr |
f(f(a, b), c) = f(a, f(b, c)).
|
staticconstexpr |
f(a, b) = f(b, a).
|
staticconstexpr |
f(-x) = f(x).
|
staticconstexpr |
An invertible monoid.
|
staticconstexpr |
The functor has an absorbing element, c, such that f(c, x) = c.
E.g: 0 for multiplication.
If this is true, the identity itself must be specified as follows:
|
staticconstexpr |
The functor has an identity, c, such that f(x, c) = x.
E.g: 0 for addition and subtraction, and 1 for multiplication and division.
If this is true, the identity itself must be specified as follows:
|
staticconstexpr |
For all x, there exists y such that f(x, y) = f(y, x) = IdentityValue.
Not to be confused with whether Inverse is non-void.
|
staticconstexpr |
f(f(x)) = x.
|
staticconstexpr |
The functor is left-distributes under g.
I.e: True only if g(f(x, a), f(x, b)) = f(x, g(a, b)).
This only needs to be overridden for operators that are left-distributive and aren't both right distributive and commutative. Matrix multiplication over addition is an example, because it's not commutative, but is both left and right distributive.
|
staticconstexpr |
Simultaneously total, associative, and with identity.
|
staticconstexpr |
f(-x) = -f(x).
|
staticconstexpr |
The functor is right-distributes under g.
I.e: True only if g(f(a, x), f(b, x)) = f(g(a, b), x). e.g: If the functor is multiplication, RightDistributiveOver for addition is true.
|
staticconstexpr |
The function is defined for all input tuples (division is not).