Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2001-10-10 15:49:37


On Wednesday, October 10, 2001, at 04:07 PM, Joachim Achtzehnter wrote:

>> Bottom line is that I don't use std::basic_string anywhere in the
>> code
>
> This argument is hard to defend. string may not appear literally in
> your code, but in the absence of a const char* ctor your code is
> clearly constructing a string.

The reverse argument is hard to defend too. Is this code portable?

#include <sstream>

int main ()
{
        std::ostringstream s;
     s << "Hello, World!\n";
}

This code implicitly relies on basic_ostream defined in <ostream> and
basic_ios defined in <ios>. Since templated base classes can be derived
from with merely a forward declaration of the templated base, it is not
clear if <ostream> and <ios> are implicitly included. If <ostream> is
not included, then even the operator<<(const char*) won't be in scope!

I've never seen such a deviant implementation of the standard C++ lib,
and hope I never do. Most people (rightly) believe that if you include
<sstream> then that's all you need to get ostringstream up and running.

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk