-
Notifications
You must be signed in to change notification settings - Fork 2
arithmeticOperatorsForType::Divides2(struct)
Igor Zarzycki edited this page Jan 31, 2022
·
2 revisions
Defined in "crap/functional.d/arithmeticoperatorsfortype.h".
Defined in "crap/functional".
template <class Type>
struct arithmeticOperatorsForType
{
/*...*/
template <Type Value1, Type Value2>
using Divides2 = dividesValue<Type, Value1, Value2>;
/*...*/
};
Creates dividesValue
(see dividesValue) acting on type Type
. Allows for dividesValue
to act as binary value operator.
-
Value1
- value to be divided byValue2
. -
Value2
- value divideValue1
.
-
value
- holds result of division ofValue1
byValue2
.
-
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/arithmeticoperatorsfortype.h>
int main()
{
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Divides2<42u, 42u>{} == 1u, "42 / 42 should be 1");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Divides2<42u, 6u>{} == 7u, "42 / 6 should be 7");
static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Divides2<42u, 101u>{} == (42u / 101u), "42 / 101 should be 0");
return 0;
}