Boost logo

Boost :

Subject: Re: [boost] [Containers] Should flat_* expose implementation vector?
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2011-08-08 13:53:28


Den 06-08-2011 02:32, Phil Endecott skrev:
> Dear All,
>
> Should Ion's proposed flat_set, flat_map etc. expose the underlying
> vector that they use as their implementation?

Yes!

> Pros: it lets the user efficiently load and save the content, and
> implement algorithms that cannot be done via the flat_* interface.
>
> Cons: it lets the user break the invariants.
>
> Const access to the impl is another possibility.

The interface should be like this, like we e.g. do it PtrContainer:

Container& base();
const Container& base() const;

This ensures that const flat_xxx objects preserves invariants
(unless you do a const_cast which is ok).

We can never foresee all uses, and overincapsulation is a serious issue.

I have also never heard complaints about the interface in PtrContainer,
and it has been useful more than once for users.

-Thorsten


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