Boost logo

Boost :

From: rogeeff (rogeeff_at_[hidden])
Date: 2002-02-23 19:05:37


--- In boost_at_y..., "Mark Rodgers" <mark.rodgers_at_c...> wrote:
> ----- Original Message -----
> > Why did you choose private inheritance? Why not public abd
eliminate
> > all forwarding function?
>
> Three reasons:
>
> 1. I don't want the implicit conversion to the base.

What wrong with that? Other than item 3? I would consider this as a
useful feature allowing to pass container in old function expecting
regular container.

> 2. Sometimes the function needs to be more than a simple forward.
Then
> I don't want to "override" (i.e. hide) a non-virtual.

What wrong with that? You are doing that already. but with private
parent.

> 3. The base probably won't have a virtual destructor and so I want
to
> avoid deletions through a base pointer.

I would not say that it is more dangerous that s[0] = new T, but you
agreed to live with that.

>
> Mark

There are al least 2 significant(?) drawbacks with private
inheritance:
1. Need to forward all the functions
Now it's about 70-80 persent of all function you implemented.
2. Can't use custom function.
Since you forward only some functions you can't use any custom
function presented by base contaner. For example map::find, or any
custom function in my custom container.

Gennadiy.


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