Skip to content

negateValue

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

crap :: negateValue

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


template <class Type, Type Value> struct negateValue;

Returns arithmetic negation of Value.

Template parameters

  • Type - type of values to operate on.
  • Value - value to negate.

Layout

Member constants

  • value - holds result of operation.

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

int main()
{
 static_assert(crap :: negateValue<int, -42>{} == 42, "minus -42 should be 42");
 static_assert(crap :: negateValue<int, 42>{} == -42, "minus 42 should be -42");
 static_assert(crap :: negateValue<int, 0>{} == 0, "minus 0 should be 0");
 return 0;
}

See also

Clone this wiki locally