Skip to content

Commit

Permalink
Make isSorted function acting on values uniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Aug 27, 2024
1 parent 4ade78a commit 6a21a30
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions include/crap/algorithm.d/issortedvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CRAP_ALGORITHM_ISSORTEDVALUE

#include "../utility.d/valuelist.h"
#include "../version.d/libintegralconstantcallable.h"

namespace crap
{
Expand All @@ -12,13 +13,19 @@ namespace crap
constexpr const static bool value = true;
using value_type = decltype(value);
constexpr operator value_type () const noexcept;
#if (crap_lib_integral_constant_callable >= 201304L)
constexpr value_type operator () () const noexcept;
#endif
};

template <class Type, template <Type, Type> class Operator, Type Value1> struct isSortedValue<Type, Operator, Value1>
{
constexpr const static bool value = true;
using value_type = decltype(value);
constexpr operator value_type () const noexcept;
#if (crap_lib_integral_constant_callable >= 201304L)
constexpr value_type operator () () const noexcept;
#endif
};

template <class Type, template <Type, Type> class Operator, Type ... Values> struct isSortedValue
Expand All @@ -36,6 +43,9 @@ namespace crap
constexpr const static bool value = (lower :: value) && borderSorted && (upper :: value);
using value_type = decltype(value);
constexpr operator value_type () const noexcept;
#if (crap_lib_integral_constant_callable >= 201304L)
constexpr value_type operator () () const noexcept;
#endif
};
}

Expand All @@ -45,19 +55,46 @@ template <class Type, template <Type, Type> class Operator>
{
return crap :: isSortedValue <Type, Operator> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

template <class Type, template <Type, Type> class Operator>
inline constexpr typename crap :: isSortedValue <Type, Operator> :: value_type
crap :: isSortedValue <Type, Operator> :: operator () () const noexcept
{
return crap :: isSortedValue <Type, Operator> :: value;
}
#endif

template <class Type, template <Type, Type> class Operator, Type Value>
inline constexpr crap :: isSortedValue <Type, Operator, Value> :: operator
typename crap :: isSortedValue <Type, Operator, Value> :: value_type () const noexcept
{
return crap :: isSortedValue <Type, Operator, Value> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

template <class Type, template <Type, Type> class Operator, Type Value>
inline constexpr typename crap :: isSortedValue <Type, Operator, Value> :: value_type
crap :: isSortedValue <Type, Operator, Value> :: operator () () const noexcept
{
return crap :: isSortedValue <Type, Operator, Value> :: value;
}
#endif

template <class Type, template <Type, Type> class Operator, Type ... Values>
inline constexpr crap :: isSortedValue <Type, Operator, Values...> :: operator
typename crap :: isSortedValue <Type, Operator, Values...> :: value_type () const noexcept
{
return crap :: isSortedValue <Type, Operator, Values...> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

template <class Type, template <Type, Type> class Operator, Type ... Values>
inline constexpr typename crap :: isSortedValue <Type, Operator, Values...> :: value_type
crap :: isSortedValue <Type, Operator, Values...> :: operator () () const noexcept
{
return crap :: isSortedValue <Type, Operator, Values...> :: value;
}
#endif
#endif

0 comments on commit 6a21a30

Please sign in to comment.