Skip to content

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

Closed

Description

@ttnghia

@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.

Activity

  1. added this to the 2019.1c milestone on Nov 21, 2019
  2. mosra commented on Nov 21, 2019

    @mosra
    Owner

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

  3. mosra commented on Nov 24, 2019

    @mosra
    Owner

    Keeping open until I have the growable Array done :)

  4. reopened this on Nov 24, 2019
  5. mosra commented on Dec 18, 2019

    @mosra
    Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions