bug566.cpp 906 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Range v3 library
  2. //
  3. // Copyright Filip Matner 2017
  4. //
  5. // Use, modification and distribution is subject to the
  6. // Boost Software License, Version 1.0. (See accompanying
  7. // file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // Project home: https://github.com/ericniebler/range-v3
  11. #include <vector>
  12. #include <memory>
  13. #include <range/v3/view/for_each.hpp>
  14. #include <range/v3/view/move.hpp>
  15. #include "./simple_test.hpp"
  16. #include "./test_utils.hpp"
  17. using namespace ranges;
  18. int main()
  19. {
  20. std::vector<std::unique_ptr<int>> d;
  21. d.emplace_back(std::unique_ptr<int>(new int(1)));
  22. d.emplace_back(std::unique_ptr<int>(new int(5)));
  23. d.emplace_back(std::unique_ptr<int>(new int(4)));
  24. auto rng = d | views::move | views::for_each([](std::unique_ptr<int> ptr)
  25. {
  26. return yield(*ptr);
  27. });
  28. check_equal(rng, {1, 5, 4});
  29. return ::test_result();
  30. }