O
Old Wolf
In a discussion elsewhere, someone wrote:
#include <iostream> is not guaranteed to define std::cout, it
merely has to declare it as an extern object, and declarations
of extern objects do not require complete types. As far as I
understand, a implementation is free to use a certain amount
of compiler magic to be able to declare std::cout etc. without
defining basic_ostream.
Is this correct? If so, then it would mean that the following program
is invalid:
#include <iostream>
int main() { std::cout; }
I don't see how an extern definition can be provided but the type
be incomplete (unless it is a definition of an array of unknown size).
Secondly, section 27.3 of the standard (1998) says that <iostream>
must define:
extern ostream cout;
but says nothing else about ostream. Does this imply that std:
stream
must be declared at this point (ie. basic_ostream<> must have been
declared, and typedef'd to ostream as well) ?
#include <iostream> is not guaranteed to define std::cout, it
merely has to declare it as an extern object, and declarations
of extern objects do not require complete types. As far as I
understand, a implementation is free to use a certain amount
of compiler magic to be able to declare std::cout etc. without
defining basic_ostream.
Is this correct? If so, then it would mean that the following program
is invalid:
#include <iostream>
int main() { std::cout; }
I don't see how an extern definition can be provided but the type
be incomplete (unless it is a definition of an array of unknown size).
Secondly, section 27.3 of the standard (1998) says that <iostream>
must define:
extern ostream cout;
but says nothing else about ostream. Does this imply that std:
must be declared at this point (ie. basic_ostream<> must have been
declared, and typedef'd to ostream as well) ?