15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <algorithm>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template<InputIterator Iter, class T>
125a83710eSEric Fiselier //   requires HasEqualTo<Iter::value_type, T>
13056f15e3SMarshall Clow //   constexpr Iter::difference_type   // constexpr after C++17
145a83710eSEric Fiselier //   count(Iter first, Iter last, const T& value);
155a83710eSEric Fiselier 
165a83710eSEric Fiselier #include <algorithm>
175a83710eSEric Fiselier #include <cassert>
185a83710eSEric Fiselier 
19056f15e3SMarshall Clow #include "test_macros.h"
205a83710eSEric Fiselier #include "test_iterators.h"
215a83710eSEric Fiselier 
22056f15e3SMarshall Clow #if TEST_STD_VER > 17
test_constexpr()23056f15e3SMarshall Clow TEST_CONSTEXPR bool test_constexpr() {
24056f15e3SMarshall Clow     int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
25056f15e3SMarshall Clow     int ib[] = {1, 2, 3, 4, 5, 6};
26056f15e3SMarshall Clow     return    (std::count(std::begin(ia), std::end(ia), 2) == 3)
27056f15e3SMarshall Clow            && (std::count(std::begin(ib), std::end(ib), 9) == 0)
28056f15e3SMarshall Clow            ;
29056f15e3SMarshall Clow     }
30056f15e3SMarshall Clow #endif
31056f15e3SMarshall Clow 
main(int,char **)322df59c50SJF Bastien int main(int, char**)
335a83710eSEric Fiselier {
345a83710eSEric Fiselier     int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
355a83710eSEric Fiselier     const unsigned sa = sizeof(ia)/sizeof(ia[0]);
36*773ae441SChristopher Di Bella     assert(std::count(cpp17_input_iterator<const int*>(ia),
37*773ae441SChristopher Di Bella                       cpp17_input_iterator<const int*>(ia + sa), 2) == 3);
38*773ae441SChristopher Di Bella     assert(std::count(cpp17_input_iterator<const int*>(ia),
39*773ae441SChristopher Di Bella                       cpp17_input_iterator<const int*>(ia + sa), 7) == 0);
40*773ae441SChristopher Di Bella     assert(std::count(cpp17_input_iterator<const int*>(ia),
41*773ae441SChristopher Di Bella                       cpp17_input_iterator<const int*>(ia), 2) == 0);
42056f15e3SMarshall Clow 
43056f15e3SMarshall Clow #if TEST_STD_VER > 17
44056f15e3SMarshall Clow     static_assert(test_constexpr());
45056f15e3SMarshall Clow #endif
462df59c50SJF Bastien 
472df59c50SJF Bastien   return 0;
485a83710eSEric Fiselier }
49