Skip to content

Commit

Permalink
Use correct form of enable_if for functions (celeritas-project#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Mar 1, 2024
1 parent e0340e2 commit 2f8cc5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/corecel/math/Algorithms.hh
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ CELER_FORCEINLINE_FUNCTION void sort(RandomAccessIt first, RandomAccessIt last)
#ifndef __CUDA_ARCH__
template<class T>
#else
template<class T, typename = std::enable_if_t<!std::is_arithmetic<T>::value>>
template<class T, std::enable_if_t<!std::is_arithmetic<T>::value, bool> = true>
#endif
CELER_CONSTEXPR_FUNCTION T const& max(T const& a, T const& b) noexcept
{
return (b > a) ? b : a;
}

#ifdef __CUDA_ARCH__
template<class T, typename = std::enable_if_t<std::is_arithmetic<T>::value>>
template<class T, std::enable_if_t<std::is_arithmetic<T>::value, bool> = true>
CELER_CONSTEXPR_FUNCTION T max(T a, T b) noexcept
{
return ::max(a, b);
Expand All @@ -328,15 +328,15 @@ CELER_CONSTEXPR_FUNCTION T max(T a, T b) noexcept
#ifndef __CUDA_ARCH__
template<class T>
#else
template<class T, typename = std::enable_if_t<!std::is_arithmetic<T>::value>>
template<class T, std::enable_if_t<!std::is_arithmetic<T>::value, bool> = true>
#endif
CELER_CONSTEXPR_FUNCTION T const& min(T const& a, T const& b) noexcept
{
return (b < a) ? b : a;
}

#ifdef __CUDA_ARCH__
template<class T, typename = std::enable_if_t<std::is_arithmetic<T>::value>>
template<class T, std::enable_if_t<std::is_arithmetic<T>::value, bool> = true>
CELER_CONSTEXPR_FUNCTION T min(T a, T b) noexcept
{
return ::min(a, b);
Expand Down Expand Up @@ -443,7 +443,7 @@ CELER_CONSTEXPR_FUNCTION T ipow(T v) noexcept
assert(9.0 == fastpow(3.0, 2.0));
\endcode
*/
template<class T, typename = std::enable_if_t<std::is_floating_point<T>::value>>
template<class T, std::enable_if_t<std::is_floating_point<T>::value, bool> = true>
inline CELER_FUNCTION T fastpow(T a, T b)
{
CELER_EXPECT(a > 0 || (a == 0 && b != 0));
Expand Down
4 changes: 2 additions & 2 deletions src/corecel/sys/MpiOperations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ allreduce(MpiCommunicator const& comm, Operation op, Span<T, N> data);

//---------------------------------------------------------------------------//
// Perform reduction on a fundamental scalar and return the result
template<class T, std::enable_if_t<std::is_fundamental<T>::value, T*> = nullptr>
template<class T, std::enable_if_t<std::is_fundamental<T>::value, bool> = true>
inline T allreduce(MpiCommunicator const& comm, Operation op, T const src);

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -147,7 +147,7 @@ void allreduce(MpiCommunicator const& comm,
/*!
* Perform reduction on a fundamental scalar and return the result.
*/
template<class T, std::enable_if_t<std::is_fundamental<T>::value, T*>>
template<class T, std::enable_if_t<std::is_fundamental<T>::value, bool>>
T allreduce(MpiCommunicator const& comm, Operation op, T const src)
{
T dst{};
Expand Down

0 comments on commit 2f8cc5e

Please sign in to comment.