Answer the question
In order to leave comments, you need to log in
Do I need to use allocator::construct()?
In Björne Stroustrup's book, object initialization only goes through construct(). In the case of copying, the code looks like this:
for (int i=0; i<sz; ++i) alloc.construct(&p[i], elem[i]);
std::copy(elem, elem+sz, p);
Answer the question
In order to leave comments, you need to log in
Depending on what you want to do.
yeah, only there will be memcpy or memove inside.
If you are using an allocator to allocate memory, then there is no point in not using it for initialization. Another question is whether it makes sense to use it at all. If you do not quite understand why you need an allocator, then most likely you do not need it at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question