-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
wrap std::weak_ptr in ofPtrWeak #2005
Conversation
thanks for the contribution :) can you provide any examples of places where ofPtrWeak would be helpful? we generally don't add features unless there is a corresponding example showing the strength of the feature, or a problem with the current core that is elegantly resolved by adding that feature. |
i think that could be super useful (for whenever you reference a smart pointed object by an object that doesn't own it). But i'd fear adding an openFrameworks specific wrapper would add a level of complexity that we might regret when transitioning the core to c++11 sometime in the future... Don't get me wrong -- weak pointers are fantastic and super useful! I believe ofPtr was introduced to have a standardised way to use smart pointers whilst common cpp compilers are catching up with c++11. Now that c++11 is (almost) available everywhere, it will in the near or distant future make sense to use these c++11 standard smart pointers. it's less the general ofPtrWeak use cases that I'm concerned with, it's more that when such pointers need to be dynamic_cast'ed &c, it can get really messy across compilers and OS'es and c++ versions when writing a future-proof wrapper... i'm saying this, because i still totally curse myself for the pain i might have introduced when suggesting dynamic_cast to ofPtr<> and i've been doing hours of community service ever since, trying to make up for it =) maybe this could be a lead-in to a more general debate on the pathway to embracing c++11 in a future oF version? |
tgfrerer beat me to it, we use them extensively here for any non-ownership references, ie: parent-child relationships, async callbacks, etc (see https://github.com/lumoslabs/ofxGeneric). Personally as an outsider (so take it with a grain of salt ;) in the interrum before openFrameworks switches over to C++11 and directly uses shared_ptrs and weak_ptrs I think it'd be a valuable resource to have. Granted should this switch happen we've got a lot of work to do here! |
I would suggest that given the roadmap, we should avoid adding a wrapper to this and encourage developers to use |
yes we should deprecate ofPtr and use std::shared_ptr as soon as we have support for c++11 in the core |
If C++11 is in the works that sounds great! Thanks guys! |
closing this since ofPtr is deprecated now |
No description provided.