find_if_not.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. //===----------------------------------------------------------------------===//
  12. //
  13. // The LLVM Compiler Infrastructure
  14. //
  15. // This file is dual licensed under the MIT and the University of Illinois Open
  16. // Source Licenses. See LICENSE.TXT for details.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #include <utility>
  20. #include <range/v3/algorithm/find_if_not.hpp>
  21. #include <range/v3/core.hpp>
  22. #include "../simple_test.hpp"
  23. #include "../test_iterators.hpp"
  24. constexpr bool is_three(int i)
  25. {
  26. return i == 3;
  27. }
  28. template<class Rng>
  29. constexpr bool contains_other_than_three(Rng r)
  30. {
  31. auto it = ranges::find_if_not(r, is_three);
  32. return it != ranges::end(r);
  33. }
  34. int main()
  35. {
  36. using namespace ranges;
  37. {
  38. using IL = std::initializer_list<int>;
  39. STATIC_CHECK(contains_other_than_three(IL{3, 3, 2, 3}));
  40. STATIC_CHECK(!contains_other_than_three(IL{3, 3, 3}));
  41. }
  42. return ::test_result();
  43. }