isSortedValue - HaxyM/crap GitHub Wiki

crap :: isSortedValue

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


template <class Type, template <Type, Type> class Comparator, Type ... Values>
struct isSortedForType;

Checks if passed Values... are sorted according to passed Comparator.

Template parameters

  • Type - type of values to operate on.
  • Comparator - specifies operator comparing passed values (see comparatorsForType).
  • Values... - values to be checked.

Layout

Member constants

  • value - true if Values... are sorted according to passed Comparator. False if not.

Usage example

#include <crap/algorithm.d/issortedvalue.h>
#include <crap/functional.d/comparatorsfortype.h>

int main()
{
 using test1 = crap :: isSortedValue<unsigned int, crap :: comparatorsForType <unsigned int> :: template Less, 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u>;
 using test2 = crap :: isSortedValue<unsigned int, crap :: comparatorsForType <unsigned int> :: template Less, 0u, 1u, 2u, 42u, 4u, 5u, 6u, 7u>;
 using test3 = crap :: isSortedValue<unsigned int, crap :: comparatorsForType <unsigned int> :: template Greater, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u>;
 using test4 = crap :: isSortedValue<unsigned int, crap :: comparatorsForType <unsigned int> :: template Greater, 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

⚠️ **GitHub.com Fallback** ⚠️