-
Notifications
You must be signed in to change notification settings - Fork 2
dividesValue
Igor Zarzycki edited this page Jan 24, 2022
·
1 revision
Defined in "crap/functional.d/dividesvalue.h".
Defined in "crap/functional".
template <class Type, Type ... Values> struct dividesValue;
Returns 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. If Values...
is single element, value
holds that element.
value_type
- type of field value
. May not be Type
but should be castable to this type.
constexpr operator value_type () const noexcept
- casts whole object to its value_type
returning value
.
#include <crap/functional.d/dividesvalue.h>
int main()
{
static_assert(crap :: dividesValue<unsigned int, 42u>{} == 42u, "42 should be 42");
static_assert(crap :: dividesValue<unsigned int, 42u, 42u>{} == 1u, "42 / 42 should be 1");
static_assert(crap :: dividesValue<unsigned int, 42u, 6u>{} == 7u, "42 / 6 should be 7");
static_assert(crap :: dividesValue<unsigned int, 42u, 101u>{} == (42u / 101u), "42 / 101 should be 0");
static_assert(crap :: dividesValue<unsigned int, 42u, 6u, 3u>{} == ((42u / 6u) / 3u),
"42 / 6 / 3 should be 2");
static_assert(crap :: dividesValue<unsigned int, 85u, 2u, 7u, 3u, 2u>{} == ((((85u / 2u) / 7u) / 3u) / 2u),
" 85 / 2 is 42 so rest should be 1");
return 0;
}