ra-10.C 1.1 KB

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