P
pauldepstein
I saw this code in the 4th edition of C++ Primer (Lippman, Lajoie and
Moo):
allocator<string> alloc;
string* sp = alloc.allocate(2);
alloc.construct(sp+1, string(b, e)); // b and e are string iterators.
I don't understand the reason for the "+1" in sp+1.
Wouldn't alloc.construct(sp, string(b,e)); be simpler and more
natural?
Is there a reason for the "+1"?
Many thanks for your help.
Paul Epstein
Moo):
allocator<string> alloc;
string* sp = alloc.allocate(2);
alloc.construct(sp+1, string(b, e)); // b and e are string iterators.
I don't understand the reason for the "+1" in sp+1.
Wouldn't alloc.construct(sp, string(b,e)); be simpler and more
natural?
Is there a reason for the "+1"?
Many thanks for your help.
Paul Epstein