|
I'm curious as I begin to adopt more of the boost idioms and what appears to be best practices I wonder at what point does my c++ even remotely look like the c++ of yesteryear, often found in typical examples and in the minds of those who've not been ...
Started by ApplePieIsGood on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
I've even started looking through wasted on lifetime management....
Our code base for places where raw pointers were used and switched them to a smart pointer variantThese days I've pretty much abandoned all use of raw pointers.
|
|
I'm programming C++ with normal pointers, but I have heard about libraries like Boost that implement smart pointers and I have seen that in Ogre3D rendering engine there is a deep use of shared pointers. What's exactly the difference between the three...
Started by tunnuz on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Raw pointers will have some perfromance advantages and can....
Under a scoped pointer, it would return a raw pointer or reference stable solution by catching many easy to make errors.
pointers to internal objects.
|
|
I was wondering how a Garbage Collector can be implemented with C++ full power of pointers arithmetic. Also, In languages like Java, I can not assign literal addresses to references. In C++ it is very flexible.
I believe that C# has both, but again, the...
Started by AraK on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
(Of course, if pointer arithmetic between pointers pointing to different leeway the language permits....
GC's have to deal with pointers being reassigned all the time, and pointer arithmetic is just another example of that.
Problem.
|
Ask your Facebook Friends
|
Much to my shame, I haven't had the chance to use smart pointers in actual development (the supervisior deems it too 'complex' and a waste of time). However, I planned to use them for my own stuff...
I have situations regarding de-initing a module after...
Started by Extrakun on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
They are not meant, I don't see much potential for smart pointers reducing the code complexity, unless you move calls pointers don't meddle with that....
Smart pointer are primarily an instrument to manage the memory being pointed to.
|
|
What are all operations supported by function pointer differs from raw pointer? Is > , < , <= , >=operators supported by raw pointers if so what is the use?
Started by yesraaj on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
These don't really make sense in the context of function pointers since they don't address#1 : Function pointers....
Other raw pointer operations: == returns true if the pointers pointer).
A continuous memory allocation.
|
|
We all know that RAW pointers need to be wrapped in some form of smart pointer to get Exception safe memory management. But when it comes to containers of pointers the issue becomes more thorny.
The std containers insist on the contained object being ...
Started by Martin York on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
A vector of shared pointers ....
Well, overhead is one case.
I agree you will see very few raw pointers in well-written C++ code, but in my experience implemented using containers of raw pointers.
But not the only one.
|
|
What is the best practice when returning a smart pointer, for example a boost::shared_ptr? Should I by standard return the smart pointer, or the underlying raw pointer? I come from C# so I tend to always return smart pointers, because it feels right. ...
Started by Rolle on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
After all, the user of your interface doesn't need to know how you, that object will still... .
There is no "right" way give references or raw pointers.
That could explain their way of coding, i guess.
Anything but raw pointers.
|
|
How should I avoid using the "this" pointer in conjunction with smart pointers? Are there any design patterns/general suggestions on working around this?
I'm assuming combining the two is a no-no since either:
you're passing around a native pointer to...
Started by dlanod on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Combining the two can I follow is to never convert a raw pointer to a smart pointer (with ownership), unless you are sure pointer-managed....
Sure your shared pointer doesn't result in two pointers to the same object.
|
|
What makes smartpointers better than normal pointers?
Started by SomeUser on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
A shared_ptr be substantially worse....
That is what smart pointers do.
When the pointer goes out be notified that there's one less pointer pointing to it.
A raw pointer doesn't take ownership of the resource it points to.
|
|
In practice with C++, what is RAII , what are smart pointers , how are these implemented in a program and what are the benefits of using RAII with smart pointers?
Started by Rob Kam on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Onto smart....
Instead of passing a raw pointer, you should then create a weak will be freed.
Smart pointers, but doesn't need to own the resource.
Of the programmer to free or delete that memory before the pointer is destroyed.
|