more_lambda_tests.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*=============================================================================
  2. Copyright (c) 2014 John Fletcher
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/phoenix/core.hpp>
  8. #include <boost/phoenix/operator.hpp>
  9. #include <boost/phoenix/function.hpp>
  10. #include <boost/phoenix/bind.hpp>
  11. #include <boost/phoenix/scope.hpp>
  12. int
  13. main()
  14. {
  15. using boost::phoenix::lambda;
  16. using boost::phoenix::let;
  17. using boost::phoenix::ref;
  18. using boost::phoenix::val;
  19. using boost::phoenix::arg_names::_1;
  20. //using boost::phoenix::arg_names::_2;
  21. using boost::phoenix::local_names::_a;
  22. // using boost::phoenix::local_names::_b;
  23. //using boost::phoenix::placeholders::arg1;
  24. {
  25. int x = 1;
  26. int y = lambda[_1]()(x);
  27. BOOST_TEST(x == y);
  28. }
  29. {
  30. int x = 1;
  31. int y = lambda(_a = _1)[_a+1](x)();
  32. BOOST_TEST(x+1 == y);
  33. }
  34. {
  35. int x = lambda[val(1)]()();
  36. BOOST_TEST(x == 1);
  37. }
  38. return boost::report_errors();
  39. }