]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/25_algorithms/copy/34595.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / copy / 34595.cc
CommitLineData
aa118a03 1// Copyright (C) 2007-2014 Free Software Foundation, Inc.
5f6d5f0a
PC
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
748086b7 6// Free Software Foundation; either version 3, or (at your option)
5f6d5f0a
PC
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
2328b1de 10// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f6d5f0a
PC
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
5f6d5f0a
PC
17
18// 25.2.1 [lib.alg.copy] Copy.
19
20#include <algorithm>
21#include <testsuite_hooks.h>
22
23class Counting_output_iterator
24: public std::iterator< std::output_iterator_tag, void, void, void, void >
25{
26 std::size_t c;
27public:
28 Counting_output_iterator() : c(0) {}
29 Counting_output_iterator& operator++() { return *this; }
30 Counting_output_iterator& operator*() { return *this; }
31
32 template <typename T>
33 void operator=(const T&) { ++c; }
34
35 std::size_t current_counter() const { return c; }
36};
37
38// libstdc++/34595
39void test01()
40{
41 bool test __attribute__((unused)) = true;
42
43 int t[10] = {0,};
44 Counting_output_iterator cnt;
45 std::size_t res = std::copy(t+0, t+5, cnt).current_counter();
46
47 VERIFY( res == 5 );
48}
49
50int main()
51{
52 test01();
53 return 0;
54}