I was reading an SO post where one user made the following comment:
Also note that
ArrTest<int> ar();uses most vexing parse.
But another user said the opposite:
ArrTest<int> ar();is not the "most vexing parse". It's just a function declaration. It's certainly vexing for beginners, but, as the page you linked to indicates, the "most vexing parse" is more convoluted.
The code example from that post is given below for reference:
template <class ItemType>
class ArrTest {
public:
ArrTest();
private:
ItemType* info;
};
//some other code here
int main() {
ArrTest<int> ar(); //DOES THIS USE THE MOST VEXING PARSE?
return 0;
}
My first question is that is the concept of "most vexing parse" formally defined by the C++ standard. My second question is that does the statement ArrTest<int> ar(); uses most vexing parse. That is, which of the above two quoted comments is technically correct?
This also seem to suggest that MyObject object(); is most vexing parse.
No. There is no concept of "most vexing parse" defined in the C++ standard. The standard does define the grammar from which the ambiguities arise, and it defines the rule that resolves the ambiguities, but it doesn't name the ambiguities.
According to Wikipedia: "The term "most vexing parse" was first used by Scott Meyers in his 2001 book Effective STL.". The example in the book is:
The way I would describe "MVP" is that there is an intention to declare a variable, with passed argument(s), but you end up actually writing a function declaration and the intended arguments turn out as parameter declarators.
The book explicitly mentions this ambiguity as well:
Given that the author who came up with the name for the ambiguity considers this as another manifestation - as opposed to the same manifestation - of a language rule, I would say that the example in question is not the "MVP". It's another, similar, and in my opinion less vexing ambiguity.