You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Simplified version of std::shared_ptr and resizable std::vector #83
@mosra,
Containers::Pointer is just similar to std::unique_ptr, so is there any plan for a simplified version of std::shared_ptr?
Similarly, how about copyable and resizable std::vector? Currently Containers::Array is non-resizable.
I have implemented those (here and here). You can have a look.
Similar to my previous feature requests, those features were implemented by me in my codebase and were used by me exclusively so far. I just think it is better to share my work by integrating into magnum such that there're more people use it, then it can get feedback from the community and be improved much more.
There's no plan for a simplified shared_ptr -- the suffering of projects relying heavily on shared pointers is not worth the perceived convenience of these -- based on my experience, it makes reasoning about data ownership very hard and in many projects a lot of time was wasted tracking down issues where the application crashed on exit due to data ownership issues, eating more memory than it should be because a shared pointer was kept for longer than it was optimal, and generally was a indication of a potential design issue. So I decided to not introduce shared pointers in this form into Magnum, except when needed to interact with 3rd party libraries such as DART. If you want to store reference-counted data with Magnum's own APIs, use the ResourceManager -- I'd say that's the Magnum version of shared pointers, but still with a clear ownership rules.
I'm planning to add an opt-in growing functionality to Array, yes. I might need it to implement some parts of mosra/magnum#371, so pretty soon (December?). But it'll be quite different from what you might expect :)
Initial version of growable arrays done in 3cf41e3. I'll be publishing a post with benchmarks and comparison against other implementations early next year, until then you have to trust me that the implementation is good enough :)
Activity
mosra commentedon Nov 21, 2019
There's no plan for a simplified
shared_ptr-- the suffering of projects relying heavily on shared pointers is not worth the perceived convenience of these -- based on my experience, it makes reasoning about data ownership very hard and in many projects a lot of time was wasted tracking down issues where the application crashed on exit due to data ownership issues, eating more memory than it should be because a shared pointer was kept for longer than it was optimal, and generally was a indication of a potential design issue. So I decided to not introduce shared pointers in this form into Magnum, except when needed to interact with 3rd party libraries such as DART. If you want to store reference-counted data with Magnum's own APIs, use the ResourceManager -- I'd say that's the Magnum version of shared pointers, but still with a clear ownership rules.I'm planning to add an opt-in growing functionality to Array, yes. I might need it to implement some parts of mosra/magnum#371, so pretty soon (December?). But it'll be quite different from what you might expect :)
mosra commentedon Nov 24, 2019
Keeping open until I have the growable Array done :)
mosra commentedon Dec 18, 2019
Initial version of growable arrays done in 3cf41e3. I'll be publishing a post with benchmarks and comparison against other implementations early next year, until then you have to trust me that the implementation is good enough :)