New answers tagged

1

We need to be more defensive in these areas: malloc() and family can return a null pointer. scanf() and family can return fewer than requested conversions. Additionally, there's no need to cast the result of malloc() - if you've correctly included <stdlib.h>, then it returns a void*, which is assignable to any pointer type. Writing the unnecessary ...


2

ResourceOwner: We need to #include <utility> for std::move. Reset might be more flexible taking its argument by value void Reset(T new_data = T()), so we can copy into it instead of moving. It might be useful to have a value constructor: ResourceOwner(T data);. SharedResourceOwner: Again, #include <utility>. Use std::size_t rather than size_t ...


Top 50 recent answers are included