Allocators

Jonathan M Davis jmdavisProg at gmx.com
Fri Aug 23 15:58:50 PDT 2013


On Friday, August 23, 2013 22:20:21 Timon Gehr wrote:
> On 08/23/2013 10:08 PM, Peter Alexander wrote:
> > On Friday, 23 August 2013 at 20:04:28 UTC, H. S. Teoh wrote:
> >> What's the problem with const again?
> > 
> > I'm thinking mainly of const postblit, and the ramifications of solving
> > that.
> 
> What problem does const postblit have that a const constructor does not
> have?

A copy constructor creates a new object from scratch, so it doesn't modify 
anything, and creating it as const is fine. postblit on the other hand does a 
memcopy of the object first and then modifies select portions of the copy. When 
constructing a const or immutable object, that would mean that you have to 
modify a const or immutable object in order to mutate the portions that the 
postblit is supposed to be mutating. We need a way to construct a copy rather 
than copy and mutate, so AFAIK, we basically need to add copy constructors to 
solve this problem.

- Jonathan M Davis


More information about the Digitalmars-d mailing list