Hi Marcus,
On Fri, 2005-05-06 at 15:32 +0200, Marcus Lindblom wrote:
> Hi,
>
> I've been working awhile with smart pointers both from OpenSG and Boost,
> and found that the latter have a neat feature which is quite useful,
> namely that they can be implicitly converted to true/false. They also
> have solved this in a robust way. (There are some non-trivialities
> implementing this, which is why I assume this isn't available in OpenSG.
> I believe Boost returns a ptr-to-member or somesuch to get around this).
Yup. I've had that request (with the same pointer towards boost) from
Chad, but I haven't had time to look into it. If you're willing to take
a shot I'd be happy to commit it.
>
> This allows for the quite common construct:
>
> if(SmartPtr<T> p = f()){
> // do stuff
> }
>
> I like this as it is one less line than the usual:
>
> SmartPtr<T> p = f();
> if (p != nullfc) {
> // do stuff
> }
> // I don't want p in this scope
>
> And as there are a lot of common usage where a field pointer might be
> null (fields not set & dynamic_cast) a nicer way to code this would be
> greatly appreciated. (I readily admint toa weakness for 'cute' code though.)
I'm all for cute if it makes life easier for the users (if you want
cuddly animals in the code I might have a problem ;).
> Unless it's been fixed or is planned (or if you've decided for other
> resons to not allow this), I could look into it and post some code. I
> believe it to be quite simple (copy-paste-edit from boost's smart_ptr :).
Sounds like a promising approach. The whole 'return a pointer to virtual
member function that has no other purpose than to be pointed at' scared
me a little, so I didn't want to just add it without really knowing what
I was doing.
Dirk
--
-- Dirk Reiners OpenSG Forum [EMAIL PROTECTED]
-- The OpenSG Open Source Scenegraph: http://www.opensg.org
-- Join the list at http://lists.sf.net/lists/listinfo/opensg-users
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users