QLinkedList: implement missing initializer_list ctor
Found by tst_QLinkedList once compiled in C++11 mode. Change-Id: Idbf79d775c5271437dbb99c1c8cc7a2e8a7f08bf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
132190c3a2
commit
bc016c53fc
@ -137,6 +137,15 @@ const QLinkedListData QLinkedListData::shared_null = {
|
||||
\sa operator=()
|
||||
*/
|
||||
|
||||
/*! \fn QLinkedList::QLinkedList(std::initializer_list<T> list)
|
||||
\since 5.2
|
||||
|
||||
Constructs a list from the std::initializer_list specified by \a list.
|
||||
|
||||
This constructor is only enabled if the compiler supports C++11
|
||||
initializer lists.
|
||||
*/
|
||||
|
||||
/*! \fn QLinkedList::~QLinkedList()
|
||||
|
||||
Destroys the list. References to the values in the list, and all
|
||||
|
@ -50,6 +50,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(Q_COMPILER_INITIALIZER_LISTS)
|
||||
# include <initializer_list>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
@ -80,6 +84,13 @@ class QLinkedList
|
||||
public:
|
||||
inline QLinkedList() : d(const_cast<QLinkedListData *>(&QLinkedListData::shared_null)) { }
|
||||
inline QLinkedList(const QLinkedList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); }
|
||||
#if defined(Q_COMPILER_INITIALIZER_LISTS)
|
||||
inline QLinkedList(std::initializer_list<T> list)
|
||||
: d(const_cast<QLinkedListData *>(&QLinkedListData::shared_null))
|
||||
{
|
||||
std::copy(list.begin(), list.end(), std::back_inserter(*this));
|
||||
}
|
||||
#endif
|
||||
~QLinkedList();
|
||||
QLinkedList<T> &operator=(const QLinkedList<T> &);
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
|
Loading…
Reference in New Issue
Block a user