Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-10-10 18:12:14

----- Original Message -----
From: "Howard Hinnant" <hinnant_at_[hidden]>

> 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.

These two cases seem completely different to me. Does "getting ostringstream
up and running" include the ability to stream /any/ type at all into it,
regardless of whether the inserter is visible?

#include <sstream>
struct X;
void f(ostringstream& s, X const& x)
    s << x; // legal?

That would seem to me to be the analogous case.


  David Abrahams, C++ library designer for hire

        C++ Booster (
          email: david.abrahams_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at