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

[Feature Request] Simplified version of std::shared_ptr and resizable std::vector #83

ttnghia opened this issue Nov 20, 2019 · 3 comments


Copy link

ttnghia commented Nov 20, 2019

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.

@mosra mosra added this to the 2019.1c milestone Nov 21, 2019
@mosra mosra added this to TODO in Containers via automation Nov 21, 2019
Copy link

mosra commented 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 :)

@ttnghia ttnghia closed this as completed Nov 24, 2019
Containers automation moved this from TODO to Done Nov 24, 2019
Copy link

mosra commented Nov 24, 2019

Keeping open until I have the growable Array done :)

@mosra mosra reopened this Nov 24, 2019
Containers automation moved this from Done to In Progress Nov 24, 2019
Copy link

mosra commented 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 :)

@mosra mosra closed this as completed Dec 18, 2019
Containers automation moved this from In Progress to Done Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

No branches or pull requests

2 participants