
On 18-03-2013 15:46, Nevin Liber wrote:
On 18 March 2013 09:35, Nevin Liber
wrote: On 18 March 2013 07:29, Thorsten Ottosen
wrote: Its no different than using boost::function<>, that is, it allow us to make a generic interface with decisions deferred till run-time (at the expense of a performance loss).
It isn't just *one* generic interface; the underlying iterators have to be type erased as well.
Sure. That has been done: http://www.boost.org/doc/libs/1_53_0/libs/range/doc/html/range/reference/ran...
To be completely generic, you may need to type erase allocator_type, pointer, const_pointer, reference, const_reference, size_type and difference_type (since they may all differ between containers, and many of those types now come from the underlying allocator), as well as have the ability to pass an allocator in for both holding the type erased container as well as any of the underlying type erased objects.
Well, I don't see a need for all the allocator stuff. What the point? Do you have a similar need when using boost::function<> or boost::any? reference/const_reference can be T& and T const&. Perhaps we don't need pointer. One may choose a difference_type that is 64 bit to be generic. -Thorsten