Skip to content

Commit

Permalink
Make isPartitioned function acting on types uuniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Sep 9, 2024
1 parent 2cd658b commit 89eeafe
Showing 1 changed file with 58 additions and 5 deletions.
63 changes: 58 additions & 5 deletions include/crap/algorithm.d/ispartitionedtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@
#include "noneoftype.h"
#include "partitionpointtype.h"
#include "../utility.d/typelist.h"
#include "../version.d/libintegralconstantcallable.h"

namespace crap
{
template <template <class> class, class...> struct isPartitionedType;

template <template <class> class Operator> struct isPartitionedType<Operator>
template <template <class> class Operator>
struct isPartitionedType<Operator>
{
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 <template <class> class Operator, class Type> struct isPartitionedType<Operator, Type>
template <template <class> class Operator, class Type>
struct isPartitionedType<Operator, Type>
{
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 <template <class> class Operator, class Type1, class Type2>
Expand All @@ -29,6 +38,9 @@ namespace crap
constexpr const static bool value = Operator <Type1> :: 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 <template <class> class Operator, class ... Types> struct isPartitionedType
Expand All @@ -38,9 +50,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 <template <class> class Operator, class ... Types>
Expand All @@ -50,11 +66,12 @@ namespace crap
private:
template <class ... SubTypes> using noneOf = noneOfType<Operator, SubTypes...>;
public:
constexpr const static bool value = typeList <Types...> :: template since<Value + 1u, noneOf> :: value;
constexpr const static bool value =
typeList <Types...> :: template since <Value + 1u, noneOf> :: value;
};

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

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

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

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

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

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

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

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

0 comments on commit 89eeafe

Please sign in to comment.