I want to guarantee that pointer I passed to function cannot be deleted inside this function (I mean compiler would generate an error on processing such function). The following is the original situation.
void foo(Bar *bar) { delete bar; }
Now I unsuccessfully tried some ways.
void foo(Bar *bar) { delete bar; }
void foo(const Bar * const bar) { delete bar; } { delete bar; }
template <typename T> void foo(const T &t) { delete t; } // calling foo(bar);
I want to know is there some way prohibit deleting pointer And if it isn't possible why it was made?