ra-10.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // -*- mode: c++; coding: utf-8 -*-
  2. /// @file ra-10.cc
  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/ra.hh"
  10. #include "ra/test.hh"
  11. #include "ra/mpdebug.hh"
  12. using std::cout, std::endl, ra::TestRecorder;
  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::none);
  20. VP = &V;
  21. auto i = ra::iota(1);
  22. // doesn't use Reframe, ref or rvalue works just the same.
  23. ply(from([&](auto i) { tr.info("fwd lambda 1").test(&V==VP); }, i));
  24. // uses Reframe.
  25. auto f = [&](auto i, auto j) { tr.info("fwd lambda 2 ref").test(&V==VP); };
  26. ply(from(f, i, i));
  27. // uses Reframe. 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. }