-
Notifications
You must be signed in to change notification settings - Fork 2
isSortedValue
Igor Zarzycki edited this page Jan 23, 2022
·
4 revisions
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
.
-
Type
- type of values to operate on. -
Comparator
- specifies operator comparing passed values (see comparatorsForType). -
Values...
- values to be checked.
-
value
- true ifValues...
are sorted according to passedComparator
. False if not.
#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;
}