Initialise NamedValueSets using std::initializer_list


Hi everybody,

I noticed that the NamedValueSet doesn’t have a constructor that takes a std::initializer_list as parameter. This could be useful for writing almost JSON like data with a least possible amount of boilerplate like this:

NamedValueSet data =
  {"item1", 20},
  {"item2", "Blabla"}

The changes in the JUCE code are trivial. In NamedValueSet.h, add somewhere after the NamedValue definition:

	NamedValueSet(const std::initializer_list<NamedValue>& items) noexcept;

and in NamedValueSet.cpp:

NamedValueSet::NamedValueSet(const std::initializer_list<NamedValue>& items) noexcept
	: values(items)

There is already something like this for ValueTrees, but the NamedValueSet deserves some C++11-love too…


Thanks - good request, I’ll add that.

(No need for the macro any more - all the compilers we support can do initialiser lists now)