Digging through MSDN, I ran into just another curious line:
// This function returns the constant string "fourth".
const string fourth() { return string("fourth"); }
The full example is buried here: https://msdn.microsoft.com/en-us/library/dd293668.aspx Refined to bare minimum, it looks like this:
#include <iostream>
const int f() { return 0; }
int main() {
std::cout << f() << std::endl;
return 0;
}
A few other tests with different return types demonstrated that both Visual Studio and g++ compile lines like this without a warning, yet const qualifier seems to have no effect on what I can do with the result. Can anyone provide an example of where it matters?