Topic: Defect: std::endl in (a) 22.2.8/5, (b) 22.2.8/11, (c) 22.2.8/13,


Author: AlbertoBarbati@libero.it (Alberto Barbati)
Date: Sun, 16 Jan 2005 17:24:25 GMT
Raw View
Alf P. Steinbach wrote:
> std::endl is declared by <ostream>, which is not necessarily
> included by <iostream>.
>
> The cited paragraps, (a) 22.2.8/5, (b) 22.2.8/11, (c) 22.2.8/13 and
> (d) 27.6.1.3/22, contain program examples that use std::endl without
> including <ostream>, just <iostream>, and even though the unofficial
> revision list for C++2003 contains a fix for e.g. 22.2.8/11 this issue
> has not been fixed there (I don't have the C++2003 standard).
>

Well, if you want to be fussy, it's not a problem of std::endl only. If
<iostream> did not eventually include <ostream> then *any* meaningful
use of std::cout, including std::cout << "hello, world\n", would be
ill-formed, because all the necessary overloads of operator<< are
defined in <ostream>. Ditto for std::cin.

> My suggested resolution is to keep the examples as-is but ensure that
> the declaration of std::endl is available via <iostream>, since this
> is commonly assumed, both in textbooks and actual code.  Is there any
> problem in stating that <ostream> is included by <iostream>?  Otherwise
> one can simply state that std::endl is available via <iostream>.
>
Maybe it would simpler to add in the <iostream> synopsis in 27.3 the two
lines:

   #include <istream>
   #include <ostream>

just like the <ios> synopsis in 27.4 explicitly provides #include <iosfwd>.

Alberto

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]