44#include < type_traits>
55#include < array>
66#include < utility>
7+ #ifdef MDSPAN_IMPL_HAS_CUDA
8+ #include < cuda/std/limits>
9+ #else
10+ #include < limits>
11+ #endif
712#include " macros.hpp"
813
914namespace MDSPAN_IMPL_STANDARD_NAMESPACE {
@@ -198,8 +203,13 @@ MDSPAN_INLINE_FUNCTION constexpr bool cmp_greater_equal(T t, U u) noexcept {
198203
199204template <class R , class T >
200205MDSPAN_INLINE_FUNCTION constexpr bool in_range (T t) noexcept {
201- return cmp_greater_equal (t, std::numeric_limits<R>::min ()) &&
202- cmp_less_equal (t, std::numeric_limits<R>::max ());
206+ #ifdef MDSPAN_IMPL_HAS_CUDA
207+ using cuda::std::numeric_limits;
208+ #else
209+ using std::numeric_limits;
210+ #endif
211+ return cmp_greater_equal (t, numeric_limits<R>::min ()) &&
212+ cmp_less_equal (t, numeric_limits<R>::max ());
203213}
204214
205215template <typename T >
@@ -216,7 +226,12 @@ check_mul_result_is_nonnegative_and_representable(T a, T b) {
216226 if constexpr (std::is_signed_v<T>) {
217227 if ( a < 0 || b < 0 ) return false ;
218228 }
219- return a <= std::numeric_limits<T>::max () / b;
229+ #ifdef MDSPAN_IMPL_HAS_CUDA
230+ using cuda::std::numeric_limits;
231+ #else
232+ using std::numeric_limits;
233+ #endif
234+ return a <= numeric_limits<T>::max () / b;
220235#endif
221236}
222237#endif
0 commit comments