arithmeticOperatorsForType::Plus(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 Plus = plusValue<Type, Values...>;
/*...*/
};Creates plusValue (see plusValue) acting on type Type. Allows for plusValue 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,valueholds value ofzero(see zero) forType.
-
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()
{
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Plus<>{} == 0u, "zero should be 0");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Plus<42u>{} == 42u, "42 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Plus<22u, 20u>{} == 42u, "22 + 20 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Plus<42u, 0u>{} == 42u, "42 + 0 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Plus<10u, 12u, 20u>{} == (10u + 12u + 20u),
"10 + 12 + 20 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Plus<20u, 0u, 0u, 0u, 0u, 0u, 0u, 22u>{} == 42u,
"anything plus 0 remains seme so rest should be 42");
return 0;
}