1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <vector>
10// vector<bool>
11
12// std::find with vector<bool>::iterator
13
14// https://llvm.org/PR16816
15
16#include <vector>
17#include <algorithm>
18#include <cassert>
19#include <cstddef>
20
21#include "test_macros.h"
22
23TEST_CONSTEXPR_CXX20 bool tests() {
24 {
25 for (unsigned i = 1; i < 256; ++i) {
26 std::vector<bool> b(i, true);
27 std::vector<bool>::iterator j = std::find(b.begin() + 1, b.end(), false);
28 assert(static_cast<std::size_t>(j - b.begin()) == i);
29 assert(b.end() == j);
30 }
31 }
32 {
33 for (unsigned i = 1; i < 256; ++i) {
34 std::vector<bool> b(i, false);
35 std::vector<bool>::iterator j = std::find(b.begin() + 1, b.end(), true);
36 assert(static_cast<std::size_t>(j - b.begin()) == i);
37 assert(b.end() == j);
38 }
39 }
40
41 return true;
42}
43
44int main(int, char**) {
45 tests();
46#if TEST_STD_VER > 17
47 static_assert(tests());
48#endif
49 return 0;
50}
51

source code of libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp