Skip to content

Commit

Permalink
Make noneOf function acting on types uniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Aug 20, 2024
1 parent eca7df0 commit d720ef5
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions include/crap/algorithm.d/noneoftype.h
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
#ifndef CRAP_ALGORITHM_NONEOFTYPE
#define CRAP_ALGORITHM_NONEOFTYPE

#include <type_traits>

#include "../functional.d/logicalnotvalue.h"
#include "../functional.d/logicalorvalue.h"
#include "../utility.d/commontype.h"
#include "../version.d/libintegralconstantcallable.h"

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

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

template <template <class> class Operator, class ... Types> struct noneOfType
{
private:
using resultType = typename commonType <decltype(Operator <Types> :: value)...> :: type;
constexpr const static auto orValue = logicalOrValue <resultType, static_cast<resultType>(Operator <Types> :: value)...> :: value;
constexpr const static auto orValue =
logicalOrValue <resultType, static_cast<resultType>(Operator <Types> :: value)...> :: value;
public:
constexpr const static auto value = logicalNotValue <decltype(orValue), orValue> :: 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>
inline constexpr crap :: noneOfType <Operator> :: operator
typename crap :: noneOfType <Operator> :: value_type () const noexcept
template <template <class> class Operator, class ... Types>
inline constexpr crap :: noneOfType <Operator, Types...> :: operator
typename crap :: noneOfType <Operator, Types...> :: value_type () const noexcept
{
return crap :: noneOfType <Operator> :: value;
return crap :: noneOfType <Operator, Types...> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

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

0 comments on commit d720ef5

Please sign in to comment.