| @@ -96,8 +96,7 @@ public: | |||||
| @param values the array to copy from | @param values the array to copy from | ||||
| */ | */ | ||||
| template <typename TypeToCreateFrom> | template <typename TypeToCreateFrom> | ||||
| explicit Array (const TypeToCreateFrom* values) | |||||
| : numUsed (0) | |||||
| explicit Array (const TypeToCreateFrom* values) : numUsed (0) | |||||
| { | { | ||||
| while (*values != TypeToCreateFrom()) | while (*values != TypeToCreateFrom()) | ||||
| add (*values++); | add (*values++); | ||||
| @@ -109,8 +108,7 @@ public: | |||||
| @param numValues the number of values in the array | @param numValues the number of values in the array | ||||
| */ | */ | ||||
| template <typename TypeToCreateFrom> | template <typename TypeToCreateFrom> | ||||
| Array (const TypeToCreateFrom* values, int numValues) | |||||
| : numUsed (numValues) | |||||
| Array (const TypeToCreateFrom* values, int numValues) : numUsed (numValues) | |||||
| { | { | ||||
| data.setAllocatedSize (numValues); | data.setAllocatedSize (numValues); | ||||
| @@ -118,6 +116,14 @@ public: | |||||
| new (data.elements + i) ElementType (values[i]); | new (data.elements + i) ElementType (values[i]); | ||||
| } | } | ||||
| #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS | |||||
| template <typename TypeToCreateFrom> | |||||
| Array (const std::initializer_list<TypeToCreateFrom>& items) : numUsed (0) | |||||
| { | |||||
| addArray (items); | |||||
| } | |||||
| #endif | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~Array() | ~Array() | ||||
| { | { | ||||
| @@ -604,6 +610,21 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS | |||||
| template <typename TypeToCreateFrom> | |||||
| void addArray (const std::initializer_list<TypeToCreateFrom>& items) | |||||
| { | |||||
| const ScopedLockType lock (getLock()); | |||||
| data.ensureAllocatedSize (numUsed + (int) items.size()); | |||||
| for (auto& item : items) | |||||
| { | |||||
| new (data.elements + numUsed) ElementType (item); | |||||
| ++numUsed; | |||||
| } | |||||
| } | |||||
| #endif | |||||
| /** Adds elements from a null-terminated array of pointers to the end of this array. | /** Adds elements from a null-terminated array of pointers to the end of this array. | ||||
| @param elementsToAdd an array of pointers to some kind of object from which elements | @param elementsToAdd an array of pointers to some kind of object from which elements | ||||
| @@ -40,6 +40,7 @@ | |||||
| #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 | #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 | ||||
| #define JUCE_COMPILER_SUPPORTS_NULLPTR 1 | #define JUCE_COMPILER_SUPPORTS_NULLPTR 1 | ||||
| #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 | #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 | ||||
| #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 | |||||
| #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL) | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL) | ||||
| #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | ||||
| @@ -87,6 +88,11 @@ | |||||
| #ifndef JUCE_COMPILER_SUPPORTS_ARC | #ifndef JUCE_COMPILER_SUPPORTS_ARC | ||||
| #define JUCE_COMPILER_SUPPORTS_ARC 1 | #define JUCE_COMPILER_SUPPORTS_ARC 1 | ||||
| #endif | #endif | ||||
| #if __has_feature (cxx_generalized_initializers) | |||||
| #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 | |||||
| #endif | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -102,6 +108,10 @@ | |||||
| #define JUCE_COMPILER_SUPPORTS_LAMBDAS 1 | #define JUCE_COMPILER_SUPPORTS_LAMBDAS 1 | ||||
| #endif | #endif | ||||
| #if _MSC_VER >= 1800 | |||||
| #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 | |||||
| #endif | |||||
| #if _MSC_VER >= 1900 | #if _MSC_VER >= 1900 | ||||
| #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 | #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 | ||||
| #define JUCE_DELETED_FUNCTION = delete | #define JUCE_DELETED_FUNCTION = delete | ||||
| @@ -86,6 +86,13 @@ StringArray& StringArray::operator= (StringArray&& other) noexcept | |||||
| } | } | ||||
| #endif | #endif | ||||
| #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS | |||||
| StringArray::StringArray (const std::initializer_list<const char*>& stringList) | |||||
| { | |||||
| strings.addArray (stringList); | |||||
| } | |||||
| #endif | |||||
| StringArray::~StringArray() | StringArray::~StringArray() | ||||
| { | { | ||||
| } | } | ||||
| @@ -86,6 +86,10 @@ public: | |||||
| */ | */ | ||||
| StringArray (const wchar_t* const* strings, int numberOfStrings); | StringArray (const wchar_t* const* strings, int numberOfStrings); | ||||
| #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS | |||||
| StringArray (const std::initializer_list<const char*>& strings); | |||||
| #endif | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~StringArray(); | ~StringArray(); | ||||