I've seen cases before where it was intended to write a variable declaration
but a function prototype was written instead (e.g. X x();) but I've come
accross a new version of this (new to me at least) and I want to check I've
understood it correctly.
The code I wrote was.
std::istringstream buf("abc");
std::vector<char> vec(std::istream_iterator<char>(buf),
std::istream_iterator<char>());
To my surprise vec was interpreted as a function prototype. After a bit of
thought here's how I see it
std::istream_iterator<char>(buf)
is a parameter declaration with std::istream_iterator<char> as the type and
buf as the dummy parameter name, and also a superfluous pair of parens. So
far so good, the bit that I couldn't work out was how
std::istream_iterator<char>()
was being interpreted as a parameter declaration. Then it occured to me that
in function declarations you are allowed to omit the dummy parameter name,
so that std::istream_iterator<char>() could be interpreted as parameter
declaration with superfluous parens surrounding the missing dummy parameter
name!
Is this a correct interpretation? Or am I barking?
john