blob: 260e5edece5b4f7c2693e64d95c4f9f0a6bbcd58 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <algorithm>
11
Howard Hinnant664ae812010-08-22 00:08:10 +000012// template<InputIterator Iter, class T>
13// requires HasEqualTo<Iter::value_type, T>
Howard Hinnant3e519522010-05-11 19:42:16 +000014// Iter::difference_type
15// count(Iter first, Iter last, const T& value);
16
17#include <algorithm>
18#include <cassert>
19
Marshall Clow32227082013-01-05 03:21:01 +000020#include "test_iterators.h"
Howard Hinnant3e519522010-05-11 19:42:16 +000021
22int main()
23{
24 int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
25 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
26 assert(std::count(input_iterator<const int*>(ia),
27 input_iterator<const int*>(ia + sa), 2) == 3);
28 assert(std::count(input_iterator<const int*>(ia),
29 input_iterator<const int*>(ia + sa), 7) == 0);
30 assert(std::count(input_iterator<const int*>(ia),
31 input_iterator<const int*>(ia), 2) == 0);
32}