Skip to content

isSortedForType

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

crap :: isSortedForType

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


template <class Type, template <Type, Type> class Comparator = comparatorsForType <Type> :: template Less>
struct isSortedForType;

Creates isSortedValue (see isSortedValue). Allows for isSortedValue to act as value container.

Template parameters

  • Type - type of values to operate on.
  • Comparator - specifies operator comparing passed values. If none passed, default one is lessValue for type Type (see lessValue and comparatorsForType).

Layout

Member types

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