1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSTACK_H
5#define QSTACK_H
6
7#include <QtCore/qlist.h>
8
9QT_BEGIN_NAMESPACE
10
11template<class T>
12class QStack : public QList<T>
13{
14public:
15 // compiler-generated special member functions are fine!
16 void swap(QStack<T> &other) noexcept { QList<T>::swap(other); } // prevent QList<->QStack swaps
17 void push(const T &t) { QList<T>::append(t); }
18 T pop() { return QList<T>::takeLast(); }
19 T &top() { return QList<T>::last(); }
20 const T &top() const { return QList<T>::last(); }
21};
22
23QT_END_NAMESPACE
24
25#endif // QSTACK_H
26

source code of qtbase/src/corelib/tools/qstack.h