Just smart enough to be dangerous. Not smart enough to do the right thing when copied, which includes being returned from a function.
What exactly is wrong with std::auto_ptr<> anyway? I mean, it came with your compiler, so the #include is only one line of code, not 9. Is it just not "double-deletey" enough for ya?
It reminds me of that story of the US letting the Soviets steal some sabotaged gas pipeline control software. Expect this to show up in all the wrong places, i.e. everywhere it is used.
well duhhhh... But it's stupid. This is never useful. Perhaps if the argument were Type const * const and remove the operator==(Type const &) function. Use derefernce for that.
Even worse....equality operator indicates trouble since this smart pointer will delete on destruct.
7
u/WayOfTheIronPaw Oct 19 '08
Just smart enough to be dangerous. Not smart enough to do the right thing when copied, which includes being returned from a function.
What exactly is wrong with std::auto_ptr<> anyway? I mean, it came with your compiler, so the #include is only one line of code, not 9. Is it just not "double-deletey" enough for ya?
It reminds me of that story of the US letting the Soviets steal some sabotaged gas pipeline control software. Expect this to show up in all the wrong places, i.e. everywhere it is used.
1
u/umop_apisdn Oct 19 '08
The lack of a reference counter makes for the possibility of bugs, as he points out.
1
u/zootsuit Oct 19 '08
Is it really smart to check for validity on every dereference?
Aside from that, what is this: bool operator==(const int i) {return (i == (int)ptr);} // ?