|
Boost : |
From: scleary_at_[hidden]
Date: 2001-10-11 07:57:48
-----Original Message-----
From: David Abrahams <david.abrahams_at_[hidden]>
> ----- Original Message -----
> From: "Howard Hinnant" <hinnant_at_[hidden]>
>
> > Additionally, it would be nice if we had some generalized rules that
> > said /why/ this is portable code, instead of just saying: well,
> > <sstream> will include <ostream> and <ios> and whatever else is
> > necessary to make this work. Maybe the paragraph I proposed eariler
> > isn't the correct generalized rule. But I would like to
> see something
> > like that; fairly easy to understand, and generally applicable.
>
> A rule I would consider acceptable (but which wouldn't help Bill) is:
>
> "any standard header which supplies the /definition/ of a class template
> also supplies the definition of all of its base classes"
"any standard header which supplies the /definition/ of a class template
also supplies the definition of all names in that definition that are not
template-parameters"
would take care of exception construction for Bill, and several other
similar problems: template default parameters, such as allocator and
char_traits...
#include <string> // for char_traits
#include <memory> // for allocator
#include <ios> // for basic_ios
#include <ostream> // for basic_ostream
#include <sstream> // for ostringstream
std::ostringstream out; // OK, now this is legal...
The only hole I see right away is that <memory> doesn't require the
definition of std::bad_alloc, which would be nice. Maybe we could add
something about exceptions?
I don't have the time to go through all the std library components in
detail, but the above rule should handle most cases.
> That rule gives you the ability to construct an ostringstream by including
> <sstream>. I don't think it lets you stream a char* into that
ostringstream,
> because the definition of the appropriate inserter might still not be
> available. I don't know how to reasonably extend the rule above so that it
> would let you stream the char* without including <ostream>, but I'm open
to
> ideas.
We could use the rule above, plus another rule that says that any header
that supplies a definition also supplies all the definitions for other types
in its corresponding header, then that would be OK.
-Steve
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk