On Wednesday, July 18, 2012 20:37:50 Namespace wrote:
> Only for correctness:
> If i allocate memory on the GC Heap in e.g. a struct and don't
> free the memory in the DTor, then the GC free the memory
> automatically?
You don't normally _ever_ free memory from the GC heap. That's the GC's job.
T
Only for correctness:
If i allocate memory on the GC Heap in e.g. a struct and don't
free the memory in the DTor, then the GC free the memory
automatically?
On Monday, July 16, 2012 10:31:11 Namespace wrote:
> I'm just experiement with D, that's all. ;)
> Most of my questions here are just out of curiosity.
>
> I have now this construct:
>
> [code]
> class smart_ptr {
> private:
> A* _ptr;
>
> public:
> this(A* ptr) {
> voi
I'm just experiement with D, that's all. ;)
Most of my questions here are just out of curiosity.
I have now this construct:
[code]
class smart_ptr {
private:
A* _ptr;
public:
this(A* ptr) {
void* buffer = GC.malloc(A.sizeof);
memcpy(buffer, ptr, A
On Monday, July 16, 2012 09:33:42 Namespace wrote:
> Yes. I want a Pointer of Foo's reference, you're right. I think i
> have to move the reference to the heap?
If you don't want it to point to a local variable and cause problems when it
goes out of scope, then yeah, though I don't know if it's p
You cannot have pointers to classes. The language does not
support it. You can
have pointers to class references, and you can have pointers to
structs or the
built-in types, but if Foo is a class, then what you can't have
a pointer to
it. The closest that you can get is that I believe that you c
On Monday, July 16, 2012 00:47:27 Namespace wrote:
> Is something like this possible?
>
> Foo* create_ptr(Foo f) {
> assert(f !is null);
> // ...
> }
>
> Foo* fp = create_ptr(new Foo());
>
> with "ref Foo f" of course, there is no limitation.
You cannot have pointers to classes. The l