FR: StringArray constructor with initializer_list<String>

.h

StringArray (const std::initializer_list<String>& strings);

.cpp

StringArray::StringArray (const std::initializer_list<String>& stringList)
{
    strings.addArray (stringList);
}

Usage example:

StringArray daysOfTheWeek =
{
    TRANS ("Sunday"),
    TRANS ("Monday"),
    TRANS ("Tuesday"),
    TRANS ("Wednesday"),
    TRANS ("Thursday"),
    TRANS ("Friday"),
    TRANS ("Saturday")
};

I thought that was already added:

#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
StringArray (const std::initializer_list<const char*>& strings);
#endif

Aah… never mind… I see your addition :blush:

Rail

To some extent it’s there, but only for const char*!

1 Like

Yes, I noticed the difference but it was too late to delete my post… hence the :blush:

Cheers,

Rail

Bump, before getting drowned out by DSP module things!

I had been planning to add a bunch of variadic constructors and add methods to the arrays for this kind of thing, which should be more versatile than an initializer_list

1 Like

Presumably this would mean, in terms of StringArray, that you can specify primitive types and various string formats (CharPointer_UTF8, CharPointer_UTF16)?

I think anything that could be cast to a string would work.