|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-25 17:27:56
FWIW, here are the technical/historical reasons that we can't declare a
template parameter to be a friend.
-Dave
----- Original Message -----
From: "John H. Spicer" <jhs_at_[hidden]>
> David Abrahams wrote:
> >
> > Hi John,
> >
> > Can you provide rationale on this for us?
> >
> > The question, in a nutshell, is "why can't I declare a class template's
> > parameter to be a
> > friend of that class template ('s instantiation)"?
>
> The basic issue is whether a template parameter can be used in an
elaborated
> type specifier (a friend class declaration is just a kind of elaborated
> type specifier).
>
> The committee had two choices:
>
> - permit elaborated type specifiers that refer to template parameters and
> update the rules to specify what happens when a template parameter has
> a conflicting type
>
> - disallow such use, as is the case with typedefs
>
> Template parameters generally behave a lot like typedefs so this seemed
like
> a good way to go. When this was discussed, no one suggested any reasons
why
> it would be useful to allow such friend declarations, so we went with the
> prohibition.
>
> If you permit elaborated type specifiers that use template parameters, you
> then have to describe cases like:
>
> template <class T> void f(struct T);
> template <class T> void f(enum T);
>
> In other words, can you overload on the kind of elaborated type specifier
> tag?
>
> John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk