On Tuesday, 26 January 2021 at 15:30:09 UTC, Steven Schveighoffer wrote:
The only way to ensure the GC isn't used is with betterC. Even with @nogc tag on main, the GC could be used in static ctors, and casting function pointers/etc.

Yes, @nogc is not strong enough... It is for a container library, so maybe I could put test for the properties of the elements instead?

I guess I would want test if the Element type contains a pointer that should be traced by the GC.

But how would I go about it?

And this will only apply to templates, not to compiled code, since compiled code already is done (and one can obviously use betterC compiled code in normal D code).

Yes, but templates is ok, but I think Better_C is too restrictive in the long term. So I hope there is some way for my library to figure out if it has to care about GC for the template parameters the user provides.

I guess I also will find the equivalent of C++ std::trivially_copyable, std::trivially_destructible in Phobos, to figure out if memcpy is safe.


Reply via email to