-
Notifications
You must be signed in to change notification settings - Fork 2
arithmeticOperatorsForType::modulus
Igor Zarzycki edited this page Feb 18, 2022
·
1 revision
Defined in "crap/functional.d/arithmeticoperatorsfortype.h".
Defined in "crap/functional".
template <class Type>
struct arithmeticOperatorsForType
{
/*...*/
template <Type ... Values>
constexpr const static auto modulus = modulusValue <Type, Values...> :: value;
/*...*/
};
Member constant of arithmeticOperatorsForType
. Stores value of modulusValue
(see modulusValue) acting on type Type
. Requires C++14 or higher language version.
-
Values...
- values to operate on.
#include <crap/functional.d/arithmeticoperatorsfortype.h>
int main()
{
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;
}