-
Notifications
You must be signed in to change notification settings - Fork 2
modulusValue
Igor Zarzycki edited this page Jan 25, 2022
·
1 revision
Defined in "crap/functional.d/modulusvalue.h".
Defined in "crap/functional".
template <class Type, Type ... Values> struct modulusValue;
Returns result of modulo division of Values...
in order of their appearance. If Values...
is empty, this operator is not defined.
-
Type
- type of values to operate on. -
Values...
- set of values to operate on. If this set is empty whole operation is not defined. If set is single element then whole operation is evaluated to that element.
-
value
- holds result of operation. IfValues...
is single element,value
holds that element.
-
value_type
- type of fieldvalue
. May not beType
but should be castable to this type.
-
constexpr operator value_type () const noexcept
- casts whole object to itsvalue_type
returningvalue
.
#include <crap/functional.d/modulusvalue.h>
int main()
{
static_assert(crap :: modulusValue<unsigned int, 42u>{} == 42u, "42 should be 42");
static_assert(crap :: modulusValue<unsigned int, 42u, 7u>{} == 0u, "42 % 7 should be 0");
static_assert(crap :: modulusValue<unsigned int, 101u, 42u>{} == 17u, "101 % 42 should be 17");
static_assert(crap :: modulusValue<unsigned int, 42u, 35u, 3u>{} == ((42u % 35u) % 3u),
"42 % 35 % 3 should be 1");
static_assert(crap :: modulusValue<unsigned int, 101u, 42u, 12u, 3u, 2u>{} == ((((101u % 42u) % 12u) % 3u) % 2u),
"101 % 42 % 12 % 3 % 2 should be 0");
return 0;
}