Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework our tuple implementation to work with older MSVC #530

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ int main(int, char**)
assert(cuda::std::get<1>(t1) == int('a'));
assert(cuda::std::get<2>(t1).id_ == 2);
}
#if !defined(TEST_COMPILER_MSVC_2017)
{
// Test that tuple evaluates correctly applies an lvalue reference
// before evaluating is_assignable (ie 'is_assignable<int&, int&>')
Expand All @@ -88,6 +87,5 @@ int main(int, char**)
assert(cuda::std::get<0>(t) == 43);
assert(&cuda::std::get<0>(t) == &x);
}
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ int main(int, char**)
assert(cuda::std::get<1>(t1) == int('a'));
assert(cuda::std::get<2>(t1)->id_ == 3);
}*/
#if !defined(TEST_COMPILER_MSVC_2017)
{
// Test that tuple evaluates correctly applies an lvalue reference
// before evaluating is_assignable (ie 'is_assignable<int&, int&&>')
Expand All @@ -112,6 +111,5 @@ int main(int, char**)
assert(cuda::std::get<0>(t) == 43);
assert(&cuda::std::get<0>(t) == &x);
}
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ int main(int, char**)
assert(cuda::std::get<2>(t) == "some text");
}
*/
#if !defined(TEST_COMPILER_MSVC_2017)
{
// test reference assignment.
using T = cuda::std::tuple<int&, int&&>;
Expand All @@ -88,7 +87,6 @@ int main(int, char**)
assert(cuda::std::get<1>(t) == y2);
assert(&cuda::std::get<1>(t) == &y);
}
#endif
// cuda::std::unique_ptr not supported
/*
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ int main(int, char**)
t = cuda::std::move(t0);
unused(t);
}
#if !defined(TEST_COMPILER_MSVC_2017)
{
typedef cuda::std::tuple<MoveOnly> T;
T t0(MoveOnly(0));
Expand Down Expand Up @@ -97,7 +96,6 @@ int main(int, char**)
assert(cuda::std::get<1>(t) == y2);
assert(&cuda::std::get<1>(t) == &y);
}
#endif
// cuda::std::unique_ptr not supported
/*
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ int main(int, char**)
// cuda::std::allocator not supported
// cuda::std::allocator<int> A;
{ // rvalue reference
#if !defined(TEST_COMPILER_MSVC_2017)
T t1(42);
cuda::std::tuple< T&& > t2(cuda::std::move(t1));
assert(&cuda::std::get<0>(t2) == &t1);
#endif
}
{ // const lvalue reference
T t1(42);
Expand All @@ -119,12 +117,10 @@ int main(int, char**)
assert(&cuda::std::get<0>(t2) == &t1);
}
{ // const rvalue reference
#if !defined(TEST_COMPILER_MSVC_2017)
T t1(42);

cuda::std::tuple< T const && > t2(cuda::std::move(t1));
assert(&cuda::std::get<0>(t2) == &t1);
#endif
}
// cuda::std::allocator not supported
/*
Expand Down Expand Up @@ -159,20 +155,16 @@ int main(int, char**)
// the 'tuple(UTypes...)' ctor should be chosen and 'UDT' constructed from
// 'tuple<T>'.
{
#if !defined(TEST_COMPILER_MSVC_2017)
using VT = ConstructibleFromTupleAndInt;
cuda::std::tuple<int> t1(42);
cuda::std::tuple<VT> t2(t1);
assert(cuda::std::get<0>(t2).state == VT::FromTuple);
#endif
}
{
#if !defined(TEST_COMPILER_MSVC_2017)
using VT = ConvertibleFromTupleAndInt;
cuda::std::tuple<int> t1(42);
cuda::std::tuple<VT> t2 = {t1};
assert(cuda::std::get<0>(t2).state == VT::FromTuple);
#endif
}
// Test constructing a 1-tuple of the form tuple<UDT> from another 1-tuple
// 'tuple<T>' where UDT cannot be constructed from 'tuple<T>' but can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ int main(int, char**)
T t(cuda::std::allocator_arg, A1<int>(), cuda::std::move(t0));
}
{
#if !defined(TEST_COMPILER_MSVC_2017)
typedef cuda::std::tuple<MoveOnly> T;
T t0(MoveOnly(0));
T t(cuda::std::allocator_arg, A1<int>(), cuda::std::move(t0));
assert(cuda::std::get<0>(t) == 0);
#endif
}
{
typedef cuda::std::tuple<alloc_first> T;
Expand All @@ -59,18 +57,15 @@ int main(int, char**)
// testing extensions
#ifdef _LIBCUDACXX_VERSION
{
#if !defined(TEST_COMPILER_MSVC_2017)
typedef cuda::std::tuple<MoveOnly, alloc_first> T;
T t0(0 ,1);
alloc_first::allocator_constructed() = false;
T t(cuda::std::allocator_arg, A1<int>(5), cuda::std::move(t0));
assert(alloc_first::allocator_constructed());
assert(cuda::std::get<0>(t) == 0);
assert(cuda::std::get<1>(t) == 1);
#endif
}
{
#if !defined(TEST_COMPILER_MSVC_2017)
typedef cuda::std::tuple<MoveOnly, alloc_first, alloc_last> T;
T t0(1, 2, 3);
alloc_first::allocator_constructed() = false;
Expand All @@ -81,7 +76,6 @@ int main(int, char**)
assert(cuda::std::get<0>(t) == 1);
assert(cuda::std::get<1>(t) == 2);
assert(cuda::std::get<2>(t) == 3);
#endif
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,9 @@ int main(int, char**)
static_assert(cuda::std::is_convertible<ExplicitTwo&&, ExplicitTwo>::value, "");
static_assert(cuda::std::is_convertible<cuda::std::tuple<ExplicitTwo&&>&&, const cuda::std::tuple<ExplicitTwo>&>::value, "");

#if !defined(TEST_COMPILER_MSVC_2017)
ExplicitTwo e;
cuda::std::tuple<ExplicitTwo> t = cuda::std::tuple<ExplicitTwo&&>(cuda::std::move(e));
((void)t);
#endif
}
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ __host__ __device__ void test_sfinae() {
}
// args constructors
{
#if !defined(TEST_COMPILER_MSVC_2017)
static_assert(cuda::std::is_constructible<Tup, Elem&&>::value, "");
#endif
static_assert(!cuda::std::is_constructible<Tup, Elem const&>::value, "");
static_assert(!cuda::std::is_constructible<Tup, Elem&>::value, "");
}
Expand Down Expand Up @@ -96,7 +94,6 @@ int main(int, char**)
T t = cuda::std::move(t0);
unused(t); // Prevent unused warning
}
#if !defined(TEST_COMPILER_MSVC_2017)
{
typedef cuda::std::tuple<MoveOnly> T;
T t0(MoveOnly(0));
Expand Down Expand Up @@ -127,7 +124,6 @@ int main(int, char**)
d_t d2(static_cast<d_t &&>(d));
unused(d2);
}
#endif
{
test_sfinae<move_only_ebo>();
test_sfinae<move_only_large>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

// UNSUPPORTED: c++98, c++03


// XFAIL: gcc-8 && c++17 && !nvrtc
// XFAIL: gcc-7 && c++17 && !nvrtc

#include <cuda/std/tuple>
#include <cuda/std/utility>
#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ int main(int, char**)
{
test0(cuda::std::forward_as_tuple());
}
#if !defined(TEST_COMPILER_MSVC_2017)
{
test1a(cuda::std::forward_as_tuple(1));
}
#endif
{
int i = 2;
test1b(cuda::std::forward_as_tuple(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ int main(int, char**)
unused(t); // Prevent unused warning
}
*/
#if !defined(TEST_COMPILER_MSVC_2017)
{
constexpr cuda::std::tuple<int> t1(1);
constexpr cuda::std::tuple<int> t = cuda::std::tuple_cat(t1);
Expand All @@ -91,15 +90,12 @@ int main(int, char**)
static_assert(cuda::std::get<1>(t) == 1, "");
}
#endif
#endif
#if !defined(TEST_COMPILER_MSVC_2017)
{
cuda::std::tuple<int, MoveOnly> t =
cuda::std::tuple_cat(cuda::std::tuple<int, MoveOnly>(1, 2));
assert(cuda::std::get<0>(t) == 1);
assert(cuda::std::get<1>(t) == 2);
}
#endif
// cuda::std::array not supported
/*
{
Expand All @@ -109,13 +105,11 @@ int main(int, char**)
assert(cuda::std::get<2>(t) == 0);
}
*/
#if !defined(TEST_COMPILER_MSVC_2017)
{
cuda::std::tuple<int, MoveOnly> t = cuda::std::tuple_cat(cuda::std::pair<int, MoveOnly>(2, 1));
assert(cuda::std::get<0>(t) == 2);
assert(cuda::std::get<1>(t) == 1);
}
#endif
{
cuda::std::tuple<> t1;
cuda::std::tuple<> t2;
Expand Down Expand Up @@ -164,7 +158,6 @@ int main(int, char**)
assert(cuda::std::get<1>(t3) == 3.5);
assert(cuda::std::get<2>(t3) == nullptr);
}
#if !defined(TEST_COMPILER_MSVC_2017)
{
cuda::std::tuple<int*, MoveOnly> t1(nullptr, 1);
cuda::std::tuple<int, double> t2(2, 3.5);
Expand Down Expand Up @@ -275,6 +268,5 @@ int main(int, char**)
int, const int, int&, const int&>);
unused(r);
}
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ int main(int, char**)
static_assert(noexcept(cuda::std::get<1>(cuda::std::move(p))), "");
}

#if !defined(TEST_COMPILER_MSVC_2017)
{
int x = 42;
int const y = 43;
Expand All @@ -75,7 +74,6 @@ int main(int, char**)
static_assert(cuda::std::is_same<int const&&, decltype(cuda::std::get<1>(cuda::std::move(p)))>::value, "");
static_assert(noexcept(cuda::std::get<1>(cuda::std::move(p))), "");
}
#endif

#if TEST_STD_VER > 11
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ int main(int, char**)
assert(*p == 3);
}
*/
#if !defined(TEST_COMPILER_MSVC_2017)
{
cuda::std::tuple<MoveOnly> t(3);
MoveOnly _m = cuda::std::get<0>(cuda::std::move(t));
assert(_m.get() == 3);
}
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ int main(int, char**)
static_assert(noexcept(cuda::std::get<int const&>(cuda::std::move(t))), "");
}

#if !defined(TEST_COMPILER_MSVC_2017)
{
int x = 42;
int y = 43;
Expand All @@ -99,7 +98,6 @@ int main(int, char**)
static_assert(cuda::std::is_same<int const&&, decltype(cuda::std::get<int const&&>(cuda::std::move(t)))>::value, "");
static_assert(noexcept(cuda::std::get<int const&&>(cuda::std::move(t))), "");
}
#endif
{
constexpr const cuda::std::tuple<int, const int, double, double> t { 1, 2, 3.4, 5.6 };
static_assert(cuda::std::get<int>(cuda::std::move(t)) == 1, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ int main(int, char**)
T t1;
swap(t0, t1);
}
#if !defined(TEST_COMPILER_MSVC_2017)
{
typedef cuda::std::tuple<MoveOnly> T;
T t0(MoveOnly(0));
Expand Down Expand Up @@ -61,6 +60,5 @@ int main(int, char**)
assert(cuda::std::get<1>(t1) == 1);
assert(cuda::std::get<2>(t1) == 2);
}
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ int main(int, char**)
T t1;
t0.swap(t1);
}
#if !defined(TEST_COMPILER_MSVC_2017)
{
typedef cuda::std::tuple<MoveOnly> T;
T t0(MoveOnly(0));
Expand Down Expand Up @@ -60,6 +59,5 @@ int main(int, char**)
assert(cuda::std::get<1>(t1) == 1);
assert(cuda::std::get<2>(t1) == 2);
}
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ __enable_if_t
>
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
typedef __make_tuple_indices_t<sizeof...(_Uj)> __indices;
return _CUDA_VSTD::__mu_expand(__ti, __uj, __indices());
}

Expand All @@ -142,7 +142,7 @@ struct __mu_return2 {};
template <class _Ti, class _Uj>
struct __mu_return2<true, _Ti, _Uj>
{
typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
typedef __tuple_element_t<is_placeholder<_Ti>::value - 1, _Uj> type;
};

template <class _Ti, class _Uj>
Expand All @@ -154,8 +154,8 @@ __enable_if_t
>
__mu(_Ti&, _Uj& __uj)
{
const size_t _Indx = is_placeholder<_Ti>::value - 1;
return _CUDA_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_CUDA_VSTD::get<_Indx>(__uj));
const size_t _Indx = is_placeholder<_Ti>::value - 1;
return _CUDA_VSTD::forward<__tuple_element_t<_Indx, _Uj>>(_CUDA_VSTD::get<_Indx>(__uj));
}

template <class _Ti, class _Uj>
Expand Down Expand Up @@ -197,8 +197,7 @@ struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
template <class _Ti, class _TupleUj>
struct __mu_return_impl<_Ti, false, false, true, _TupleUj>
{
typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
_TupleUj>::type&& type;
typedef __tuple_element_t<is_placeholder<_Ti>::value - 1, _TupleUj>&& type;
};

template <class _Ti, class _TupleUj>
Expand Down Expand Up @@ -298,7 +297,7 @@ class __bind : public __weak_result_type<__decay_t<_Fp>>
_Fd __f_;
_Td __bound_args_;

typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
typedef __make_tuple_indices_t<sizeof...(_BoundArgs)> __indices;
public:
template <class _Gp, class ..._BA,
class = __enable_if_t
Expand Down
Loading
Loading