This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implementation of forward_list (and compressed_pair)


Ion Gaztañaga wrote:
> Just a comment. Why do you need to store two allocators? This will
> increase the size of the list for stateful allocators (after all
> forward list has no size() to save space) and now that we have
> variadic construct() in allocators, we can just store the node
> allocator and construct the node using a new constructor for the node:
>
>     struct _Fwd_list_node : public _Fwd_list_node_base
>     {
>       template<class ...Args>
>       _Fwd_list_node(Args && args)
>       : _Fwd_list_node_base(), _M_value(std::forward<Args>(args)...){}
>       //...
>     };
Ah! I think this is right! And, I must say, I'm "guilty" of having
sidetracked Ed to the issue of having a pair of allocators stored for
efficiency. Now I see that indeed thanks to the new variadic
allocator::construct one can construct in place using the same node
allocator (provided one adds an appropriate constructor for the node as
you are doing above).

So... We are learning something: after all, the experimental C++0x mode
is here also for that reason! Ed, do you want to play with the above?

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]