inline ~QStack() {}
inline void swap(QStack<T> &other) { QVector<T>::swap(other); } // prevent QVector<->QStack swaps
inline void push(const T &t) { QVector<T>::append(t); }
- inline T pop();
- inline T &top() { return QVector<T>::last(); }; // for compatibility
- const T &top() const { return QVector<T>::last(); }; // for compatibility
+ T pop();
+ T &top();
+ const T &top() const;
};
template<class T>
{ Q_ASSERT(!this->isEmpty()); T t = this->data()[this->size() -1];
this->resize(this->size()-1); return t; }
+template<class T>
+inline T &QStack<T>::top()
+{ Q_ASSERT(!this->isEmpty()); this->detach(); return this->data()[this->size()-1]; }
+
+template<class T>
+inline const T &QStack<T>::top() const
+{ Q_ASSERT(!this->isEmpty()); return this->data()[this->size()-1]; }
+
QT_END_NAMESPACE
QT_END_HEADER