issues with std::wstring

S

sean.farrow

Hi:
I have the following code:
std::wstring Process =ProcessToFind;
//this is an lpwstr passed in to my function.
std::wstring test =boost::filesystem::wpath(szModName).filename();
//note: szModNameisretrived from a win32 api function.
When I do:
Process.Comparetest);
I get:
1>c:\work\access for everyone\dragonspeak\dragonspeak.cpp(45) : error
C2039: 'Compare' : is not a member of
'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>,
1> _Ax=std::allocator<wchar_t>
1> ]

I am using visual studio 2005, and this is the only error.
Anyone know whats happening, and how to fix this?
Any help much apreciated.
Sean
 
W

WANG Cong

Hi:
I have the following code:
std::wstring Process =ProcessToFind;
//this is an lpwstr passed in to my function.
std::wstring test =boost::filesystem::wpath(szModName).filename();
//note: szModNameisretrived from a win32 api function.
When I do:
Process.Comparetest);
I get:
1>c:\work\access for everyone\dragonspeak\dragonspeak.cpp(45) : error
C2039: 'Compare' : is not a member of
'std::basic_string<_Elem,_Traits,_Ax>'

C++ is case-sensitive, try Process.compare(test).
C++ standard library always has names in lower case.
 
M

mzdude

Hi:
I have the following code:
std::wstring Process =ProcessToFind;
//this is an lpwstr passed in to my function.
std::wstring test =boost::filesystem::wpath(szModName).filename();
//note: szModNameisretrived from a win32 api function.
When I do:
Process.Comparetest);
I get:
1>c:\work\access for everyone\dragonspeak\dragonspeak.cpp(45) : error
C2039: 'Compare' : is not a member of
'std::basic_string<_Elem,_Traits,_Ax>'
1>        with
1>        [
1>            _Elem=wchar_t,
1>            _Traits=std::char_traits<wchar_t>,
1>            _Ax=std::allocator<wchar_t>
1>        ]
more code would be helpful. The error message says that Compare is not
part of your wstring.

Process.Comparetest); isn't even valid C++.

I'll assume it's Process.Compare(test); Compare (or even compare)
isn't part of wstring.

Look up valid relation operators for basic_string. They include '==',
'<=' , '!=' etc. However, if you want something that is case
insensitive, look up functions like _wcsicmp().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top