Boost logo

Geometry :

Subject: Re: [geometry] geometries design question: inheriting from STL containers
From: Bruno Lalande (bruno.lalande_at_[hidden])
Date: 2013-05-22 09:24:45


Hi Tomislav,

I have a question regarding the Ring model. How come it inherits from a
> (STL) Sequence?
> Inheriting from STL containers is said to be a problem because of the
> lack of a virtual destructor.
> However, this is only dangerous if you try to use dynamic polymorphism
> with a container, accessing
> the derived container member functions using a base class container

Exactly, and that's not the intended use here. Inheritance is used for
aliasing in this situation, as a convenient way to pull the public
interface of the STL container. It's not intended to be used
polymorphically. The documentation implicitly incurs that by not mentioning
this implementation detail.

> , but
> why would anyone use
> pointers to containers?
>

Outside of Boost.Geometry there's plenty of reasons to do that, but you are
right to say that doing it with STL classes would be plain wrong. They are
not intended to be extended this way.

Bruno



Geometry list run by mateusz at loskot.net