Re: custom allocator issue
ranin02 wrote:
:: Thanks very much for the response. I got past that part, but now
:: have a puzzling error. I am seeing the following error
::
:: error C2664:
:: 'CObjectPoolListAlloc<Ty,_Node>::CObjectPoolListAlloc(const
:: CObjectPoolListAlloc<Ty,_Node> &) throw()' : cannot convert
:: parameter 1 from 'CObjectPoolListAlloc<Ty,_Node>' to 'const
:: CObjectPoolListAlloc<Ty,_Node> &'
::
:: And the error is actually being given within the STL list code
:: here: _List_ptr(_Alloc _Al)
::: _List_nod<_Ty, _Alloc>(_Al), _Alptr(_Al)
::
:: Why on earth would it not be able to convert to a const ref? Note
:: that CObjectPoolListAlloc does not in fact define a copy
:: constructor, but defaults to the base class. This code compiled
:: fine before the upgrade and my attemp to implement Rebind. Please
:: forgive me if this is a stupid question.
You do need a copy constructor (which might be the default), as well
as a converting constructor like
template<class _OtherT>
allocator(const allocator<_OtherT>&) throw()
{ }
allocator(const allocator&) throw()
{ }
because std::list uses two copies of the constructor, with slightly
different types.
Bo Persson