Skip to content

isSortedForType::type

Igor Zarzycki edited this page Jan 23, 2022 · 8 revisions

crap :: isSortedForType <Type, template <Type,Type> class> :: type

Defined in "crap/algorithm.d/issortedfortype.h".
Defined in "crap/algorithm".


template <class Type, template <Type, Type> class Operator> struct isSortedForType
{
 /*...*/
 template <Type ... Values>
 using type = typename isSortedValue<Type, Operator, Values...>;
 /*...*/
};

Member type of isSortedForType (see isSortedForType). Allows for isSortedValue (see isSortedValue) to act like container (see value container). Passes Values... into isSortedValue with type (Type) and comparing operator (Operator) specified by isSortedForType nesting it. Same as isSortedForType :: values (see isSortedForType :: values).

Template parameters

  • Values... - values of type Type to be checked if sorted acording to comparing operator Operator.

Usage example

#include <crap/algorithm.d/issortedfortype.h>

int main()
{
 using test1 = typename crap :: isSortedForType <unsigned int> :: template type<0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u>;
 using test2 = typename crap :: isSortedForType <unsigned int> :: template type<0u, 1u, 2u, 42u, 4u, 5u, 6u, 7u>;
 using test3 = typename crap :: isSortedForType <unsigned int, crap :: comparatorsForType <unsigned int> :: template Greater> :: template type<7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u>;
 using test4 = typename crap :: isSortedForType <unsigned int, crap :: comparatorsForType <unsigned int> :: template Greater> :: template type<7u, 6u, 5u, 4u, 42u, 2u, 1u, 0u>;
 static_assert(test1 :: value, "test1 should be sorted in ascending order.");
 static_assert(!(test2 :: value), "test2 sould not be sorted in ascending order.");
 static_assert(test3 :: value, "test3 sould be sorted in descending order.");
 static_assert(!(test4 :: value), "test4 should not be sorted in descending order.");
 return 0;
}

See also

Clone this wiki locally