-
Notifications
You must be signed in to change notification settings - Fork 2
arithmeticOperatorsForType::plus
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 plus = plusValue <Type, Values...> :: value;
/*...*/
};
Member constant of arithmeticOperatorsForType
. Stores value of plusValue
(see plusValue) 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 plus<> == 0u, "zero should be 0");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template plus<42u> == 42u, "42 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template plus<22u, 20u> == 42u, "22 + 20 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template plus<42u, 0u> == 42u, "42 + 0 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template plus<10u, 12u, 20u> == (10u + 12u + 20u),
"10 + 12 + 20 should be 42");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template plus<20u, 0u, 0u, 0u, 0u, 0u, 0u, 22u> == 42u,
"anything plus 0 remains seme so rest should be 42");
return 0;
}