Boost logo

Boost :

From: Bo Persson (bop_at_[hidden])
Date: 2006-11-20 13:51:21


Howard Hinnant wrote:
> On Nov 20, 2006, at 7:48 AM, John Maddock wrote:
>
>> As an aside, I've always wanted a sort of "conceptual" std lib
>> implementation, that included in each header nothing except what
>> absolutely
>> has to be there. Just the declarations would do, so we could do
>> compile-time tests against it to verify inclusion of the right
>> headers: the
>> only tricky bit is getting the compile time constants correct so
>> that it can
>> still compile meta code. Any volunteers? :->
>
> One of the problems with this project is deciding exactly what
> should
> appear in the headers. For example, imho, this is a valid C++
> program:
>
> #include <iostream>
>
> int main()
> {
> std::cout << "Hello World\n";
> }
>
> In order for that to be valid, <iostream> must declare and define
> the namepace scope:
>
> template<class traits>
> basic_ostream<char, traits>&
> operator<< (basic_ostream<char, traits>& out, const char* s);
>
> which lives in <ostream>. In other words, I think it would be
> incorrect for <iostream> *not* to include <istream> and <ostream>.

But the standard doesn't say so explicitly. So how do we know?

Section 27.3 just says that "The header <iostream> declares objects
that...". It doesn't say that any types or operators are defined.

>
> I have heard people argue that HelloWorld should include <ostream>
> explicitly as well. But imho that leads to a C++ language spec that
> is just too difficult and cumbersome to use (and we're already at
> risk for that reputation).

It *is* possible to just include <iosfwd> to be able to declare (not define)
the extern stream objects. Isn't that what <iosfwd> was designed for?

Bo Persson


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