-
Notifications
You must be signed in to change notification settings - Fork 2
multipliesValue
Igor Zarzycki edited this page Jan 25, 2022
·
1 revision
Defined in "crap/functional.d/multipliesvalue.h".
Defined in "crap/functional".
template <class Type, Type ... Values> struct multipliesValue;
Returns product of Values...
. Order of computations is unspecified.
-
Type
- type of values to operate on. -
Values...
- set of values to operate on.
-
value
- holds result of operation. IfValues...
is single element,value
holds that element. IfValues...
is empty,value
holds value ofidentity
(see identity) forType
.
-
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/multpliesvalue.h>
int main()
{
static_assert(crap :: multipliesValue<unsigned int>{} == 1u, "identity should be 1");
static_assert(crap :: multipliesValue<unsigned int, 42u>{} == 42u, "42 should be 42");
static_assert(crap :: multipliesValue<unsigned int, 6u, 7u>{} == 42u, "6 * 7 should be 42");
static_assert(crap :: multipliesValue<unsigned int, 42u, 1u>{} == 42u, "42 * 1 should be 42");
static_assert(crap :: multipliesValue<unsigned int, 42u, 101u>{} == (42u * 101u),
"42 * 101 should be 4242");
static_assert(crap :: multipliesValue<unsigned int, 7u, 6u, 3u>{} == (7u * 6u * 3u),
"7 * 6 * 3 should be 126");
static_assert(crap :: multipliesValue<unsigned int, 6u, 1u, 1u, 1u, 1u, 1u, 1u, 7u>{} == 42u,
"anything times 1 remains seme so rest should be 42");
static_assert(crap :: multipliesValue<unsigned int, 85u, 2u, 7u, 3u, 0u>{} == 0u,
"anything times 0 is 0 so rest should be 0");
return 0;
}