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:
parent
bed78605e7
commit
f90dd023cf
@ -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.
|
||||||
|
|
||||||
|
@ -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(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user