Re: std::ostringstream unexpected behavior with .net 2003.
"Nathalie D'Amours" <firstname.lastname@example.org> wrote in message
> int i = 3;
> std::ostringstream os;
> os << i << std::ends;
> std::string s1 = os.str();
> std::string s2("3");
> bool result = (s1 == s2);
> When I execute this code, 'result' gets set to false. Obviously I am
> expecting the strings to be identical. I've stepped in the comparison
> code and the internal call to ::strcmp correctly returns 0 but then there
> is some logic to compare the string lengths and they differ. s1 size is
> 2 and s2 is 1 and this is why the comparison function returns false.
> This seems buggy to me. Am I missing something? Has anyone else seen the
> same problem?
s1 is two characters: '3' and std::ends. s2 is one character: '3'.
You shouldn't use std::ends with ostringstreams. std::ends is useful only
with ostrstreams, which are deprecated.
|All times are GMT. The time now is 01:32 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.