You are a victim of Vexing Parse itself, where the compiler sees your declaration as a strings function, returning a vector<string> , taking two arguments:
- a
istream_iterator<string> is called file - unnamed function pointer without arguments and returning
istream_iterator<string> .
To eliminate annoying parsing, use an extra pair of parentheses around the first argument:
vector<string> strings((istream_iterator<string>(file)) , istream_iterator<string>());
or alternatively in C ++ 11, use curly braces for the strings constructor
vector<string> strings{istream_iterator<string>(file) , istream_iterator<string>()};
NOTE : Clang warns you about this via -Wvexing-parse (default).
source share