]>
Commit | Line | Data |
---|---|---|
748086b7 | 1 | // Copyright (C) 2001, 2004, 2005, 2009 Free Software Foundation, Inc. |
f133a43e BK |
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) |
f133a43e BK |
7 | // any later version. |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
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/>. | |
f133a43e | 17 | |
17472bb6 | 18 | // 23.2.2.1 list constructors, copy, and assignment |
f133a43e | 19 | |
17472bb6 | 20 | #include <list> |
fe413112 | 21 | #include <testsuite_hooks.h> |
f133a43e | 22 | |
17472bb6 | 23 | // A nontrivial type convertible from an int |
875d0f10 BK |
24 | struct C |
25 | { | |
17472bb6 BK |
26 | C(int i) : i_(i) { } |
27 | bool operator==(const C& rhs) { return i_ == rhs.i_; } | |
28 | int i_; | |
29 | }; | |
30 | ||
31 | // Fill Assignment disguised as a Range Assignment | |
875d0f10 | 32 | template<typename _Tp> |
17472bb6 | 33 | void |
875d0f10 | 34 | cons08() |
f133a43e | 35 | { |
875d0f10 BK |
36 | typedef _Tp list_type; |
37 | typedef typename list_type::iterator iterator; | |
38 | bool test __attribute__((unused)) = true; | |
11f10e6b | 39 | const std::size_t LIST_SIZE = 5; |
17472bb6 | 40 | const int INIT_VALUE = 7; |
11f10e6b | 41 | std::size_t count = 0; |
875d0f10 BK |
42 | |
43 | list_type list0604; | |
17472bb6 BK |
44 | VERIFY(list0604.size() == 0); |
45 | ||
46 | list0604.assign(LIST_SIZE, INIT_VALUE); | |
875d0f10 | 47 | iterator i = list0604.begin(); |
17472bb6 BK |
48 | for (; i != list0604.end(); ++i, ++count) |
49 | VERIFY(*i == INIT_VALUE); | |
50 | VERIFY(count == LIST_SIZE); | |
51 | VERIFY(list0604.size() == LIST_SIZE); | |
f133a43e BK |
52 | } |
53 | ||
54 | int main() | |
55 | { | |
875d0f10 | 56 | cons08<std::list<C> >(); |
f133a43e BK |
57 | return 0; |
58 | } | |
f90e600a | 59 |