Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2001-10-11 08:41:54


On Thursday, October 11, 2001, at 08:57 AM, scleary_at_[hidden]
wrote:

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

I think your rule would work. However I fear that it is overkill and
leads to an overly bloated lib.

For example, consider the Metrowerks lib:

The preprocessed file for this program:

#include <stdexcept>

int main() {}

is 338 lines long.

But changing the Metrowerks C++ lib to adhere to your proposal leads to
a preprocessed file that is 29889 lines long. There is no type-o. 88
times the amount of stuff to compile!

<stdexcept> references <string>. <string> references <istream> and
<ostream>. These headers reference <streambuf>, which in turn
references <locale>... Essentially <stdexcept> now includes just about
the entire C++ lib. Are we willing to pay this price?

-Howard


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