I see your reasoning. I guess the consensus here is that you should make use of smart pointers wherever possible. I shouldn't be accessing the objects too frequently externally, just for setting...
Type: Posts; User: hpesoj
I see your reasoning. I guess the consensus here is that you should make use of smart pointers wherever possible. I shouldn't be accessing the objects too frequently externally, just for setting...
You are correct, the idea of weak_ptrs is so that you can hold a reference to the object without having ownership. To access the object using weak_ptr, you have to lock it (by calling the lock()...
Well, like you said, if the user holds shared_ptr references the Entity will not be deleted, and the user will still be able to use it, therefore some extra checks/coordination between the objects...
No one inparticular. I've seen many people write something along the lines of this. I've always assumed they are just stuck in their old ways, or just have never really looked at the benefits.
...
Hi, I have seen several responses to this question before, ranging from "Never! Smart pointers are evil!" to "Only when you have resources that the main framework does not directly track." to...
But surely if I'm compiling exactly the same code as them, 'size_t' should be defined the same for both of us? I included iostream in the example because it seemed that was where size_t was defined...
I am trying to compile a specific library, that apparently compiles fine for the author, but not for me. The following code demonstrates the problem (at least for me):
#include <iostream>
...