arithmeticOperatorsForType - HaxyM/crap GitHub Wiki
Defined in "crap/functional.d/arithmeticoperatorsfortype.h".
Defined in "crap/functional".
template <class Type>
struct arithmeticOperatorsForType;Creates dividesValue (see dividesValue), minusValue (see minusValue), modulusValue (see modulusValue), multipliesValue (see multipliesValue), negateValue (see negateValue) and plusValue (see plusValue) acting on type Type. Allows for negateValue as unary value operator and dividesValue, minusValue, modulusValue, multipliesValue, plusValue to act as both value operator and binary value operator.
-
Type- type of values to operate on.
-
divides-valueof dividesValue with any number of passed values of typeType(for details see arithmeticOperatorsForType :: divides). Avaliable since C++14 language version. -
divides2-valueof dividesValue with two values of typeType(for details see arithmeticOperatorsForType :: divides2). Avaliable since C++14 language version. -
minus-valueof minusValue with any number of passed values of typeType(for details see arithmeticOperatorsForType :: minus). Avaliable since C++14 language version. -
minus2-valueof minusValue with two values of typeType(for details see arithmeticOperatorsForType :: minus2). Avaliable since C++14 language version. -
modulus-valueof modulusValue with any number of passed values of typeType(for details see arithmeticOperatorsForType :: modulus). Avaliable since C++14 language version. -
modulus2-valueof modulusValue with two values of typeType(for details see arithmeticOperatorsForType :: modulus2). Avaliable since C++14 language version. -
multiplies-valueof multipliesValue with any number of passed values of typeType(for details see arithmeticOperatorsForType :: multiplies). Avaliable since C++14 language version. -
multiplies2-valueof multipliesValue with two values of typeType(for details see arithmeticOperatorsForType :: multiplies2). Avaliable since C++14 language version. -
negate-valueof negateValue with single value of typeType(for details see arithmeticOperatorsForType :: negate). Avaliable since C++14 language version. -
plus-valueof plusValue with any number of passed values of typeType(for details see arithmeticOperatorsForType :: plus). Avaliable since C++14 language version. -
plus2-valueof plusValue with two values of typeType(for details see arithmeticOperatorsForType :: plus2). Avaliable since C++14 language version.
-
Divides- dividesValue accepting any number of values of typeType. CreatesdividesValueacting on passed values (for details see arithmeticOperatorsForType :: Divides). -
Divides2- dividesValue accepting two values of typeType. CreatesdividesValueacting on those two passed values (for details see arithmeticOperatorsForType :: Divides2). -
Minus- minusValue accepting any number of values of typeType. CreatesminusValueacting on passed values (for details see arithmeticOperatorsForType :: Minus). -
Minus2- minusValue accepting two values of typeType. CreatesminusValueacting on those two passed values (for details see arithmeticOperatorsForType :: Minus2). -
Modulus- modulusValue accepting any number of values of typeType. CreatesmodulusValueacting on passed values (for details see arithmeticOperatorsForType :: Modulus). -
Modulus2- modulusValue accepting two values of typeType. CreatesmodulusValueacting on those two passed values (for details see arithmeticOperatorsForType :: Modulus2). -
Multiplies- multipliesValue accepting any number of values of typeType. CreatesmultipliesValueacting on passed values (for details see arithmeticOperatorsForType :: Multiplies). -
Multiplies2- multipliesValue accepting two values of typeType. CreatesmultipliesValueacting on those two passed values (for details see arithmeticOperatorsForType :: Multiplies2). -
Negate- negateValue accepting single value of typeType. CreatesnegateValueacting on this passed value (for details see arithmeticOperatorsForType :: Negate). -
Plus- plusValue accepting any number of values of typeType. CreatesplusValueacting on passed values (for details see arithmeticOperatorsForType :: Plus). -
Plus2- plusValue accepting two values of typeType. CreatesplusValueacting on those two passed values (for details see arithmeticOperatorsForType :: Plus2).
#include <crap/functional.d/arithmeticoperatorsfortype.h>
int main()
{
using test1 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Divides<128u, 42u, 3u>;
using test2 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Minus<101u, 42u, 17u>;
using test3 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Modulus<42u, 35u, 3u>;
using test4 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Multiplues<2u, 3u, 7u>;
using test5 = typename crap :: arithmeticOperatorsForType < signed int> :: template Negate<-42>;
using test6 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Plus<101u, 42u, 27u>;
using test7 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Divides2<101u, 42u>;
using test8 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Minus2<101u, 42u>;
using test9 = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Modulus2<101u, 42u>;
using testA = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Multiplues2<101u, 42u>;
using testB = typename crap :: arithmeticOperatorsForType <unsigned int> :: template Plus2<101u, 42u>;
static_assert(test1 :: value == 1u, "test1: ((128 / 42) / 3) should be equal to 1.");
static_assert(test2 :: value == 42u, "test2: ((101 - 42) - 17) sould be equal to 42.");
static_assert(test3 :: value == 1u, "test3: ((42 % 35) % 3) sould be equal to 1.");
static_assert(test4 :: value == 42u, "test4: (2 * 3 * 7) should be equal to 42.");
static_assert(test5 :: value == 42, "test5: -(-42) should be equal to 42.");
static_assert(test6 :: value == 170u, "test6: (101 + 42 + 27) should not be equal to 170.");
static_assert(test7 :: value == 2u, "test7: (101 / 42) should be equal to 2.");
static_assert(test8 :: value == 59u, "test8: (101 - 42) sould be equal to 59.");
static_assert(test9 :: value == 17u, "test9: (101 % 42) sould be equal to 17.");
static_assert(testA :: value == 4242u, "testA: (101 * 42) should be equal to 4242.");
static_assert(testB :: value == 143u, "testB: (101 + 42) should not be equal to 143.");
return 0;
}- arithmeticOperatorsForType :: Divides
- arithmeticOperatorsForType :: Divides2
- arithmeticOperatorsForType :: Minus
- arithmeticOperatorsForType :: Minus2
- arithmeticOperatorsForType :: Modulus
- arithmeticOperatorsForType :: Modulus2
- arithmeticOperatorsForType :: Multiplies
- arithmeticOperatorsForType :: Multiplies2
- arithmeticOperatorsForType :: Negate
- arithmeticOperatorsForType :: Plus
- arithmeticOperatorsForType :: Plus2
- arithmeticOperatorsForType :: divides
- arithmeticOperatorsForType :: divides2
- arithmeticOperatorsForType :: minus
- arithmeticOperatorsForType :: minus2
- arithmeticOperatorsForType :: modulus
- arithmeticOperatorsForType :: modulus2
- arithmeticOperatorsForType :: multiplies
- arithmeticOperatorsForType :: multiplies2
- arithmeticOperatorsForType :: negate
- arithmeticOperatorsForType :: plus
- arithmeticOperatorsForType :: plus2
- dividesValue
- minusValue
- modulusValue
- multipliesValue
- negateValue
- plusValue