blob: e0cad5a8b4c3bd1d5a6ec1a118a9734e880f4e04 (
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
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSTACK_H
#define QSTACK_H
#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
template<class T>
class QStack : public QList<T>
{
public:
// compiler-generated special member functions are fine!
void swap(QStack<T> &other) noexcept { QList<T>::swap(other); } // prevent QList<->QStack swaps
void push(const T &t) { QList<T>::append(t); }
void push(T &&t) { QList<T>::append(std::move(t)); }
T pop() { return QList<T>::takeLast(); }
T &top() { return QList<T>::last(); }
const T &top() const { return QList<T>::last(); }
};
QT_END_NAMESPACE
#endif // QSTACK_H
|