Browse Source

Added back std::initializer_list constructors for Array and StringArray in addition to the variadic constructors

tags/2021-05-28
jules 7 years ago
parent
commit
6cb79e1414
3 changed files with 19 additions and 0 deletions
  1. +8
    -0
      modules/juce_core/containers/juce_Array.h
  2. +7
    -0
      modules/juce_core/text/juce_StringArray.cpp
  3. +4
    -0
      modules/juce_core/text/juce_StringArray.h

+ 8
- 0
modules/juce_core/containers/juce_Array.h View File

@@ -133,6 +133,14 @@ public:
addAssumingCapacityIsReady (static_cast<ElementType&&> (firstNewElement), otherElements...);
}
#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
template <typename TypeToCreateFrom>
Array (const std::initializer_list<TypeToCreateFrom>& items)
{
addArray (items);
}
#endif
/** Destructor. */
~Array()
{


+ 7
- 0
modules/juce_core/text/juce_StringArray.cpp View File

@@ -67,6 +67,13 @@ StringArray::StringArray (const wchar_t* const* initialStrings, int numberOfStri
strings.addArray (initialStrings, numberOfStrings);
}
#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
StringArray::StringArray (const std::initializer_list<const char*>& stringList)
{
strings.addArray (stringList);
}
#endif
StringArray& StringArray::operator= (const StringArray& other)
{
strings = other.strings;


+ 4
- 0
modules/juce_core/text/juce_StringArray.h View File

@@ -49,6 +49,10 @@ public:
template <typename... OtherElements>
StringArray (StringRef firstValue, OtherElements... otherValues) : strings (firstValue, otherValues...) {}
#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
StringArray (const std::initializer_list<const char*>& strings);
#endif
/** Creates an array from a raw array of strings.
@param strings an array of strings to add
@param numberOfStrings how many items there are in the array


Loading…
Cancel
Save