1
SFML projects / Re: Ignition Engine
« on: January 13, 2014, 10:08:26 am »Nowadays the C++ standard removes need for unnecessary checks.Not nowadays, but since more than one and a half decade. C++ was standardized in 1998.I only keep these template functions around for DX programming because from what I can tell, it is not safe to use C++11 smart pointers due to reference counting issuesWritten in such a general way, that's wrong. I don't see a problem with reference counting, and not all smart pointers use it anyway. std::unique_ptr is a simple pointer wrapper that is just as fast as performing manual new/delete, and it's faster and much safer than your SafeDelete() function.
"Safe delete" is an abomination which inspired a lot of C++ developers to write questionable code, and unfortunately it has survived a long time, even though the original problems have disappeared long ago. One could even call it an anti-idiom; there's absolutely no sane reason to use it. This has nothing to do with C++11, smart pointers and RAII have been around for much longer (boost::scoped_ptr, std::auto_ptr). Even if those are not ideal nowadays and std::unique_ptr should be preferred, they're still much better than any way of managing memory or other resources manually.
If you're interested, read the RAII thread, we all tried to explain why RAII is such a powerful idiom that should be applied wherever possible.
Again I would highly advise against using std::unique_ptr with DirectX COM objects.
http://msdn.microsoft.com/en-us/library/hh279683.aspx
illustrates the idea.
But to each his own I guess. I've already read up on RAII, and yes it can be a great idiom, but it really does depend on your target platform.
For example, I know some developers tend to stay away from RAII designs for embedded systems due to exception overhead.
Also, please stop re-iterating what I clearly already know, and have stated my reasons for keeping it around. Its not going to change the templates, really. Thanks!