brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 744496f Raw
51 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <vector>10// vector<bool>11 12// std::find with vector<bool>::iterator13 14// https://llvm.org/PR1681615 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 > 1747  static_assert(tests());48#endif49  return 0;50}51