This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Implementation of forward_list (and compressed_pair)
- From: Ion Gaztañaga <igaztanaga at gmail dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 13 Oct 2008 22:55:59 +0200
- Subject: Re: Implementation of forward_list (and compressed_pair)
- References: <48F0EE6E.3000409@verizon.net>
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