Skip to content

Commit

Permalink
Make anyOf function acting on values uniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Aug 20, 2024
1 parent 9c8f612 commit 330adf4
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions include/crap/algorithm.d/anyofvalue.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#ifndef CRAP_ALGORITHM_ANYOFVALUE
#define CRAP_ALGORITHM_ANYOFVALUE

#include <type_traits>

#include "../functional.d/logicalorvalue.h"
#include "../utility.d/commontype.h"

#include <type_traits>
#include "../version.d/libintegralconstantcallable.h"

namespace crap
{
template <class Type, template <Type> class, Type...> struct anyOfValue;

template <class Type, template <Type> class Operator> struct anyOfValue<Type, Operator>
{
constexpr const static bool value = false;
using value_type = decltype(value);
constexpr operator value_type () const noexcept;
};
: std :: integral_constant<bool, false> {};

template <class Type, template <Type> class Operator, Type ... Values> struct anyOfValue
{
Expand All @@ -26,21 +23,26 @@ namespace crap
logicalOrValue <resultType, static_cast<resultType>(Operator <Values> :: value)...> :: 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>
inline constexpr crap :: anyOfValue <Type, Operator> :: operator
typename crap :: anyOfValue <Type, Operator> :: value_type () const noexcept
{
return crap :: anyOfValue <Type, Operator> :: value;
};

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

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

0 comments on commit 330adf4

Please sign in to comment.