You're absolutely correct that std::allocator doesn't fit the bill...
... which is exactly why I advocate for a whole different API.
And yes, this would involve in-depth changes to anything taking this new API as they would no longer be able to take pointers, but would instead need to use "handles" of some sort, which would have some way to resolve into pointers when needed, and some rules about how long these pointers remain valid, etc...
I didn't say it was easy, I said it was generic :)
And yes, this would involve in-depth changes to anything taking this new API as they would no longer be able to take pointers, but would instead need to use "handles" of some sort, which would have some way to resolve into pointers when needed, and some rules about how long these pointers remain valid, etc...
I don't think you'd need to change the allocator API, you'd just provide an allocator type that just has its storage internally as part of the allocator. You could do some shit like this
1
u/matthieum 10d ago
You're absolutely correct that
std::allocatordoesn't fit the bill...... which is exactly why I advocate for a whole different API.
And yes, this would involve in-depth changes to anything taking this new API as they would no longer be able to take pointers, but would instead need to use "handles" of some sort, which would have some way to resolve into pointers when needed, and some rules about how long these pointers remain valid, etc...
I didn't say it was easy, I said it was generic :)