Skip to content

arithmeticOperatorsForType::Multiplies2(struct)

Igor Zarzycki edited this page Feb 15, 2022 · 1 revision

crap :: arithmeticOperatorsForType :: Multiplies2

Defined in "crap/functional.d/arithmeticoperatorsfortype.h".
Defined in "crap/functional".


template <class Type>
struct arithmeticOperatorsForType
{
 /*...*/
 template <Type Value1, Type Value2>
 using Multiplies2 = multipliesValue<Type, Value1, Value2>;
 /*...*/
};

Creates multipliesValue (see multipliesValue) acting on type Type. Allows for multipliesValue to act as binary value operator.

Template parameters

  • Value1 - value to be multiplied with Value2.
  • Value2 - value to be multiplied with Value1.

Layout

Member constants

  • value - holds result of multiplication of Value1 with Value2.

Member types

  • value_type - type of field value. May not be Type but should be castable to this type.

Member functions

  • constexpr operator value_type () const noexcept - casts whole object to its value_type returning value.

Usage example

#include <crap/functional.d/arithmeticoperatorsfortype.h>

int main()
{
 static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Multiplies2<42u, 0u>{} == 0u, "42 * 0 should be 0");
 static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Multiplies2<42u, 1u>{} == 42u, "42 * 1 should be 42");
 static_assert(crap :: arithmeticOperatorsForType <unsigned int> :: template Multiplies2<6u, 7u>{} == 42u, "6 * 7 should be 42");
 return 0;
}

See also

Clone this wiki locally