wifstream
Jonathan Wakely
jwakely.gcc@gmail.com
Fri Aug 15 15:54:00 GMT 2014
On 15 August 2014 16:49, ArbolOne wrote:
> In my Windows 7 this code doesn't work:
> std::wstring& getFileName() {
> return file_name;
> }
> myMethod(){
> wchar_t tmp = *getFileName().c_str() ;
> std::wifstream infile( tmp ); // <<-- error: invalid conversion
> from 'wchar_t' to 'const char*' [-fpermissive]
> return infile.good( );
> }
>
>
> It seems to me that std::wifstream does not accept wchar_t as a value
> type, but only const char*, contrary to to what is explained in
> http://msdn.microsoft.com/en-us/library/3b5w4311.aspx
That is describing the MS library, it's not the standard.
> Where did I go wrong? or, is this a bug?
No, the standard says that basic_fstream always takes narrow character
strings to specify the filename, even if the stream itself uses wide
characters.
More information about the Gcc-help
mailing list