test-ra-10.C 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // (c) Daniel Llorens - 2017
  2. // This library is free software; you can redistribute it and/or modify it under
  3. // the terms of the GNU Lesser General Public License as published by the Free
  4. // Software Foundation; either version 3 of the License, or (at your option) any
  5. // later version.
  6. /// @file test-ra-10.C
  7. /// @brief Regressions using from() with temp lambdas
  8. #include "ra/operators.H"
  9. #include "ra/io.H"
  10. #include "ra/test.H"
  11. #include "ra/mpdebug.H"
  12. using std::cout; using std::endl;
  13. void * VP;
  14. int main()
  15. {
  16. TestRecorder tr(std::cout);
  17. tr.section("temp lambda");
  18. {
  19. ra::Big<ra::Small<double, 2>, 1> V({2*2}, ra::unspecified);
  20. VP = &V;
  21. auto i = ra::iota(1);
  22. // goes through Expr, ref or rvalue works just the same.
  23. ply(from([&](auto i) { tr.info("fwd lambda 1").test(&V==VP); }, i));
  24. // goes through Ryn.
  25. auto f = [&](auto i, auto j) { tr.info("fwd lambda 2 ref").test(&V==VP); };
  26. ply(from(f, i, i));
  27. // goes through Ryn. This requires the forward in [ra31].
  28. ply(from([&](auto i, auto j) { tr.info("fwd lambda 2 rvalue").test(&V==VP); }, i, i));
  29. }
  30. return tr.summary();
  31. }