Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Yeah, it depends. I try to use smart pointers as sparingly as possible, but there are tons of cases where it's the best thing you can do.
However, raw pointers are still cool for a lot of things.
This may interest you: https://youtu.be/xnqTKD8uD64 -
Why pointers could be smart? Just
*Googlin it
wut?
*Reading pages
FRIGGG
C++ is trying to imitate Java!
Fellow comrades, THE END TIMES ARE UPON US!
Jk, in fact, i've seen to much lack of delete[]; 's -
Thanks for the input!
@RememberMe, definitely going to look into that.
I myself don't really like the java-style giving stuff out of my hands. If i didn't get it wrong, shared pointers just free themselves, so the only thing you saved yourself from is a free-call for the cost of runtime, am i right?
I liked the "do shit yourself or leave it" nature of C. C++ doesn't seem to go that way.^^ -
@hch11 lol, if you want more Java "imitation" there's a pretty good garbage collector implementation for C/C++ : the Boehm GC.
-
@PAKA is there any reason besides prevention of memory leaks by forgetting something for enforcing this?
-
Pretty much always yes unless I'm holding a non owning pointer. In that case I just use a raw pointer or a reference if I want the class lifetime bound to what I'm pointing at
-
@stevemk14ebr and that's what i don't like about smart pointers. They automatically bring inconsistency to your code.
The C subset uses raw pointers and I guess the lib functions, do so, too. (pure guess! Is that so?)
Also it makes stuff unnecessarily complex, now we have one way that always works + 3 other ways + 1 deprecated way to point to an object in memory.
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911Hats off to this lady .... I would have just flipped the machine
C++ Warriors: Do you use smart pointers?
Yes/No/Depends.
question
unique
c++
weak
or raw
shared
smart pointers