fake RefCounted for CTFE?
Steven Schveighoffer
schveiguy at gmail.com
Mon Jun 15 21:18:23 UTC 2020
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
More information about the Digitalmars-d
mailing list