Skip to content

Commit

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

#include "../utility.d/bisectvalue.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 <class Type, template <Type> class Operator, Type Value> struct findIfValue<Type, Operator, Value>
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 <class Type, template <Type> class Operator, Type ... Values> struct findIfValue
Expand All @@ -38,6 +45,9 @@ namespace crap
constexpr const static std :: size_t npos = sizeof...(Values);
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 Down Expand Up @@ -65,19 +75,46 @@ typename crap :: findIfValue <Type, Operator> :: value_type () const noexcept
{
return crap :: findIfValue <Type, Operator> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

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

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

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

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

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

0 comments on commit e76493e

Please sign in to comment.