Skip to content

Commit

Permalink
Make allOf 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 330adf4 commit 109c618
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions include/crap/algorithm.d/alloftype.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#ifndef CRAP_ALGORITHM_ALLOFTYPE
#define CRAP_ALGORITHM_ALLOFTYPE

#include <type_traits>

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

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

template <template <class> class Operator> struct allOfType<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 allOfType
{
Expand All @@ -23,21 +22,26 @@ namespace crap
constexpr const static auto value = logicalAndValue <resultType, static_cast<resultType>(Operator <Types> :: 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 <template <class> class Operator>
inline constexpr crap :: allOfType <Operator> :: operator
typename crap :: allOfType <Operator> :: value_type () const noexcept
template <template <class> class Operator, class ... Types>
inline constexpr crap :: allOfType <Operator, Types...> :: operator
typename crap :: allOfType <Operator, Types...> :: value_type () const noexcept
{
return crap :: allOfType <Operator> :: value;
return crap :: allOfType <Operator, Types...> :: value;
}
#if (crap_lib_integral_constant_callable >= 201304L)

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

0 comments on commit 109c618

Please sign in to comment.