Schik
Level: Legendary Smitemaster
Rank Points: 5381
Registered: 02-04-2003
IP: Logged
|
Re: VS.NET project (0)
Previously, begin() and c_str() were used almost interchangably in DROD code.
begin() returns an iterator, while c_str() returns a const char* (or const WCHAR*).
In VC6, a string iterator is typedef\'d to a char* I believe. In VS.NET, the iterator is an actual templated class, and there are no automatic conversion operators defined for it, so a char* and string::iterator can\'t be used interchangably.
So, if you saw both:
pRoomLabel->SetText(&*wstrDesc.begin());
pRoomLabel->SetText(wstrDesc.c_str());
in my changes, then it\'s most likely a mistake (not a bug, more of an inconsistency).
My thought was to use c_str() if I needed a const WCHAR*, and &*begin() if I needed a WCHAR*.
Strictly speaking, we probably shouldn\'t muck around with the memory used in a WSTRING directly like this (as with &*wstrDesc.begin()), but it seems to work.
____________________________
The greatness of a nation and its moral progress can be judged by the way it treats its animals.
--Mahatma Gandhi
|