
Marco Costalba wrote:
Other options that I have evaluated are:
- Assert instead of NULL dereferencing: does not gain much at run-time, always a crash occurs
- Silently fail, as example returning a default value: much more dangerous then segfaulting IMHO
Any suggestion? (compile time assert does not seem an option because it's related to the runtime value stored in an auto_ptr pointer).
I guess you considered throwing an exception eg argument_error. If you don't mind me asking (its the way to learn) if you did reject throwing an exception, why? On the surface it seems that throwing at least allows the possibility of graceful termination for programs (I do realise uncaught exceptions still abort the program without cleanup), so I suspect there must be something deeper that I have missed. Kevin