diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 11 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.qdoc | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 54d97d8762..32f621c809 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -42,6 +42,9 @@ #include <string.h> #include <stdlib.h> #include <algorithm> +#ifdef Q_COMPILER_INITIALIZER_LISTS +#include <initializer_list> +#endif QT_BEGIN_NAMESPACE @@ -62,6 +65,14 @@ public: append(other.constData(), other.size()); } +#ifdef Q_COMPILER_INITIALIZER_LISTS + QVarLengthArray(std::initializer_list<T> args) + : a(Prealloc), s(0), ptr(reinterpret_cast<T *>(array)) + { + append(args.begin(), args.size()); + } +#endif + inline ~QVarLengthArray() { if (QTypeInfo<T>::isComplex) { T *i = ptr + s; diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 6cc9f62c5a..d1b87f381e 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -100,6 +100,17 @@ \l{default-constructed value}. */ + +/*! \fn QVarLengthArray::QVarLengthArray(std::initializer_list<T> args) + \since 5.5 + + Constructs an array from the std::initializer_list given by \a args. + + This constructor is only enabled if the compiler supports C++11 initializer + lists. +*/ + + /*! \fn QVarLengthArray::~QVarLengthArray() Destroys the array. |