[PATCH] D48151: [CUDA] Make __host__/__device__ min/max overloads constexpr in C++14.

Justin Lebar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 29 15:33:01 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL336026: [CUDA] Make __host__/__device__ min/max overloads constexpr in C++14. (authored by jlebar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48151?vs=151248&id=153594#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48151

Files:
  cfe/trunk/lib/Headers/cuda_wrappers/algorithm


Index: cfe/trunk/lib/Headers/cuda_wrappers/algorithm
===================================================================
--- cfe/trunk/lib/Headers/cuda_wrappers/algorithm
+++ cfe/trunk/lib/Headers/cuda_wrappers/algorithm
@@ -67,34 +67,43 @@
 #endif
 #endif
 
+#pragma push_macro("_CPP14_CONSTEXPR")
+#if __cplusplus >= 201402L
+#define _CPP14_CONSTEXPR constexpr
+#else
+#define _CPP14_CONSTEXPR
+#endif
+
 template <class __T, class __Cmp>
 __attribute__((enable_if(true, "")))
-inline __host__ __device__ const __T &
+inline _CPP14_CONSTEXPR __host__ __device__ const __T &
 max(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__a, __b) ? __b : __a;
 }
 
 template <class __T>
 __attribute__((enable_if(true, "")))
-inline __host__ __device__ const __T &
+inline _CPP14_CONSTEXPR __host__ __device__ const __T &
 max(const __T &__a, const __T &__b) {
   return __a < __b ? __b : __a;
 }
 
 template <class __T, class __Cmp>
 __attribute__((enable_if(true, "")))
-inline __host__ __device__ const __T &
+inline _CPP14_CONSTEXPR __host__ __device__ const __T &
 min(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__b, __a) ? __b : __a;
 }
 
 template <class __T>
 __attribute__((enable_if(true, "")))
-inline __host__ __device__ const __T &
+inline _CPP14_CONSTEXPR __host__ __device__ const __T &
 min(const __T &__a, const __T &__b) {
   return __a < __b ? __a : __b;
 }
 
+#pragma pop_macro("_CPP14_CONSTEXPR")
+
 #ifdef _LIBCPP_END_NAMESPACE_STD
 _LIBCPP_END_NAMESPACE_STD
 #else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48151.153594.patch
Type: text/x-patch
Size: 1515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180629/94e400ae/attachment-0001.bin>


More information about the cfe-commits mailing list