actor_assignment.cpp 925 B

1234567891011121314151617181920212223242526272829
  1. /*=============================================================================
  2. Copyright (c) 2018 Nikita Kniazev
  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.hpp>
  8. #include <boost/function.hpp>
  9. #include <string>
  10. // Checks that rhs Phoenix actor is taken by value on assignment.
  11. // The wrapper function is used to ensure that created temporaries are
  12. // out of scope (as they will be created on the other stack frame).
  13. boost::function<void()> make_assignment_test(std::string & s)
  14. {
  15. return boost::phoenix::ref(s) = "asd";
  16. }
  17. int main()
  18. {
  19. std::string s;
  20. make_assignment_test(s)();
  21. BOOST_TEST(s == "asd");
  22. return boost::report_errors();
  23. }