contains.cpp 961 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Range v3 library
  2. //
  3. // Copyright Johel Guerrero 2019
  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. #include <range/v3/algorithm/contains.hpp>
  13. #include "../simple_test.hpp"
  14. int main()
  15. {
  16. using ranges::contains;
  17. constexpr int rng[] = {4, 2};
  18. const auto first = rng;
  19. const auto last = rng + 2;
  20. CHECK(!contains(first, first, 0));
  21. CHECK(!contains(first, last, 1));
  22. CHECK(contains(first, last, 2));
  23. CHECK(!contains(first, last, 3));
  24. CHECK(contains(first, last, 4));
  25. #ifndef RANGES_WORKAROUND_CLANG_23135
  26. static_assert(!contains(rng, 1), "");
  27. static_assert(contains(rng, 2), "");
  28. static_assert(!contains(rng, 3), "");
  29. static_assert(contains(rng, 4), "");
  30. #endif
  31. return ::test_result();
  32. }