Boost logo

Boost :

From: Achilleas Margaritis (axilmar_at_[hidden])
Date: 2007-09-23 17:51:46


O/H Larry Evans έγραψε:
> On 09/23/07 15:45, Achilleas Margaritis wrote:
> [snip]
>>> your gc_allocator to be used. Now that I think about it,
>>> maybe only the std_list::node::_next needs to be a gc_ptr<.>.
>>> That would save some time.
>>>
>> Ah, ok, now I get it :-). You are coding your own list.
>>
>> All you have to do is make every pointer gc_ptr<T> and allocate every
>> object using the collector.
>>
>> The node object must be allocated using gc_new.
>>
> So, instead of:
>
> //adds an element as the last entry
> inline void push_back(T const& elem) {
> node_ptr new_node=new node(elem);
> ...
> }
>
> It should be:
>
> //adds an element as the last entry
> inline void push_back(T const& elem) {
> node::allocator node_allocator;
> node_ptr new_node=node_allocator(1);
> new_node->_elem=elem;
> ...
> }
>
> at least, AFAICT. Haven't tested.
>

Indeed.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk