Boost logo

Boost :

From: Gavin Collings (gcollings_at_[hidden])
Date: 2000-03-21 12:13:30

"borgerding, mark a." <marka-_at_[hidden]> wrote:
original article:
> There are a few reasons I shied away from using template friends
> 1) Compiler support for template friends is less than universal.
> them reduces the amount of #ifdef code to maintain.
> 2) I don't like using friends unless they clearly strengthen
> (This point is arguable for linked_ptr_base)
> 3) I think it reads better without the template friends. (Personal
> preference perhaps)

There do seem to be arguments in both directions for this type of
thing. I tend to go with Scott Meyers et al and use public inheritance
only to express an is-a relationship. Though I have to confess to
getting a little tired of the using directives that the approach
implies (and have bypassed them on occasion).

Answering your points.

1) Yes it is a pain that template friends aren't universally supported,
but hopefully, it's a temporary situation.

2) The argument for increased encapsulation is exactly that for which
Miki proposed his fix - that of clients getting hold of a
linked_ptr_base pointer. This is highly unlikely in itself, since
linked_ptrs would typically be used by value, so polymorphism wouldn't
enter in to it. But having acknowledged that a problem exists, better
to make more explicit the fact that a linked_ptr should not be used as
a linked_ptr_base IMO.

3) My personal preference leans the other way. Not strongly though, if
you say no, I'll leave it as it is.


Boost list run by bdawes at, gregod at, cpdaniel at, john at