Skip to content

Commit 3639cad

Browse files
committed
Refactor THRUST_STATIC_CONSTANT and rename it to
`THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT`.
1 parent 29e0592 commit 3639cad

3 files changed

Lines changed: 23 additions & 14 deletions

File tree

thrust/detail/config/cpp_compatibility.h

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,44 @@
3636
# define THRUST_DEFAULT = default;
3737
# define THRUST_NOEXCEPT noexcept
3838
# define THRUST_FINAL final
39-
# define THRUST_STATIC_CONSTANT static constexpr
4039
#else
4140
# define THRUST_CONSTEXPR
4241
# define THRUST_OVERRIDE
4342
# define THRUST_DEFAULT {}
4443
# define THRUST_NOEXCEPT throw()
4544
# define THRUST_FINAL
46-
# define THRUST_STATIC_CONSTANT static const
4745
#endif
4846

4947
#ifndef THRUST_NODISCARD
5048
# define THRUST_NODISCARD
5149
#endif
5250

51+
// FIXME: Combine THRUST_INLINE_CONSTANT and
52+
// THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT into one macro when NVCC properly
53+
// supports `constexpr` globals in host and device code.
5354
#ifdef __CUDA_ARCH__
54-
# if THRUST_CPP_DIALECT >= 2017
55-
# define THRUST_INLINE_CONSTANT inline const __device__
56-
# elif THRUST_CPP_DIALECT >= 2011
57-
# define THRUST_INLINE_CONSTANT static const __device__
55+
// FIXME: Add this when NVCC supports inline variables.
56+
//# if THRUST_CPP_DIALECT >= 2017
57+
//# define THRUST_INLINE_CONSTANT inline constexpr
58+
//# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr
59+
# if THRUST_CPP_DIALECT >= 2011
60+
# define THRUST_INLINE_CONSTANT static constexpr
61+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr
5862
# else
59-
# define THRUST_INLINE_CONSTANT static const __device__
63+
# define THRUST_INLINE_CONSTANT static const __device__
64+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static const
6065
# endif
6166
#else
62-
# if THRUST_CPP_DIALECT >= 2017
63-
# define THRUST_INLINE_CONSTANT inline constexpr
64-
# elif THRUST_CPP_DIALECT >= 2011
65-
# define THRUST_INLINE_CONSTANT static constexpr
67+
// FIXME: Add this when NVCC supports inline variables.
68+
//# if THRUST_CPP_DIALECT >= 2017
69+
//# define THRUST_INLINE_CONSTANT inline constexpr
70+
//# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr
71+
# if THRUST_CPP_DIALECT >= 2011
72+
# define THRUST_INLINE_CONSTANT static constexpr
73+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr
6674
# else
67-
# define THRUST_INLINE_CONSTANT static const
75+
# define THRUST_INLINE_CONSTANT static const
76+
# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static const
6877
# endif
6978
#endif
7079

thrust/detail/static_assert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace detail
3737
template <typename, bool x>
3838
struct depend_on_instantiation
3939
{
40-
THRUST_STATIC_CONSTANT bool value = x;
40+
THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT bool value = x;
4141
};
4242

4343
#if THRUST_CPP_DIALECT >= 2011

thrust/detail/type_traits.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace detail
4040
template<typename T, T v>
4141
struct integral_constant
4242
{
43-
THRUST_STATIC_CONSTANT T value = v;
43+
THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT T value = v;
4444

4545
typedef T value_type;
4646
typedef integral_constant<T, v> type;

0 commit comments

Comments
 (0)