Skip to main content
GameDev.net gamedev.net
🔒 Locked

Boost Question with Example

Started by Raeldor Oct 12, 2006 at 1:09 PM 2 replies 800+ views
Original Post
Raeldor
Raeldor
Hi All, I'm try to get to grips with Boost and have been doing some test code. The following throws an bad weak pointer exception when trying to create an object of class A, but it looks good to me. Obviously I am misunderstanding something critical here, can anyone see what it is? Thanks Rael
Raeldor
Raeldor
Quote:
Original post by deffer
You cannot expect shared_from_this() to return valid shared_ptr, when the object is not being shared by any other shared_ptr yet!.
The shared_ptr
pa in _tmain() is not yet constructed at the time of calling new A().


Seriously, though, don't you people use debuggers at all???
Step-by-step - that's the way the world is turning for millenias.

Ack. So I would have to do something like...

This is getting more and more convoluted to use. I think I was better off with my own intrusive smart pointer counter. At least it seemed there were not so many work arounds.
Telastyn
Telastyn
IIRC, you're working on a UI sort of n-tree?

Personally, I make the 'tie' a seperate act compared to creation. It is useful to allow objects to exist without parents (to be prototypes, to be completely constructed before rendering, to be created and then conditionally inserted, to be more easily moved/shifted).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.