There is some unfortunate mechanism that merges tags initializer-list and initializer_list. In the new upcoming C++ Standard, these have quite different meanings and usage patterns, and are about different problem domains

class IntList {
  // This is a constructor that accepts an
  // initializer_list, which is a language-magic type supporting
  // iteration over a homogeneous initializer list 

// { 1, 2, 3 } is an initializer list.
int a[] = { 1, 2, 3 };

// {{"foo", 42}, {"bar", 43}} is an initializer list.
map<string, int> m = {{"foo", 42}, {"bar", 43}};

I'm not sure whether it's worth-while to introduce a special case for this, but it seems harmful to merge these two things, since the majority of uses of these two words will refer to the "initializer-list" case, but I still see significant cases of "initializer_list" (which is also the header file where the initializer_list class is defined in).

To be pedantic, there are three things, but I suspect "initializer-list" will, as the "-" is commonly used to serve as a space for tags, be used to mean "initializer list"

  • initializer list refers to the whole brace-enclosed thing - that is { 1, 2, 3 }.
  • initializer-list refers to the grammar that parses the content of the brace enclosed thing - that is, 1, 2, 3.
  • initializer_list refers to the type that a constructor or function can use to iterate over a homogeneous initializer list - that is std::initializer_list<>.

I would personally use stdinitializer-list for the case of std::initializer_list<> (like we use stdvector for std::vector<>) and initializer-list for the language construct.

I changed my question to use that scheme.


The problem with "correct" tagging is that tagging isn't and can't be perfect. Usage dictates tags, not the other way round; synonyms can nudge usage towards correctness but only by so much. That's why people can retag.

Since there can't be spaces in tags, the standard is to use dashes instead, hence there's no hope of separating initializer-list and initializer list; tag the latter instead :)

As for the other tag, [tag:initializer_list], there's actually no synonym rule in place. All underscores are turned into dashes automatically. So, there's also no hope of separating initializer-list from initializer_list.

I'm no C++ master, but I think this is akin to splitting hairs. They're all the same thing seen from three different points: grammar, type and... er... grammar again. If distinguishing is this important, use a second tag :)

  • I've an idea. I think i will use std::initializer_list for the other case! They are not really the same. It's like the difference between {1, 2, 3} and std::vector<int>. An std::initializer_list<int> is actually much more like a std::vector<int>. An initializer list is just a language construct. – Johannes Schaub - litb Jan 21 '11 at 12:04
  • 5
    Of course this is splitting hair. We're the C++ crowd, so what did you expect? – sbi Jan 21 '11 at 13:55
  • @johannes Nice try, but will people use the stdinitializer-list tag? :) – badp Jan 21 '11 at 15:26
  • @badp you can help make it happen: stackoverflow.com/tags/stdinitializerlist/info – Johannes Schaub - litb Mar 11 '16 at 18:51
  • @JohannesSchaub-litb I don't actually know any C++ :) – badp Mar 11 '16 at 22:38

Not the answer you're looking for? Browse other questions tagged .