fake RefCounted for CTFE?
Timon Gehr
timon.gehr at gmx.ch
Mon Jun 15 21:39:33 UTC 2020
On 15.06.20 23:18, Steven Schveighoffer wrote:
> I'm doing some stuff with RefCounted for a factory-like expression,
> where I expect the factory harnesses are going to be very short-lived.
> However, these don't work at CTFE (because malloc/etc aren't available).
>
> Would it make sense for RefCounted to turn into GC for CTFE mode? That
> is, if RefCounted is used during CTFE, it just allocates on the GC heap
> and doesn't actually do ref counting. The end result will be a ref
> counted struct that somehow is flagged that it's never going away (and
> it shouldn't, if it's generated at compile time).
>
> Then you could use functions that return RefCounted items as static
> initializers, or use libraries that use RefCounted at compile time
> without issues.
>
> What do you think?
>
> -Steve
I think it should work in CTFE, but it cannot break @nogc.
More information about the Digitalmars-d
mailing list