This patch represents the ethos of D62233. It is much smaller and will hopefully be easier to review while still achieving the same result :)
Before, we would create the control block with new, and with this patch we're using the allocator. Is this correct? Why?
Also, we're now unconditionally using a try-catch block -- I'd be curious to see what the impact on code generation is.
Note to reviewers: It's okay to move this outside of the try-catch block, since __enable_weak_this is noexcept anyway.
Yes, it's correct. The allocator will call __builtin_operator_new (or operator new), which makes it functionally equivalent. When the control block is deallocated, it calls __a.deallocate. I think it's better that the control block is also allocated with the allocator (even if they're functionally equivalent) both for cognitive load and in case we introduced an optimization (for example) that broke this type of deallocation down the road.
I'll take a look at the codegen.
I'm going to move the try-catch-blocks out of these two members and into the initializers they're used in. This should help with codegen.
Also, I forgot to wrap these in the #ifs.
Looking at it again, I'm not sure this patch is really needed. None of my other subsequent patches depend on it. If you want, I'm happy to abandon it. I do think it's not a bad cleanup, though. Anyway, I'd like to close it one way or another (either by committing it or by abandoning it).