Boost logo

Boost :

Subject: Re: [boost] [Block.Pointer][Container] List node allocator
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2016-03-01 16:27:31

On 01/03/2016 14:14, Phil Bouchard wrote:
>> But after debugging the code it looks like the allocator is not used to
>> instantiate the nodes and I do not see how it is used by looking at the
>> code:
>> template <class T, class VoidPointer>
>> struct list_node
>> : public list_hook<VoidPointer>::type
>> {
>> private:
>> //list_node();
>> public:
>> typedef T value_type;
>> typedef typename list_hook<VoidPointer>::type hook_type;
>> T m_data;
>> T &get_data()
>> { return this->m_data; }
>> const T &get_data() const
>> { return this->m_data; }
>> };
>> Am I missing something?

A node is created using allocator_traits::construct, which is what the
standard mandates.

> Sorry I forgot that the header node is instantiated on the stack. Smart
> pointers pointing to objects on the stack doesn't work so therefore
> modifications to the Container API will be needed to support smart
> pointers.

Supporting embedded end pointers is not only an option, but the choice
of most STL implementations. It makes default constructors nothrow and
improves performance. Any smart pointer should support pointing to those
end nodes or it's just broken for STL-like containers.



Boost list run by bdawes at, gregod at, cpdaniel at, john at