In an answer there was the following code:
if (std::ifstream input("input_file.txt"))
;
Which seems convenient, limiting the scope of the 'input' variable to where it's confirmed to be valid, however neither VS2015 nor g++ seems to compile it. Is it some compiler specific thing or does it require some extra flags?
In VS2015 the IDE highlights "std::ifstream" and the "input_file.txt" as well as the last parentheses. "std::ifstream" is flagged with "Error: a function type is not allowed here".
VS2015 C++ compiler gives following errors:
- C4430 missing type specifier - int assumed. Note: C++ does not support default-int
- C2059 syntax error: '('