Of course, this is not valid Standard C++, and VC 2008 disallows it:
1 2 3
string fn("data.txt");
ifstream ifs(fn); // Error! Should be ifstream ifs(fn.c_str());
ifs.open(fn); // Error! Should be ifs.open(fn.c_str());
I'm getting reports that it compiles under VC 2010, but I can't find any documentation of such an extension. I'm not in a situation where I can check this myself any time soon.
Aha! In the C++0x draft, it's in section 27.9.1.6, so it's not surprising that VC 2010 implements it. But I'll be damned if I can find it in the MSDN documentation. For example, on the page http://msdn.microsoft.com/en-us/library/zek0beca.aspx
I see a move constructor, so I know the page has been updated for VC 2010, but no constructor taking a const string&.
OK, now that I've had a chance to pore through VC 2010 documentation and the header files, I see that in a number of places, library features conditionally compiled if the macro _HAS_CPP0X is non-zero do not appear in the documentation. The file stream constructors and open functions that take const string& parameters fall in this category.