diff --git a/dune/common/test/stdapplytest.cc b/dune/common/test/stdapplytest.cc index ccf2370c3fb56d7f456f32ac2d5d1cd81e5c7955..d451694461f7583763dcee24a99c249dd745d9f9 100644 --- a/dune/common/test/stdapplytest.cc +++ b/dune/common/test/stdapplytest.cc @@ -46,6 +46,17 @@ int main() test.check(std::get<0>(intTuple) == intTuple0) << "Dune::Std::apply does not properly return references"; + // transformTuple implemented using Std::apply + auto transformTuple = [](auto&& t, auto&& f) { + return Dune::Std::apply([&](auto&&... args) { + return std::make_tuple((f(std::forward<decltype(args)>(args)))...); + }, t); + }; + + auto t1 = std::make_tuple(1, 0.2); + auto t2 = transformTuple(t1, [](auto&& x) { return 1.0/x; }); + + test.check(t2 == std::make_tuple(1.0, 5.0)) << "transformTuple implementation based on Dune::Std::apply fails"; return test.exit(); }