Subject: Re: [boost] [cpo-proposal] presentation of the idea
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-08-19 16:18:41
On 08/19/13 09:41, Thorsten Ottosen wrote:
> On 19-08-2013 16:30, Larry Evans wrote:
>> On 08/19/13 09:06, Thorsten Ottosen wrote:
>>> Since the size of vector<T*> is no bigger than vector<size_t>, it's
>>> probably better just to allow forward iteration and then let the user
>>> create a vector<T*> as they want (for full random access manipulation).
>> However I assume you meant vector<T*> to contain pointers to elements
>> in the vector<char> storage of the container. But what happens if
>> storage needs to be resized? OTOH, using vector<std::size_t> to
>> store the offsets would not be invalidated by resizing storage.
> True, there are different tradeoffs.
> At least in my use cases, the objects would be loaded at application
> start, and remain in memory until the application exists. Therefore,
> I can create a vector<T*> object after loading the data and rely on the
> pointers to be valid throughout the entire application lifetime.
> Perhaps push_back should return the offset instead, leaving it up to the
> user if he needs to store the offset or the pointers?
> Anyway, I think the basic functionality of this library should
> strive for minimal overhead, and then perhaps expose various
> container adaptors that add more functionality.
The 1st attachment uses the offset method for the container
and has the:
template<typename F> void push_back(F const&);
The output is in 2nd attachment.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk