Re: GC and void[N] in struct

2018-08-07 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 6 August 2018 at 19:43:17 UTC, Steven Schveighoffer wrote: On 8/6/18 2:59 PM, vit wrote: struct ExprImpl(Ts...){     enum N = max(staticMap!(sizeOf, Ts)); This is clever! No need to be clever though - we've got std.traits.Largest for exactly this kind of purpose. -- Simen

Re: GC and void[N] in struct

2018-08-06 Thread vit via Digitalmars-d-learn
On Monday, 6 August 2018 at 21:23:36 UTC, Paul Backus wrote: On Monday, 6 August 2018 at 20:22:36 UTC, vit wrote: On Monday, 6 August 2018 at 19:56:03 UTC, Steven Schveighoffer wrote: BTW, is there a reason you aren't just using Algebraic? https://dlang.org/phobos/std_variant.html#.Algebraic

Re: GC and void[N] in struct

2018-08-06 Thread Paul Backus via Digitalmars-d-learn
On Monday, 6 August 2018 at 20:22:36 UTC, vit wrote: On Monday, 6 August 2018 at 19:56:03 UTC, Steven Schveighoffer wrote: BTW, is there a reason you aren't just using Algebraic? https://dlang.org/phobos/std_variant.html#.Algebraic -Steve primarily visit for Algebraic isn't pure, @nogc,

Re: GC and void[N] in struct

2018-08-06 Thread vit via Digitalmars-d-learn
On Monday, 6 August 2018 at 19:56:03 UTC, Steven Schveighoffer wrote: BTW, is there a reason you aren't just using Algebraic? https://dlang.org/phobos/std_variant.html#.Algebraic -Steve primarily visit for Algebraic isn't pure, @nogc, @safe, nothrow.

Re: GC and void[N] in struct

2018-08-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/6/18 3:43 PM, Steven Schveighoffer wrote: On 8/6/18 2:59 PM, vit wrote: On Monday, 6 August 2018 at 18:28:11 UTC, Steven Schveighoffer wrote: On 8/6/18 2:22 PM, vit wrote: Hello, I have this struct: struct S{ uint kind; void[N] data_; define "N" } Instances of struct S

Re: GC and void[N] in struct

2018-08-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/6/18 2:59 PM, vit wrote: On Monday, 6 August 2018 at 18:28:11 UTC, Steven Schveighoffer wrote: On 8/6/18 2:22 PM, vit wrote: Hello, I have this struct: struct S{ uint kind; void[N] data_; define "N" } Instances of struct S are allocated by standard GC new and S.data_ can

Re: GC and void[N] in struct

2018-08-06 Thread vit via Digitalmars-d-learn
On Monday, 6 August 2018 at 19:17:58 UTC, nkm1 wrote: On Monday, 6 August 2018 at 18:22:24 UTC, vit wrote: Hello, I have this struct: struct S{ uint kind; void[N] data_; } Instances of struct S are allocated by standard GC new and S.data_ can contain pointers/ranges to GC allocated

Re: GC and void[N] in struct

2018-08-06 Thread nkm1 via Digitalmars-d-learn
On Monday, 6 August 2018 at 18:22:24 UTC, vit wrote: Hello, I have this struct: struct S{ uint kind; void[N] data_; } Instances of struct S are allocated by standard GC new and S.data_ can contain pointers/ranges to GC allocated data. If is GC disabled then program run fine. But

Re: GC and void[N] in struct

2018-08-06 Thread vit via Digitalmars-d-learn
On Monday, 6 August 2018 at 18:28:11 UTC, Steven Schveighoffer wrote: On 8/6/18 2:22 PM, vit wrote: Hello, I have this struct: struct S{     uint kind;     void[N] data_; define "N" } Instances of struct S are allocated by standard GC new and S.data_ can contain pointers/ranges to GC

Re: GC and void[N] in struct

2018-08-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/6/18 2:22 PM, vit wrote: Hello, I have this struct: struct S{     uint kind;     void[N] data_; define "N" } Instances of struct S are allocated by standard GC new and S.data_ can contain pointers/ranges to GC allocated data. If is GC disabled then  program run fine. But when is

GC and void[N] in struct

2018-08-06 Thread vit via Digitalmars-d-learn
Hello, I have this struct: struct S{ uint kind; void[N] data_; } Instances of struct S are allocated by standard GC new and S.data_ can contain pointers/ranges to GC allocated data. If is GC disabled then program run fine. But when is GC enabled then it fail randomly. If the

Re: GC and void*

2012-01-28 Thread Nicolas Silva
Yes, right, thank you, why reinventing the wheel when the std does the things you want :) On Fri, Jan 27, 2012 at 1:05 PM, Daniel Murphy yebbl...@nospamgmail.com wrote: Have you looked at std.variant?  It sounds like what you're looking for.

Re: GC and void*

2012-01-27 Thread Daniel Murphy
Have you looked at std.variant? It sounds like what you're looking for.

Re: GC and void*

2012-01-26 Thread Steven Schveighoffer
On Wed, 25 Jan 2012 19:11:36 -0500, Nicolas Silva nical.si...@gmail.com wrote: Hi, I need to be sure: would the GC collect an object that is still reachable through a void* pointer ? No. The current GC does not know anything about type information. It blindly assumes if a pointer

Re: GC and void*

2012-01-26 Thread Nicolas Silva
Ok thanks! You said the current GC, do you mean that this behavior might change in the future? Well, first of all, what is T? If T is a class, you would not cast void * to T*, you almost never use T* since T is already a reference. You could cast void * to T. I am making a sort of