join.cpp 1012 B

12345678910111213141516171819202122232425262728293031323334
  1. // Range v3 library
  2. //
  3. // Copyright Eric Niebler 2014-present
  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. #include <vector>
  10. #include <string>
  11. #include <range/v3/core.hpp>
  12. #include <range/v3/action/join.hpp>
  13. #include <range/v3/algorithm/move.hpp>
  14. #include <range/v3/algorithm/equal.hpp>
  15. #include <range/v3/view/transform.hpp>
  16. #include "../simple_test.hpp"
  17. #include "../test_utils.hpp"
  18. int main()
  19. {
  20. using namespace ranges;
  21. std::vector<std::string> v {"hello"," ","world"};
  22. auto s = v | move | actions::join;
  23. static_assert(std::is_same<decltype(s), std::string>::value, "");
  24. CHECK(s == "hello world");
  25. auto s2 = v | views::transform(views::all) | actions::join;
  26. static_assert(std::is_same<decltype(s2), std::vector<char>>::value, "");
  27. CHECK(std::string(s2.begin(), s2.end()) == "hello world");
  28. return ::test_result();
  29. }