Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: std::ostringstream unexpected behavior with .net 2003. (http://www.velocityreviews.com/forums/t267729-re-std-ostringstream-unexpected-behavior-with-net-2003-a.html)

Victor Bazarov 06-25-2003 10:20 PM

Re: std::ostringstream unexpected behavior with .net 2003.
 
"Nathalie D'Amours" <nathalie.damours@timespring.com> wrote...
> I am using Microsoft VC .net 2003 and the std::ostringstream seams to

behave
> in an unexpected way.
>
> 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?


Yes. Drop the "<< std::ends".

> Has anyone else seen the
> same problem?


Probably. I haven't.




All times are GMT. The time now is 11:08 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.