Skip to content

Commit

Permalink
Make findIfNot function acting on types uniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Sep 4, 2024
1 parent 9b6199a commit 0752359
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions include/crap/algorithm.d/findifnottype.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstddef>

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

namespace crap
{
Expand All @@ -15,6 +16,9 @@ namespace crap
constexpr const static std :: size_t npos = 0u;
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 findIfNotType<Operator, Type>
Expand All @@ -23,6 +27,9 @@ namespace crap
constexpr const static std :: size_t npos = 1u;
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 findIfNotType
Expand All @@ -40,6 +47,9 @@ namespace crap
constexpr const static std :: size_t npos = sizeof...(Types);
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 @@ -63,19 +73,46 @@ typename crap :: findIfNotType <Operator> :: value_type () const noexcept
{
return crap :: findIfNotType <Operator> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

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

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

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

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

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

0 comments on commit 0752359

Please sign in to comment.