1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
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);
19 #include "test_macros.h"
20 #include "test_iterators.h"
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)
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);
44 static_assert(test_constexpr());