Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
23.list.cons.stdcxx-268.cpp
Go to the documentation of this file.
1
27#include <list>
28#include <cassert>
29
30static int throw_inx = -1;
31
33{
34public:
35 static int count_;
36
37 void test ()
38 {
39 if (throw_inx == count_)
40 throw count_;
41
42 ++count_;
43 }
44
45 ListItem () { test (); }
46
47 ListItem (const ListItem&) { test (); }
48
49 ~ListItem () { --count_; }
50};
51
52int ListItem::count_ = 0;
53
54
55int main ()
56{
57 typedef std::list<ListItem> List;
58 ListItem items [20];
59 List lst (20);
60
61 bool thrown = false;
62 throw_inx = 10;
63
64 try {
66 List test (20);
67 } catch (...) {
68 thrown = true;
69 }
70
71 assert (thrown);
73
74 try {
75 thrown = false;
77 List test (20, items [0]);
78 } catch (...) {
79 thrown = true;
80 }
81
82 assert (thrown);
84
85 try {
86 thrown = false;
88 List test (items, items + 20);
89 } catch (...) {
90 thrown = true;
91 }
92
93 assert (thrown);
95
96 try {
97 thrown = false;
99 List test (lst.begin (), lst.end ());
100 } catch (...) {
101 thrown = true;
102 }
103
104 assert (thrown);
106
107 try {
108 thrown = false;
110 List test (lst);
111 } catch (...) {
112 thrown = true;
113 }
114
115 assert (thrown);
117
118 return 0;
119}
#define assert(expr)
Definition _cassert.h:40
ListItem(const ListItem &)