is_sorted.cpp 812 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Range v3 library
  2. //
  3. // Copyright Jeff Garland 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. //
  12. ///[is_sorted]
  13. // Check if a container is sorted
  14. // output
  15. // vector: true
  16. // array: false
  17. #include <array>
  18. #include <iostream>
  19. #include <range/v3/algorithm/is_sorted.hpp> // specific includes
  20. #include <vector>
  21. using std::cout;
  22. int
  23. main()
  24. {
  25. cout << std::boolalpha;
  26. std::vector<int> v{1, 2, 3, 4, 5, 6};
  27. cout << "vector: " << ranges::is_sorted(v) << '\n';
  28. std::array<int, 6> a{6, 2, 3, 4, 5, 6};
  29. cout << "array: " << ranges::is_sorted(a) << '\n';
  30. }
  31. ///[is_sorted]