blob: 478ad278aa6cd18e316265b71b933a005a82d32c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// { dg-do compile }
// { dg-options "-fno-exceptions" }
typedef unsigned int uint;
struct QShared {
bool deref() {
return !--count;
}
uint count;
};
template <class T> class QValueListNode {
public:
QValueListNode<T>* next;
QValueListNode<T>* prev;
};
template <class T> class QValueListPrivate : public QShared {
public:
typedef QValueListNode<T> Node;
typedef QValueListNode<T>* NodePtr;
QValueListPrivate();
void derefAndDelete() {
if ( deref() ) delete this;
}
~QValueListPrivate();
NodePtr node;
};
template <class T> QValueListPrivate<T>::QValueListPrivate() {
node = new Node;
node->next = node->prev = node;
}
template <class T> QValueListPrivate<T>::~QValueListPrivate() {
NodePtr p = node->next;
while( p != node ) {
NodePtr x = p->next;
delete p;
p = x;
}
}
template <class T> class QValueList {
public:
QValueList() {
sh = new QValueListPrivate<T>;
}
~QValueList() {
sh->derefAndDelete();
}
QValueListPrivate<T>* sh;
};
class Cell {
QValueList<Cell*> obscuringCells() const;
};
QValueList<Cell*> Cell::obscuringCells() const {
QValueList<Cell*> empty;
}
|