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

wrap std::weak_ptr in ofPtrWeak #2005

Closed

Conversation

yoiang
Copy link

@yoiang yoiang commented Apr 9, 2013

No description provided.

@kylemcdonald
Copy link
Contributor

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.

@tgfrerer
Copy link
Member

tgfrerer commented Apr 9, 2013

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?

@yoiang
Copy link
Author

yoiang commented Apr 9, 2013

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!

@bakercp
Copy link
Member

bakercp commented Aug 21, 2013

I would suggest that given the roadmap, we should avoid adding a wrapper to this and encourage developers to use std::weak_ptr directly. It is brought in via tr1 along w/ std::shared_ptr in the case of os x. Perhaps that is also true with other platforms?

@arturoc
Copy link
Member

arturoc commented Aug 21, 2013

yes we should deprecate ofPtr and use std::shared_ptr as soon as we have support for c++11 in the core

@yoiang
Copy link
Author

yoiang commented Aug 22, 2013

If C++11 is in the works that sounds great! Thanks guys!

@bilderbuchi bilderbuchi mentioned this pull request Sep 20, 2013
@arturoc
Copy link
Member

arturoc commented Jul 5, 2014

closing this since ofPtr is deprecated now

@arturoc arturoc closed this Jul 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants