-
Notifications
You must be signed in to change notification settings - Fork 39
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
Enable shared_ptr to work without ContainerTraits::construct #86
Conversation
This addresses my issue. I'm having some other strange migration issues, which i will report separately, but this addresses the need for |
You can do: template <class T>
using RefCountedPtr = std::shared_ptr<T>; To minimize the breaking change |
Yes, I did that to test it. It was a little more involved than that, because the raw pointer constructor for Thank you for taking time to address this. |
Also, another question. There is one of my classes that is not part of the legacy framework. I am going to "intrude" on it to make it behave better. Do you recommend |
I think enable_shared_from_this is the standard way to handle intrusive shared ownership in C++ and it's backed by the standard libraries. I will eventually deprecate |
If cross-dll boundary support is a strong goal, there should perhaps be a built-in way to create shared pointers that use the destructor function from the DLL that created them, something like this: template<class T>
static std::shared_ptr<T> makeLuaPtr(T *p) { return std::shared_ptr<T>(p, [](T* p){ delete p; }); } |
If you are going to deprecate class foobase : public std::enable_shared_from_this<foobase> {};
class foo : public foobase {}; going to work equivalently to class foobase : public luabridge::RefCountedObject {};
class foo : public foobase {}; That is, does type-based instantiantion |
Yes it does, plus you gain weak references that are not possible with RefCountedObject. And you have documentation and standard support https://en.cppreference.com/w/cpp/memory/enable_shared_from_this |
Isn't this easy to roll your own ? I'm a bit against providing these constructs, as they make no interaction at all with the library itself, they are more belonging to C++ than luabridge. Where is Those constructs are really flexible if solved in the implementation layer, and the library should just make sure they work with lower level primitives. |
Given that I can put In the meantime, it's not so much a question of how easy something is but whether the programmer knows to do it. If a stated feature of the library is cross-DLL support, it would be nice if programmers didn't have to know these things in order to have it. But I don't feel strongly about it. |
I've recently started trying out sonar, and On the dll support, it's a bit more complicated than just a |
I compile Lua directly into my plugin, fwiw. I'm not super concerned about cross-dll support in my environment, tbh. My biggest concern is that I am a single point of failure for the project. I am the only person on Earth who has access to and permission to use the proprietary code needed for this project. (Well, there are 2 others. One is the original creator of the legacy framework, but he has withdrawn from the internet, and the other is not interested.) Cross-dll support might allow for external user interfaces. Right now my bandwidth is limited, and I am not terribly interested in adding new ui support. EDIT: I should clarify I am the only 3rd party person with access and permission. Obviously the employees of the company do. |
No description provided.