1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-27 02:20:05 +00:00

Added an initialiser list constructor to OwnedArray

This commit is contained in:
ed 2018-02-20 17:22:28 +00:00
parent ac44306a4c
commit d77f4fe691

View file

@ -72,6 +72,13 @@ public:
other.numUsed = 0;
}
#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
OwnedArray (const std::initializer_list<ObjectClass*>& items)
{
addArray (items);
}
#endif
/** Move assignment operator */
OwnedArray& operator= (OwnedArray&& other) noexcept
{
@ -469,6 +476,21 @@ public:
}
}
#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
template <typename OtherArrayType>
void addArray (const std::initializer_list<OtherArrayType>& items)
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + (int) items.size());
for (auto* item : items)
{
data.elements[numUsed] = item;
++numUsed;
}
}
#endif
/** Adds copies of the elements in another array to the end of this array.
The other array must be either an OwnedArray of a compatible type of object, or an Array