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:
parent
ac44306a4c
commit
d77f4fe691
1 changed files with 22 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue