diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h index a0e39f8ece..c43c63cdd2 100644 --- a/src/corelib/tools/qstack.h +++ b/src/corelib/tools/qstack.h @@ -49,26 +49,13 @@ class QStack : public QList { public: // compiler-generated special member functions are fine! - inline void swap(QStack &other) noexcept { QList::swap(other); } // prevent QList<->QStack swaps - inline void push(const T &t) { QList::append(t); } - T pop(); - T &top(); - const T &top() const; + void swap(QStack &other) noexcept { QList::swap(other); } // prevent QList<->QStack swaps + void push(const T &t) { QList::append(t); } + T pop() { return QList::takeLast(); } + T &top() { return QList::last(); } + const T &top() const { return QList::last(); } }; -template -inline T QStack::pop() -{ Q_ASSERT(!this->isEmpty()); T t = this->data()[this->size() -1]; - this->resize(this->size()-1); return t; } - -template -inline T &QStack::top() -{ Q_ASSERT(!this->isEmpty()); this->detach(); return this->data()[this->size()-1]; } - -template -inline const T &QStack::top() const -{ Q_ASSERT(!this->isEmpty()); return this->data()[this->size()-1]; } - QT_END_NAMESPACE #endif // QSTACK_H