Skip to content

Commit 05288a6

Browse files
committed
Fix new tuple algorithm tests to compile in C++11 mode.
1 parent 95354d1 commit 05288a6

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

testing/tuple_algorithms.cu

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,34 @@
55
#include <unittest/unittest.h>
66

77
#include <thrust/detail/tuple_algorithms.h>
8+
#include <thrust/type_traits/integer_sequence.h>
89

910
// FIXME: Replace with C++14 style `thrust::square<>` when we have it.
1011
struct custom_square
1112
{
1213
template <typename T>
14+
__host__ __device__
1315
T operator()(T v) const
1416
{
15-
return v * v;
17+
return v * v;
18+
}
19+
};
20+
21+
struct custom_square_inplace
22+
{
23+
template <typename T>
24+
__host__ __device__
25+
void operator()(T& v) const
26+
{
27+
v *= v;
1628
}
1729
};
1830

1931
void test_tuple_subset()
2032
{
2133
auto t0 = std::make_tuple(0, 2, 3.14);
2234

23-
auto t1 = thrust::tuple_subset(t0, std::index_sequence<2, 0>{});
35+
auto t1 = thrust::tuple_subset(t0, thrust::index_sequence<2, 0>{});
2436

2537
ASSERT_EQUAL_QUIET(t1, std::make_tuple(3.14, 0));
2638
}
@@ -30,7 +42,7 @@ void test_tuple_transform()
3042
{
3143
auto t0 = std::make_tuple(0, 2, 3.14);
3244

33-
auto t1 = thrust::tuple_transform(t0, custom_square{});
45+
auto t1 = thrust::tuple_transform(t0, custom_square{});
3446

3547
ASSERT_EQUAL_QUIET(t1, std::make_tuple(0, 4, 9.8596));
3648
}
@@ -40,11 +52,11 @@ void test_tuple_for_each()
4052
{
4153
auto t = std::make_tuple(0, 2, 3.14);
4254

43-
thrust::tuple_for_each(t, [](auto& x) { x *= x; });
55+
thrust::tuple_for_each(t, custom_square_inplace{});
4456

4557
ASSERT_EQUAL_QUIET(t, std::make_tuple(0, 4, 9.8596));
4658
}
4759
DECLARE_UNITTEST(test_tuple_for_each);
48-
60+
4961
#endif // THRUST_CPP_DIALECT >= 2011
5062

0 commit comments

Comments
 (0)