
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
is no bigger than vector , it's probably better just to allow forward iteration and then let the user create a vector as they want (for full random access manipulation). -Thorsten
However I assume you meant vector
to contain pointers to elements in the vector<char> storage of the container. But what happens if storage needs to be resized? OTOH, using vectorstd::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
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.
regards
-Thorsten
The 1st attachment uses the offset method for the container and has the: template<typename F> void push_back(F const&); method. The output is in 2nd attachment. -Larry