arithmeticOperatorsForType::Modulus(struct) - HaxyM/crap GitHub Wiki
Defined in "crap/functional.d/arithmeticoperatorsfortype.h".
Defined in "crap/functional".
template <class Type>
struct arithmeticOperatorsForType
{
/*...*/
template <Type ... Values>
using Modulus = modulusValue<Type, Values...>;
/*...*/
};Creates modulusValue (see modulusValue) acting on type Type. Allows for modulusValue to act as value operator.
-
Values...- values to operate on.
-
value- holds result of operation. IfValues...is single element, value holds that element. IfValues...is empty whole operation is not defined.
-
value_type- type of fieldvalue. May not beTypebut should be castable to this type.
-
constexpr operator value_type () const noexcept- casts whole object to itsvalue_typereturningvalue.
#include <crap/functional.d/arithmeticoperatorsfortype.h>
int main()
{
return 0;
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Modulus<42u>{} == 42u, "42 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Modulus<42u, 7u>{} == 0u, "42 % 42 should be 0");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Modulus<101u, 42u>{} == 17u, "101 % 42 should be 17");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Modulus<42u, 35u, 3u>{} == ((42u % 35u) % 3u),
"42 % 35 % 3 should be 1");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Modulus<101u, 42u, 12u, 3u, 2u>{} == ((((101u % 42u) % 12u) % 3u) % 2u),
"101 % 42 % 12 % 3 % 2 should be 0");
return 0;
}