Skip to content

comparatorsForType::EqualTo(struct)

Igor Zarzycki edited this page Jan 24, 2022 · 5 revisions

crap :: comparatorsForType :: EqualTo

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


template <class Type>
struct comparatorsForType
{
 /*...*/
 template <Type Value1, Type Value2>
 using EqualTo = equalToValue<Type, Value1, Value2>;
 /*...*/
};

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

Template parameters

  • Value1 - value to be compared equal against Value2.
  • Value2 - value with which Value1 is compared.

Layout

Member constants

  • value - true if Value1 compares equal to Value2. False if not.

Member types

  • value_type - type of field value. May not be bool 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/comparatorsfortype.h>

int main()
{
 using test1 = typename crap :: comparatorsForType <unsigned int> :: template EqualTo<42u, 101u>;
 using test2 = typename crap :: comparatorsForType <unsigned int> :: template EqualTo<101u, 42u>;
 using test3 = typename crap :: comparatorsForType <unsigned int> :: template EqualTo<42u, 42u>;

 static_assert(!(test1 :: value), "test1: 42 should not be equal to 101.");
 static_assert(!(test2 :: value), "test2: 101 should not be equal to 42.");
 static_assert(test3 :: value, "test3: 42 should be equal to 42.");
 return 0;
}

See also

Clone this wiki locally