Trying to understand ofPtr

I am trying to understand how to use ofPtr.

how can I erase or delete one object inside ofPtr vector?

vector<ofPtr<ball> > myBalls;
myBalls.erase(myBalls[i]); -----> not working

like anything on a vector to delete a position:

myBalls.erase(myBalls.begin()+i);

2 Likes

i was facing the same question, thanks @arturo!

@arturo, is ofPtr going to be deprecated? I think i read it somewhere. What was the idea of having it originally? as it seems to be just a regular smart pointer.
cheers

While learning how to use smart pointers, I am also wondering what ofPtr exactly stands for.
How is it different from shared_ptr or unique_ptr? I don’t see it so often in examples (except in ofxBox2d until now)
Should I forget it if it is going to be deprecated?
Thanks!

According to latest source it is deprecated, so I’d recommend using shared_ptr (or any other smart pointer) instead. I believe ofPtr and shared_ptr are completely interchangeable.

thank you @chuckleplant.