ae.utils.appender: check for Allocator.deallocate#55
ae.utils.appender: check for Allocator.deallocate#55pbackus wants to merge 1 commit intoCyberShadow:masterfrom
Conversation
|
Maybe I don't understand something, but would it not be useful for data structure implementations to enforce the availability of allocator primitives? E.g. some data structures may be grow-only, and therefore truly not need the deallocate method, and some may allocate/deallocate memory and therefore actually need for the allocator to support deallocation? As it is, this change will make passing an allocator that truly can't deallocate silently leak memory. I will follow up in the Phobos PR as well. |
|
If a data structure absolutely requires deterministic deallocation, then yes, of course it can require that its allocator implement In general, though, if a user goes out of their way to create an allocator that leaks memory, and instantiates a container with that allocator, it probably should not be the container's job to second-guess the user's intentions. Sometimes programmers leak memory on purpose (see: DMD). |
I think a more correct and elegant approach to address that would be a shim layer as described here: dlang/phobos#8554 (comment) |
|
BTW on the topic of shim layers, it should be easier to write them: |
Needed to unblock dlang/phobos#8554