copy_n.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Range v3 library
  2. //
  3. // Copyright Eric Niebler 2014
  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 <range/v3/algorithm/copy_n.hpp>
  12. #include "../array.hpp"
  13. #include "../simple_test.hpp"
  14. constexpr bool test_constexpr()
  15. {
  16. using namespace ranges;
  17. test::array<int, 4> a{{1, 2, 3, 4}};
  18. test::array<int, 4> b{{0, 0, 0, 0}};
  19. const auto res = copy_n(begin(a), 2, ranges::begin(b));
  20. STATIC_CHECK_RETURN(res.first == begin(a) + 2);
  21. STATIC_CHECK_RETURN(res.second == begin(b) + 2);
  22. STATIC_CHECK_RETURN(a[0] == 1);
  23. STATIC_CHECK_RETURN(a[1] == 2);
  24. STATIC_CHECK_RETURN(a[2] == 3);
  25. STATIC_CHECK_RETURN(a[3] == 4);
  26. STATIC_CHECK_RETURN(b[0] == 1);
  27. STATIC_CHECK_RETURN(b[1] == 2);
  28. STATIC_CHECK_RETURN(b[2] == 0);
  29. STATIC_CHECK_RETURN(b[3] == 0);
  30. return true;
  31. }
  32. int main()
  33. {
  34. {
  35. STATIC_CHECK(test_constexpr());
  36. }
  37. return test_result();
  38. }