[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / algorithms / alg.nonmodifying / alg.count / count.pass.cpp
blobd864080df8d32eb8302c4fc23779eea47699bfbe
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 //===----------------------------------------------------------------------===//
9 // <algorithm>
11 // template<InputIterator Iter, class T>
12 // requires HasEqualTo<Iter::value_type, T>
13 // constexpr Iter::difference_type // constexpr after C++17
14 // count(Iter first, Iter last, const T& value);
16 #include <algorithm>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "test_iterators.h"
22 #if TEST_STD_VER > 17
23 TEST_CONSTEXPR bool test_constexpr() {
24 int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
25 int ib[] = {1, 2, 3, 4, 5, 6};
26 return (std::count(std::begin(ia), std::end(ia), 2) == 3)
27 && (std::count(std::begin(ib), std::end(ib), 9) == 0)
30 #endif
32 int main(int, char**)
34 int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
35 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
36 assert(std::count(input_iterator<const int*>(ia),
37 input_iterator<const int*>(ia + sa), 2) == 3);
38 assert(std::count(input_iterator<const int*>(ia),
39 input_iterator<const int*>(ia + sa), 7) == 0);
40 assert(std::count(input_iterator<const int*>(ia),
41 input_iterator<const int*>(ia), 2) == 0);
43 #if TEST_STD_VER > 17
44 static_assert(test_constexpr());
45 #endif
47 return 0;