<div dir="ltr"><div>It would be nice with rules for enforcing smart-pointer usage in C++. I guess that this can be achieved by disallowing assignment of the return-value of "new" to a raw pointer. It would also be possible to disallow "delete" altogether, but might be a bit indirect.<br>

<br>The return-value of "new" should instead be assigned directly to a auto_ptr/scoped_ptr/unique_ptr/shared_ptr or other user-defined RAII type. Hopefully, a rule wouldn't need to depend on a "whitelist" of pre-approved smart-ptr types.<br>
<br>Smart-ptr enforcement is probably not something that everyone would like to activate, but it could still be very valuable for avoiding memory & resource leaks if it was an optional checker.<br>
</div><div><br></div><div>Could this be possible to implement?<br><br></div><div>Thanks in advance,<br></div><div>Fredrik Orderud<br></div></div>