Skip to content

minusValue

Igor Zarzycki edited this page Jan 25, 2022 · 1 revision

crap :: minusValue

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


template <class Type, Type ... Values> struct minusValue;

Returns result of subtraction of Values... in order of their appearance. If Values... is empty, this operator is not defined.

Template parameters

  • 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.

Layout

Member constants

  • value - holds result of operation. If Values... is single element, value holds that element.

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/minusvalue.h>

int main()
{
 static_assert(crap :: minusValue<unsigned int, 42u>{} == 42u, "42 should be 42");
 static_assert(crap :: minusValue<unsigned int, 42u, 42u>{} == 0u, "42 - 42 should be 0");
 static_assert(crap :: minusValue<unsigned int, 42u, 35u>{} == 7u, "42 - 35 should be 7");
 static_assert(crap :: minusValue<unsigned int, 42u, 7u, 3u>{} == ((42u - 6u) - 3u),
 "42 - 7 - 3 should be 32");
 static_assert(crap :: minusValue<unsigned int, 84u, 42u, 7u, 3u, 2u>{} == ((((84u - 42u) - 7u) - 3u) - 2u),
 " 84 - 42 - 7 - 3 - 2 should be 30");
 return 0;
}

See also

Clone this wiki locally