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)


Ed Smith-Rowland wrote:
Greetings,

Here is an implementation of forward_list and a supporting utility, compressed_pair, that might be used in other containers.

The compressed pair is used to implement a pairs of allocators - one outer for the list node and one inner one for the type object. This mirrors proposals on scoped allocator. Otherwise, the implementation is similar to ext/slist and std::list in many respects.

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)...){} //... };

Regards,

Ion


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