Question is in subject.
I want to write some universal template function for safe deleting objects and wondering is it possible to use something like this:
template< class T > void SafeDelete( T*& pVal )
{
if(objc_is_cpp_object(pVal)){
delete pVal;
pVal = NULL;
}
else
[pVal release]
}
As mentioned in comments, I would suggest not to mix the C++
deleteand Objective-Crelease.Just for technical point of view, you can use the following SFINAE trick runtime:
Possibly,
is_podis available in C++11, boost etc. But it’s easy to implement.