If I have code that would normally function like this:
char* log = new char[logLength];
glGetProgramInfoLog(..., ..., log)
//Print Log
delete [] log;
How could I achieve the same result with a C++11 Smart Pointer? Who knows what could happen before I have a chance to delete that memory.
So I guess I need to downcast to a C style pointer?
If your code really looks like that in your snippet,
shared_ptris a bit of an overkill for the situation, because it looks like you do not need shared ownership of the allocated memory.unique_ptrhas a partial specialization for arrays that is a perfect fit for such use cases. It’ll calldelete[]on the managed pointer when it goes out of scope.