Skip to content

Commit df12df7

Browse files
committed
Try and fix MSVC issues
1 parent 979d581 commit df12df7

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

libcudacxx/include/cuda/std/inplace_vector

+6-6
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ struct __inplace_vector_base : __inplace_vector_destruct_base<_Tp, _Capacity, _S
286286
// [containers.sequences.inplace.vector.members] size/capacity
287287
_LIBCUDACXX_INLINE_VISIBILITY constexpr void __change_size(const ptrdiff_t __count) noexcept
288288
{
289-
this->__size_ += __count;
289+
this->__size_ += static_cast<__size_type>(__count);
290290
}
291291

292292
_CCCL_NODISCARD _LIBCUDACXX_INLINE_VISIBILITY constexpr size_type size() const noexcept
@@ -497,7 +497,7 @@ struct __inplace_vector_base<_Tp, _Capacity, __inplace_vector_specialization::__
497497
// [containers.sequences.inplace.vector.members] size/capacity
498498
_LIBCUDACXX_INLINE_VISIBILITY constexpr void __change_size(const ptrdiff_t __count) noexcept
499499
{
500-
__size_ += __count;
500+
__size_ += static_cast<__size_type>(__count);
501501
}
502502

503503
_CCCL_NODISCARD _LIBCUDACXX_INLINE_VISIBILITY constexpr size_type size() const noexcept
@@ -1771,8 +1771,8 @@ public:
17711771

17721772
// [containers.sequences.inplace.vector.erasure]
17731773
template <class _Up>
1774-
_LIBCUDACXX_INLINE_VISIBILITY friend constexpr size_type
1775-
erase(inplace_vector& __cont, const _Up& __value) noexcept(_CCCL_TRAIT(is_nothrow_move_assignable, _Tp))
1774+
_LIBCUDACXX_INLINE_VISIBILITY friend constexpr size_type erase(inplace_vector& __cont, const _Up& __value) noexcept(
1775+
_CCCL_TRAIT(is_nothrow_move_assignable, typename inplace_vector::value_type)) // MSVC2017 cannot handle _Tp here
17761776
{
17771777
_CCCL_IF_CONSTEXPR (_Capacity == 0)
17781778
{
@@ -1785,8 +1785,8 @@ public:
17851785
}
17861786

17871787
template <class _Pred>
1788-
_LIBCUDACXX_INLINE_VISIBILITY friend constexpr size_type
1789-
erase_if(inplace_vector& __cont, _Pred __pred) noexcept(_CCCL_TRAIT(is_nothrow_move_assignable, _Tp))
1788+
_LIBCUDACXX_INLINE_VISIBILITY friend constexpr size_type erase_if(inplace_vector& __cont, _Pred __pred) noexcept(
1789+
_CCCL_TRAIT(is_nothrow_move_assignable, typename inplace_vector::value_type)) // MSVC2017 cannot handle _Tp here
17901790
{
17911791
_CCCL_IF_CONSTEXPR (_Capacity == 0)
17921792
{

libcudacxx/test/libcudacxx/std/containers/sequences/inplace_vector/constructor.pass.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,28 @@ __host__ __device__ constexpr void test_size()
106106
{ // inplace_vector<T, 0> can be constructed from a size
107107
cuda::std::inplace_vector<T, 0> vec(0);
108108
assert(vec.empty());
109-
#if !defined(TEST_COMPILER_GCC) || __GNUC__ >= 10
109+
#if (!defined(TEST_COMPILER_GCC) || __GNUC__ >= 10) && !defined(TEST_COMPILER_MSVC_2017)
110110
static_assert(!noexcept(cuda::std::inplace_vector<T, 0>(0)), "");
111-
#endif // !TEST_COMPILER_GCC < 10
111+
#endif // !TEST_COMPILER_GCC < 10 && !TEST_COMPILER_MSVC_2017
112112
}
113113

114114
using inplace_vector = cuda::std::inplace_vector<T, 42>;
115115
{ // inplace_vector<T, N> can be constructed from a size, is empty if zero
116116
inplace_vector vec(0);
117117
assert(vec.empty());
118-
#if !defined(TEST_COMPILER_GCC) || __GNUC__ >= 10
118+
#if (!defined(TEST_COMPILER_GCC) || __GNUC__ >= 10) && !defined(TEST_COMPILER_MSVC_2017)
119119
static_assert(!noexcept(inplace_vector(0)), "");
120-
#endif // !TEST_COMPILER_GCC < 10
120+
#endif // !TEST_COMPILER_GCC < 10 && !TEST_COMPILER_MSVC_2017
121121
}
122122

123123
{ // inplace_vector<T, N> can be constructed from a size, elements are value initialized
124124
constexpr size_t size{3};
125125
inplace_vector vec(size);
126126
assert(!vec.empty());
127127
assert(equal_range(vec, cuda::std::array<T, size>{T(0), T(0), T(0)}));
128-
#if !defined(TEST_COMPILER_GCC) || __GNUC__ >= 10
128+
#if (!defined(TEST_COMPILER_GCC) || __GNUC__ >= 10) && !defined(TEST_COMPILER_MSVC_2017)
129129
static_assert(!noexcept(inplace_vector(3)), "");
130-
#endif // !TEST_COMPILER_GCC < 10
130+
#endif // !TEST_COMPILER_GCC < 10 && !TEST_COMPILER_MSVC_2017
131131
}
132132
}
133133

@@ -137,28 +137,28 @@ __host__ __device__ constexpr void test_size_value()
137137
{ // inplace_vector<T, 0> can be constructed from a size and a const T&
138138
cuda::std::inplace_vector<T, 0> vec(0, T(42));
139139
assert(vec.empty());
140-
#if !defined(TEST_COMPILER_GCC) || __GNUC__ >= 10
140+
#if (!defined(TEST_COMPILER_GCC) || __GNUC__ >= 10) && !defined(TEST_COMPILER_MSVC_2017)
141141
static_assert(!noexcept(cuda::std::inplace_vector<T, 0>(0, T(42))), "");
142-
#endif // !TEST_COMPILER_GCC < 10
142+
#endif // !TEST_COMPILER_GCC < 10 && !TEST_COMPILER_MSVC_2017
143143
}
144144

145145
using inplace_vector = cuda::std::inplace_vector<T, 42>;
146146
{ // inplace_vector<T, N> can be constructed from a size and a const T&, is empty if zero
147147
inplace_vector vec(0, T(42));
148148
assert(vec.empty());
149-
#if !defined(TEST_COMPILER_GCC) || __GNUC__ >= 10
149+
#if (!defined(TEST_COMPILER_GCC) || __GNUC__ >= 10) && !defined(TEST_COMPILER_MSVC_2017)
150150
static_assert(!noexcept(inplace_vector(0, T(42))), "");
151-
#endif // !TEST_COMPILER_GCC < 10
151+
#endif // !TEST_COMPILER_GCC < 10 && !TEST_COMPILER_MSVC_2017
152152
}
153153

154154
{ // inplace_vector<T, N> can be constructed from a size and a const T&, elements are copied
155155
constexpr size_t size{3};
156156
inplace_vector vec(size, T(42));
157157
assert(!vec.empty());
158158
assert(equal_range(vec, cuda::std::array<T, size>{T(42), T(42), T(42)}));
159-
#if !defined(TEST_COMPILER_GCC) || __GNUC__ >= 10
159+
#if (!defined(TEST_COMPILER_GCC) || __GNUC__ >= 10) && !defined(TEST_COMPILER_MSVC_2017)
160160
static_assert(!noexcept(inplace_vector(3, T(42))), "");
161-
#endif // !TEST_COMPILER_GCC < 10
161+
#endif // !TEST_COMPILER_GCC < 10 && !TEST_COMPILER_MSVC_2017
162162
}
163163
}
164164

libcudacxx/test/libcudacxx/std/containers/sequences/inplace_vector/properties.pass.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ __host__ __device__ void test()
5252
== cuda::std::numeric_limits<cuda::std::uint16_t>::max() + 1 + sizeof(cuda::std::uint32_t),
5353
"");
5454

55+
#if !defined(TEST_COMPILER_MSVC) // too large array
5556
// There is an overflow issue when using cuda::std::numeric_limits<cuda::std::uint32_t>::max() directly
5657
constexpr size_t uint32_t_max = cuda::std::numeric_limits<cuda::std::uint32_t>::max();
5758
static_assert(sizeof(cuda::std::inplace_vector<char, uint32_t_max>) == uint32_t_max + 1 + sizeof(cuda::std::uint32_t),
5859
"");
5960
static_assert(
6061
sizeof(cuda::std::inplace_vector<char, uint32_t_max + 1>) == uint32_t_max + 1 + sizeof(cuda::std::uint64_t), "");
62+
#endif // !TEST_COMPILER_MSVC
6163

6264
// Check the type aliases
6365
using inplace_vector = cuda::std::inplace_vector<int, 42>;

0 commit comments

Comments
 (0)