Skip to content

Commit

Permalink
Make isPartitioned function acting on values uniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Sep 9, 2024
1 parent b832ed7 commit 2cd658b
Showing 1 changed file with 56 additions and 4 deletions.
60 changes: 56 additions & 4 deletions include/crap/algorithm.d/ispartitionedvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "noneofvalue.h"
#include "partitionpointvalue.h"
#include "../utility.d/valuelist.h"
#include "../version.d/libintegralconstantcallable.h"

namespace crap
{
Expand All @@ -14,13 +15,20 @@ 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> class Operator, Type Value> struct isPartitionedValue<Type, Operator, Value>
template <class Type, template <Type> class Operator, Type Value>
struct isPartitionedValue<Type, Operator, Value>
{
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> class Operator, Type Value1, Type Value2>
Expand All @@ -29,6 +37,9 @@ namespace crap
constexpr const static bool value = Operator <Value1> :: 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
};

template <class Type, template <Type> class Operator, Type ... Values> struct isPartitionedValue
Expand All @@ -38,9 +49,13 @@ namespace crap
template <std :: size_t Value, std :: size_t Npos> struct checkTail;
template <std :: size_t Npos> struct checkTail<Npos, Npos>;
public:
constexpr const static bool value = checkTail <partitionPoint :: value, partitionPoint :: npos> :: value;
constexpr const static bool value =
checkTail <partitionPoint :: value, partitionPoint :: npos> :: 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
};

template <class Type, template <Type> class Operator, Type ... Values>
Expand All @@ -50,11 +65,12 @@ namespace crap
private:
template <Type ... SubValues> using noneOf = noneOfValue<Type, Operator, SubValues...>;
public:
constexpr const static bool value = valueList <Type, Values...> :: template since<Value + 1u, noneOf> :: value;
constexpr const static bool value =
valueList <Type, Values...> :: template since <Value + 1u, noneOf> :: value;
};

template <class Type, template <Type> class Operator, Type ... Values> template <std :: size_t Npos>
struct isPartitionedValue <Type, Operator, Values...> :: template checkTail<Npos, Npos>
struct isPartitionedValue <Type, Operator, Values...> :: checkTail<Npos, Npos>
{
constexpr const static bool value = true;
};
Expand All @@ -66,26 +82,62 @@ template <class Type, template <Type> class Operator>
{
return crap :: isPartitionedValue <Type, Operator> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

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

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

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

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

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

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

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

0 comments on commit 2cd658b

Please sign in to comment.