]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | // Copyright (C) 2007-2022 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 | ||
23 | class Counting_output_iterator | |
de196e5d | 24 | : public std::iterator< std::output_iterator_tag, void, void, void, void > // { dg-warning "is deprecated" "" { target c++17 } } |
5f6d5f0a PC |
25 | { |
26 | std::size_t c; | |
27 | public: | |
28 | Counting_output_iterator() : c(0) {} | |
29 | Counting_output_iterator& operator++() { return *this; } | |
5f1db762 | 30 | Counting_output_iterator operator++(int) { return *this; } |
5f6d5f0a | 31 | Counting_output_iterator& operator*() { return *this; } |
5f1db762 | 32 | |
5f6d5f0a PC |
33 | template <typename T> |
34 | void operator=(const T&) { ++c; } | |
5f1db762 | 35 | |
5f6d5f0a PC |
36 | std::size_t current_counter() const { return c; } |
37 | }; | |
38 | ||
39 | // libstdc++/34595 | |
40 | void test01() | |
41 | { | |
5f6d5f0a PC |
42 | int t[10] = {0,}; |
43 | Counting_output_iterator cnt; | |
44 | std::size_t res = std::copy(t+0, t+5, cnt).current_counter(); | |
45 | ||
46 | VERIFY( res == 5 ); | |
47 | } | |
48 | ||
49 | int main() | |
50 | { | |
51 | test01(); | |
52 | return 0; | |
53 | } |