-
Notifications
You must be signed in to change notification settings - Fork 2
isSortedForType
Igor Zarzycki edited this page Jan 23, 2022
·
4 revisions
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.
-
Type
- type of values to operate on. -
Comparator
- specifies operator comparing passed values. If none passed, default one islessValue
for typeType
(see lessValue and comparatorsForType).
-
type
- value container accepting values of typeType
. CreatesisSortedValue
containing passed values (for details see isSortedForType :: type). -
values
- value container accepting values of typeType
. CreatesisSortedValue
containing passed values (same as above) (for details see isSortedForType :: values).
#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;
}