Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime variable shared pointer clearing #131

Open
BrianSipos opened this issue Jan 2, 2025 · 1 comment
Open

Runtime variable shared pointer clearing #131

BrianSipos opened this issue Jan 2, 2025 · 1 comment

Comments

@BrianSipos
Copy link

One of the helpful capabilities of the STL shared_ptr class is the ability to define, at initialization, the deleter function which will be used to clean up a particular object instance. And each shared_ptr keeps track of its deleter function for that specific data instance.

It seems like the current M-SHARED-PTR only supports compile-time definition of a CLEAR function, which fits the type-safe nature of M*LIB but limits its ability to handle situations where different contained-data uses are handled by the same pointer type.

Is adding this kind of parity with the STL class desirable in M*LIB? Maybe by a different container than M-SHARED-PTR?

@P-p-H-d
Copy link
Owner

P-p-H-d commented Jan 2, 2025

The current  M_SHARED_PTR interface does indeed only support compile-time definition of the destructor.

I'm not sure why C++ has added this run-time property of their shared pointer, but I suppose it is due to class inheritance (The shared_ptr is the only pointer remaining when the shared pointer is destroyed, but it shall call the overloaded destructor of one of its inherited class).

I don't see any value in supporting it in M*LIB. Moreover, the user code can quite easily emulate it itself by adding its own function pointer (or using a VARIANT for the encapsulated object).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants