Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#7408 closed Bugs (fixed)

istream_range should not pull istream

Reported by: Christopher Yeleighton <giecrilj@…> Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.51.0 Severity: Optimization
Keywords: Cc:

Description

To minimize the time you have to wait on the compiler, it is good to only #include the headers you really need. istream_range.hpp simply #includes <istream> when it does not need to — and that can penalize the runtime as well.

<iosfwd> should be #included whenever you simply need the name of an I/O-related class, such as "basic_istream". Like the name implies, these are forward declarations.

Change History (7)

comment:1 by viboes, 10 years ago

Component: Nonerange
Owner: set to Neil Groves
Version: Boost 1.52.0Boost 1.51.0

comment:2 by Nathan Ridge, 9 years ago

(In [84644]) [range] Don't include <istream> unnecessarily in istream_range.hpp (refs #7408).

comment:3 by Nathan Ridge, 9 years ago

Fixed in trunk. However, I'm not convinced that this accomplishes anything, as istream_range.hpp includes <iterator> to use istream_iterator, and <iterator> most likely needs to bring in <istream> to properly define istream_iterator (since it's a template class so its methods need to be defined in the header). libstdc++'s <iterator>, for example, brings in <istream>.

comment:4 by Nathan Ridge, 9 years ago

Resolution: fixed
Status: newclosed

(In [84823]) [range] Merge Boost.Range bug fixes to release branch (fixes #6944; fixes #7407; fixes #7408; fixes #7731; fixes #7827; fixes #8338; fixes #8453).

comment:5 by Nathan Ridge, 9 years ago

Fixed for 1.54.

in reply to:  3 ; comment:6 by ne01026@…, 9 years ago

Replying to nathanridge:

Fixed in trunk. However, I'm not convinced that this accomplishes anything, as istream_range.hpp includes <iterator> to use istream_iterator, and <iterator> most likely needs to bring in <istream> to properly define istream_iterator (since it's a template class so its methods need to be defined in the header). libstdc++'s <iterator>, for example, brings in <istream>.

#include <iterator>
void foo (::std ::wistream & = ::std ::wcin);

error: ‘wcin’ is not a member of ‘std’ (good!)

in reply to:  6 comment:7 by Nathan Ridge, 9 years ago

Replying to ne01026@…:

Replying to nathanridge:

Fixed in trunk. However, I'm not convinced that this accomplishes anything, as istream_range.hpp includes <iterator> to use istream_iterator, and <iterator> most likely needs to bring in <istream> to properly define istream_iterator (since it's a template class so its methods need to be defined in the header). libstdc++'s <iterator>, for example, brings in <istream>.

#include <iterator>
void foo (::std ::wistream & = ::std ::wcin);

error: ‘wcin’ is not a member of ‘std’ (good!)

That would be because 'wcin' is defined in <iostream>, not <istream>, and <iterator> doesn't bring in <iostream>, only <istream>. istream_range.hpp has never brought in <iostream>, either, so I don't see how this is relevant.

Note: See TracTickets for help on using tickets.