The domain and terminology
Just so we're all on the same page when it comes to the terminology, I'll summarize it. A constructor in C++ can have an optional ctor-initializer which is a grammatical rule that expands to:
For example:
struct S {
int x;
S() : x() {} // ": x()" is the ctor-initializer, and
// "x()" is the mem-initializer-list
};
This construct isn't formally given a name in the C++ standard, but the most accepted name for it is "member initializer list" which closely follows the name of the grammatical rule. See the cppreference article Constructors and member initializer lists. Some people also refer to it as "initialization list". CppCoreGuidelines contains both "member initializer list" and "initialization list".
There is also the fairly ambiguous name "initializer list" which may refer to one of three things:
- the mem-initializer-list grammatical rule
- the standard library class
std::initializer_list
- the initializer-list grammatical rule, as in list initialization like
std::pair{1, 2}
The tagging situation
Tag | Questions | Summary |
---|---|---|
ctor-initializer | 78 | Unambiguous tag, but rarely used because intuitively, people think of this construct as "member initializer list" or "member initialization list". Some people may also call it "constructor initializer list", which is a misnomer because a constructor only has one initializer, but multiple member initializers. |
initialization-list | N/A | Synonym for ctor-initializer. This synonym somewhat mitigates the problem with the first tag. |
member-initialization | 127 | Closely related to ctor-initializer, and most questions with this tag should probably be tagged ctor-initializer too. However, this is only the case for 4 questions. It looks like this tag is a sink that misleads people into thinking that there is no tag for the member initializer list. |
initializer-list | 1,207 | This tag is used for all three of the above meanings of "initializer list", despite the excerpt clearly saying that it refers to std::initializer_list only. |
stdinitializerlist | 53 | Unambiguously refers to std::initializer_list . Pending synonym suggestion. |
list-initialization | 337 | Unambiguously refers to list initialization, and is thus a better tag than initializer-list. However, it is not as commonly used. It has 36 questions in common with the latter. |
The problem in summary
The tag initializer-list is ambiguous and commonly misused. ctor-initializer is very rarely used because of its obscure name, and initialization-list does not fully solve the problem because many people understand the construct as "member initializer list". member-initialization is almost a synonym for ctor-initializer, based on its usage, but actually making it a synonym would not be appropriate because it isn't equivalent.
I believe that the tagging situation is quite chaotic and confusing, with tags not being used enough or being frequently misused. What would be a good solution to the current situation?