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