diff options
author | Justin Lebar <jlebar@google.com> | 2018-06-29 22:28:09 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2018-06-29 22:28:09 +0000 |
commit | 2a192abaec7aa25d0368e6b90bf694782a69cd2b (patch) | |
tree | 2f9bff53a5c19d3feec825c75bc8fe9c5ff8f4f3 /clang/lib/Headers/cuda_wrappers/algorithm | |
parent | 5cb41c2acf83c6bbdffac928d40939c08c7f5aad (diff) | |
download | bcm5719-llvm-2a192abaec7aa25d0368e6b90bf694782a69cd2b.tar.gz bcm5719-llvm-2a192abaec7aa25d0368e6b90bf694782a69cd2b.zip |
[CUDA] Make __host__/__device__ min/max overloads constexpr in C++14.
Summary: Tests in a separate change to the test-suite.
Reviewers: rsmith, tra
Subscribers: lahwaacz, sanjoy, cfe-commits
Differential Revision: https://reviews.llvm.org/D48151
llvm-svn: 336026
Diffstat (limited to 'clang/lib/Headers/cuda_wrappers/algorithm')
-rw-r--r-- | clang/lib/Headers/cuda_wrappers/algorithm | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/Headers/cuda_wrappers/algorithm b/clang/lib/Headers/cuda_wrappers/algorithm index d8658bf1c7d..01af18360d8 100644 --- a/clang/lib/Headers/cuda_wrappers/algorithm +++ b/clang/lib/Headers/cuda_wrappers/algorithm @@ -67,34 +67,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #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 |