Date: Tue, 21 Oct 2025 21:20:26 +0000
On Tue, Oct 21, 2025 at 5:09 PM Thiago Macieira wrote:
>
> What if the constructor in step 2 attempts to use the object that was there?
> It's perfectly possible for constructors to access a global list of live
> objects. Likewise for the destruction in step 4 could access the list of live
> objects.
I think if we were to ask Microsoft to look over all the code in
GitHub and see what percentage of classes have a constructor or
destructor that accesses some sort of global directory of objects,
they might come back with a figure around about 1%.
So I don't think 99% of classes should be burdened.
For those 1% of classes, maybe they should be marked with an attribute
which forbids them to be used with 'emplace_or_retain', something
like:
class MyClass [[never_retain]] {
. . .
};
>
> What if the constructor in step 2 attempts to use the object that was there?
> It's perfectly possible for constructors to access a global list of live
> objects. Likewise for the destruction in step 4 could access the list of live
> objects.
I think if we were to ask Microsoft to look over all the code in
GitHub and see what percentage of classes have a constructor or
destructor that accesses some sort of global directory of objects,
they might come back with a figure around about 1%.
So I don't think 99% of classes should be burdened.
For those 1% of classes, maybe they should be marked with an attribute
which forbids them to be used with 'emplace_or_retain', something
like:
class MyClass [[never_retain]] {
. . .
};
Received on 2025-10-21 21:19:57
