$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [config] request for BOOST_NO_FWD_STD_DECLARATION
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-02-22 08:41:05
On 22 Feb 2011, at 13:28, Felipe Magno de Almeida wrote:
> On Wed, Feb 16, 2011 at 12:49 PM, Mathias Gaunard
> <mathias.gaunard_at_[hidden]> wrote:
>> On 16/02/2011 13:52, Christopher Jefferson wrote:
>
> [snip]
>
>>> The question is then if forward declarations of types in std:: are
>>> allowed. From 17.6.3.2.1p1 in the current C++0x draft (there is identical
>>> text in the c++03 standard):
>>>
>>> "The behavior of a C++ program is undefined if it adds declarations or
>>> definitions to namespace std or to a namespace within namespace std unless
>>> otherwise specified."
>>>
>>> While people could read this in various ways, I would say it forbids these
>>> kinds of games, although they might work for particular standard libraries.
>>
>> The standard also gives the reference of what the declarations of the
>> classes of the standard library must be, and all those declarations are in
>> namespace std.
>
> Isn't the standard library allowed to add template parameters with defaults?
>
> template <typename T, typename Allocator, typename _InternalParameter = int>
> struct vector;
No.
The fine details of the standard aren't really important here anyway. In practice there are compilers where we have been able to write well-defined forward declarations for many years and people have found them useful. On other standard libraries, like libc++, forward declarations are hard to write and not advised.
Therefore we should support forward declarations where we can, and just include the standard headers where we can't.
Chris