
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