Quick A: When it comes to destruction, only your deleter knows for sure... but he's captured at construction time, so all starts well and stays well.

I found some code using std::shared_ptr to perform arbitrary cleanup at shutdown. At first I thought this code could not possibly work, but then I tried the following:

[edited]

int main() { vector<shared_ptr<void>> v; { v.push_back( shared_ptr<test>( new test() ) ); } } // [[ how can this destroy type-safely? ]]