[computer-go] C++: sstreams

Lars Nilsson chamaeleon at gmail.com
Wed Aug 9 10:42:34 PDT 2006


On 8/9/06, Peter Drake <drake at lclark.edu> wrote:
>
> I've followed the idiom and overloaded << so that I can print instances of
> my classes to any output stream.  This much works fine:
>
> BitBoard b;
> b.clear();
> b.add(1);
> ostringstream s;
> s << b;
>
> Now, though, I want to compare s with a different string. The compiler won't
> accept this:
>
> assert(s == ".....\n.....\n.....\n.....\n.X...\n");
>
> Do I have to do something to convert s into a string?

assert(s.str() == " ... ");

Lars Nilsson


More information about the computer-go mailing list