Firstly, is std::string the same thing as basic_string? The reason I'm asking is that I can never find anything on MSDN about std::string - but basic_string seems very similar.
Anyway, here's my question - Yesterday I was looking at some code that I wrote a long time ago. It does some string comparisons and I realised that I should probably have written something like this:-
whereas in fact, I did it this way:-Code:#include <string> using namespace std; void MyFunc ( string someString, char* compareString ) { if ( 0 == someString.compare( string( compareString ))) ; do something here.... }
That code appears to work just fine - even though this MSDN article seems to suggest that basic_string has no equality operators.Code:#include <string> using namespace std; void MyFunc ( string someString, char* compareString ) { if ( someString == compareString ) ; do something here.... }
Am I looking at the wrong MSDN article? Or is it out of date? Or have I somehow been kidding myself all these years and the code doesn't really work??![]()




Reply With Quote