how to delete unique_ptr

Dec 13, 2013 at 7:41am
I was wondering how I would go about deleting just a single member in a unique_ptr array

here is what I have:

1
2
std::unique_ptr<Foo> Blocks[100][100][100];
Blocks[a][b][c] = std::unique_ptr<Foo>(new Foo);


and then I would like to do something equivalent to:

 
delete Blocks[a][b][c];


Thank You.
Dec 13, 2013 at 7:44am
delete Blocks[a][b][c].release();

http://en.cppreference.com/w/cpp/memory/unique_ptr/release

or, preferred:

Blocks[a][b][c].reset(nullptr);

http://en.cppreference.com/w/cpp/memory/unique_ptr/reset
Last edited on Dec 13, 2013 at 7:47am
Topic archived. No new replies allowed.