This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Better debug features


Better debug features

Postby Rhino123 » Jul 2, 2002 @ 3:17pm

User avatar
Rhino123
pm Member
 
Posts: 66
Joined: Jul 2, 2002 @ 2:58pm
Location: Amsterdam


Postby Phantom » Jul 2, 2002 @ 3:28pm

Give me some good data and
I will give you the world
User avatar
Phantom
pm Insider
 
Posts: 913
Joined: Feb 21, 2001 @ 8:14am
Location: Houten, Netherlands


ehm ehm ehm

Postby Rhino123 » Jul 2, 2002 @ 3:38pm

User avatar
Rhino123
pm Member
 
Posts: 66
Joined: Jul 2, 2002 @ 2:58pm
Location: Amsterdam


Postby s9801758 » Jul 2, 2002 @ 5:07pm

User avatar
s9801758
pm Member
 
Posts: 48
Joined: May 10, 2002 @ 10:20am
Location: Vancouver BC, Canada


STL

Postby Rhino123 » Jul 2, 2002 @ 5:39pm

User avatar
Rhino123
pm Member
 
Posts: 66
Joined: Jul 2, 2002 @ 2:58pm
Location: Amsterdam


Postby s9801758 » Jul 2, 2002 @ 5:47pm

"This means hat if he whole class goes out of scope (the program exits) all the pointers are freed."

What you mean is "when the INSTANCE of a class" goes out of scope. Indeed, in the case of the framegame this is the case when the application exits. But for all my code this is exactly what I want, because I really want the GUI resources to be available at all time! I'm not going to reload a gui-button-surface from a file when I'm re-entering the game-menu....

Thus, your argument is not a matter of the scoped_ptr itself, but a matter of the scoped_ptr usage. Thus, an explicit design decision of me.

As for your second point.

"STL is definately NOT meant to be used for storing POINTERS"

This is nonsense. The STL is not meant to do anything in particular. Part of the STL is a collection of containers in which you can put anything you want. You can put instances (Build-in-type, POD's or more complex class structures) in it, but pointers too. It doesn't matter for the STL.

True, the STL is build on value-semantics (for very good reasons) and this seems to imply that the STL is meant to contain objects, and not pointers or references to objects, but this is not true. Any decent reallife situation will come up with a situation where you need pointers to objects in a container.

Start writing your GUI system, and you'll see what I mean.

If, instead, you would have said:

"The STL is not designed to safely contain raw pointers"

you would have been perfectly right! However, this only agrees my point.

Cheers,

Jape

[edited to fix spelling errors]
User avatar
s9801758
pm Member
 
Posts: 48
Joined: May 10, 2002 @ 10:20am
Location: Vancouver BC, Canada


Postby s9801758 » Jul 2, 2002 @ 6:00pm

"Please note that you DO have to make a good copy constructor if your class has pointers in them!"

LOL :), you provide my examples.

What if a class has expensive copy semantics? Consider a class with some complex buffer in it. Obviously the copy-constructor and assigment-operator will be expensive operations because the buffer has to be copied too (or exchanged in rare cases).

Now you want a container of such a class. Performance-wise it would be better to use a container of smart-pointers -that have easy and fast copy constructors and assigment operators- to these objects.

It's precisely these kind of ideas that make the STL seem slow. It's not the STL that is slow, it's the user that makes it slow.

All with a :wink: again ofcourse...

Regards,

Jape
User avatar
s9801758
pm Member
 
Posts: 48
Joined: May 10, 2002 @ 10:20am
Location: Vancouver BC, Canada


Smart pointers, dumb programmers?

Postby Rhino123 » Jul 3, 2002 @ 10:44am

User avatar
Rhino123
pm Member
 
Posts: 66
Joined: Jul 2, 2002 @ 2:58pm
Location: Amsterdam


Return to Phantom's Forum


Sort


Forum Description

Discuss any of Phantom's projects here (Operation Nutcracker, etc.)

Moderators:

sponge, RICoder, Phantom

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum