Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2000-10-05 11:11:48


on 10/5/00 8:47 AM, Paul Hollingsworth at boost_at_[hidden] wrote:

> One solution I thought might work would be:
>
> namespace impl {
> #include <vector>
> }
>
>
> That is, according to the ANSI/ISO standard, should you be able to use this
> trick?

Absolutely not.

The specific language in the ISO standard is "A translation unit shall
include a header only outside of any external declaration or definition,
[...]" (17.4.2.1/3). The code above includes the header inside a namespace
definition.

> So, are there any other cool tricks that can be brought to bear on this
> problem?

The standard is specifically designed so that including any one standard
header is allowed to pull in all the rest of the standard headers. I don't
know of any tricks to get around this for programmers who want to write
standard code, although I could imagine a compiler/library implementer
making a feature that would enforce some kind of programming rule like this.

    -- Darin


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