Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Fix tuple_for_each unused variable macro and tests #1027

Merged
merged 2 commits into from
Oct 28, 2019
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
20 changes: 20 additions & 0 deletions testing/tuple_algorithms.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ struct custom_square
}
};

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

auto t1 = thrust::tuple_subset(t0, std::index_sequence<2, 0>{});

ASSERT_EQUAL_QUIET(t1, std::make_tuple(3.14, 0));
}
DECLARE_UNITTEST(test_tuple_subset);

void test_tuple_transform()
{
auto t0 = std::make_tuple(0, 2, 3.14);
Expand All @@ -25,6 +35,16 @@ void test_tuple_transform()
ASSERT_EQUAL_QUIET(t1, std::make_tuple(0, 4, 9.8596));
}
DECLARE_UNITTEST(test_tuple_transform);

void test_tuple_for_each()
{
auto t = std::make_tuple(0, 2, 3.14);

thrust::tuple_for_each(t, [](auto& x) { x *= x; });

ASSERT_EQUAL_QUIET(t, std::make_tuple(0, 4, 9.8596));
}
DECLARE_UNITTEST(test_tuple_for_each);

#endif // THRUST_CPP_DIALECT >= 2011

2 changes: 1 addition & 1 deletion thrust/detail/tuple_algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ template <typename Tuple, typename F, std::size_t... Is>
void tuple_for_each_impl(Tuple&& t, F&& f, index_sequence<Is...>)
{
auto l = { (f(std::get<Is>(t)), 0)... };
THRUST_UNUSED(l);
THRUST_UNUSED_VAR(l);
}

template <typename Tuple, typename F, std::size_t... Is>
Expand Down