Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2006-11-20 11:08:33

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

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

So to catch this particular bug (mistaken uses of <iostream>) we
would need a tool that looked for std::ios_base::Init constructors in
the translation unit, but no uses of one of the eight terminal
streams. Outside of a grep-like tool operating on the preprocessed
translation unit (as an extra compilation phase), I'm not sure how to
catch that with a std::lib implementation or prototype. Seems like
something the compiler could do no problem though. :-)


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