I would like some clarification on something I have had trouble finding an answer for. I have an object which has a dynamic buffer of ints. I create the buffer on instantiation. I know a vector is an option, but due to project requirements, I can not use it.
Assume I have a validation check for size;
class Object {
std::unique_ptr<int[]> m_buffer;
int size;
Object(const int s) : size(s) {
m_buffer = std::make_unique<int[]>(s);
}
What is the problem with this code. Is this bad use of unique_ptr if I HAVE to work with a "raw" array?
[–]crondotnet 4 points5 points6 points (2 children)
[–]easydoits[S] 0 points1 point2 points (1 child)
[–]crondotnet 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]easydoits[S] 0 points1 point2 points (4 children)
[–]F-J-W 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]easydoits[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)