Skip to content

Commit

Permalink
Make maxElement function acting on types uniformly callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Aug 27, 2024
1 parent b45d1cc commit 1768b9b
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions include/crap/algorithm.d/maxelementtype.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#ifndef CRAP_ALGORITHM_MAXELEMENTTYPE
#define CRAP_ALGORITHM_MAXELEMENTTYPE

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

#include <cstddef>
#include <type_traits>

#include "../utility.d/bisecttype.h"

namespace crap
{
template <template <class, class> class, class...> struct maxElementType;
Expand All @@ -16,6 +17,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 <template <class, class> class Operator, class Type>
Expand All @@ -29,6 +33,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 <template <class, class> class Operator, class Type1, class Type2>
Expand All @@ -42,6 +49,9 @@ namespace crap
constexpr const static std :: size_t npos = 2u;
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> class Operator, class ... Types> struct maxElementType
Expand All @@ -60,6 +70,9 @@ namespace crap
constexpr const static std :: size_t npos = sizeof...(Types);
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 @@ -69,26 +82,62 @@ template <template <class, class> class Operator>
{
return crap :: maxElementType <Operator> :: value;
};
#if (crap_lib_integral_constant_callable >= 201304L)

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

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

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

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

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

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

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

0 comments on commit 1768b9b

Please sign in to comment.