QQueue: add enqueue signature to enqueue elements by moving

Using the QQueue shim one could only use `enqueue` by copying. Adding a
signature to copy to allow elements to be moved.

Change-Id: Idfbabb6fc01265285f128c5657ccb4050e902720
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Tim Blechmann 2025-05-10 21:07:30 +02:00
parent bed78605e7
commit f90dd023cf
2 changed files with 2 additions and 0 deletions

View File

@ -48,6 +48,7 @@
/*! /*!
\fn template <class T> void QQueue<T>::enqueue(const T& t) \fn template <class T> void QQueue<T>::enqueue(const T& t)
\fn template <class T> void QQueue<T>::enqueue(T&& t)
Adds value \a t to the tail of the queue. Adds value \a t to the tail of the queue.

View File

@ -16,6 +16,7 @@ public:
// compiler-generated special member functions are fine! // compiler-generated special member functions are fine!
inline void swap(QQueue<T> &other) noexcept { QList<T>::swap(other); } // prevent QList<->QQueue swaps inline void swap(QQueue<T> &other) noexcept { QList<T>::swap(other); } // prevent QList<->QQueue swaps
inline void enqueue(const T &t) { QList<T>::append(t); } inline void enqueue(const T &t) { QList<T>::append(t); }
inline void enqueue(T &&t) { QList<T>::append(std::move(t)); }
inline T dequeue() { return QList<T>::takeFirst(); } inline T dequeue() { return QList<T>::takeFirst(); }
inline T &head() { return QList<T>::first(); } inline T &head() { return QList<T>::first(); }
inline const T &head() const { return QList<T>::first(); } inline const T &head() const { return QList<T>::first(); }