ra-10.cc 1.1 KB

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