~= call copy ctor?

Jonathan M Davis jmdavisProg at gmx.com
Sun Jul 22 02:02:51 PDT 2012


On Sunday, July 22, 2012 10:46:51 Namespace wrote:
> Oh yes, i mean std.typecons, not std.algorithm, my bad.
> 
> If delete will be deprecated, how can i delete/call dtor of one
> of my objects manually?

You're _really_ not supposed to be doing that. If you're dealing with GC 
allocated memory, then it's the GC that should be freeing it, not you. It's 
unsafe for you to be doing it, and it's just asking for bugs. If you want to 
be manually managing memory, you should be using malloc and free (which 
admittedly is a bit of pain with objects right now - custom allocators should 
fix that once we get them).

But if you absolutely insist on trying to manage GC memory manually, then use 
the stuff in core.memory:

http://dlang.org/phobos/core_memory.html

But again, that's really only for when you _really_ need it. If you're doing 
much with it, then it's just about a guarantee that you're not using D as it's 
intended to be used. You're trying to program in C++ with D, which is just 
going to cause you trouble.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list