Question

Here's the code:

std::filebuf fbuffer;
if ( fbuffer.open( fileName, std::ios::in ) )
{
    std::istream str( &fbuffer );
    std::tstring line;
    while ( std::getline( str, line, '\n' ) )
    {
        //parsing
    }
}

In the project I got this code from, this compiles fine. When I copy/pasted this code into a throwaway project, I got the following errors (trimmed some template junk for brevity):

std::getline expects 2 arguments - 3 provided //getline() has overloads for 2 and 3 arguments
std::getline( std::basic_istream, std::basic_string, const _Elem ) template parameter '_Elem' is ambiguous: could be wchar_t or char

I've been fiddling with the project settings to no avail. Any ideas?

Was it helpful?

Solution

Found a #define:

#ifdef _UNICODE
#define tstring wstring
#else
#define tstring string
#endif

I changed the project's Character Set to "Not Set" and it compiles fine. Thanks to @chris's comment for pointing me in the right direction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top