Skip to content

Commit

Permalink
Add adjacentFind acting on values uniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Aug 26, 2024
1 parent abca09c commit a2128db
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions include/crap/algorithm.d/adjacentfindvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CRAP_ALGORITHM_ADJACENTFINDVALUE

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

namespace crap
{
Expand All @@ -13,6 +14,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, Type> class Operator, Type Value> struct adjacentFindValue<Type, Operator, Value>
Expand All @@ -21,6 +25,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, Type> class Operator, Type ... Values> struct adjacentFindValue
Expand All @@ -40,6 +47,9 @@ namespace crap
constexpr const static std :: size_t npos = (lower :: npos) + (upper :: npos);
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 @@ -49,19 +59,46 @@ template <class Type, template <Type, Type> class Operator>
{
return crap :: adjacentFindValue <Type, Operator> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

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

template <class Type, template <Type, Type> class Operator, Type Value>
inline constexpr crap :: adjacentFindValue <Type, Operator, Value> :: operator
typename crap :: adjacentFindValue <Type, Operator, Value> :: value_type () const noexcept
{
return crap :: adjacentFindValue <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 :: adjacentFindValue <Type, Operator, Value> :: value_type
crap :: adjacentFindValue <Type, Operator, Value> :: operator () () const noexcept
{
return crap :: adjacentFindValue <Type, Operator, Value> :: value;
}
#endif

template <class Type, template <Type, Type> class Operator, Type ... Values>
inline constexpr crap :: adjacentFindValue <Type, Operator, Values...> :: operator
typename crap :: adjacentFindValue <Type, Operator, Values...> :: value_type () const noexcept
{
return crap :: adjacentFindValue <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 :: adjacentFindValue <Type, Operator, Values...> :: value_type
crap :: adjacentFindValue <Type, Operator, Values...> :: operator () () const noexcept
{
return crap :: adjacentFindValue <Type, Operator, Values...> :: value;
}
#endif
#endif

0 comments on commit a2128db

Please sign in to comment.