Menu

Beyond New and Delete: Engineering Approach with gsl::owner, std::span and clang-tidy
📰

Beyond New and Delete: Engineering Approach with gsl::owner, std::span and clang-tidy

DEV Community·Rui-Tech·6 months ago
#9IaaJ0z8
#warning#include#cpp#owner#clang
Reading 0:00
15s threshold

In my previous articles, Beyond new and delete: A Practical Guide to Refactoring Raw Pointers to Smart Pointers and Beyond new and delete: to Weak Pointer , I explained how to refactor raw pointers into unique_ptr , shared_ptr , weak_ptr , and references.

But swapping pointer types is only half the battle. A successful refactoring also requires a systematic engineering process — one that combines ownership analysis, modern C++ types, static analysis, and incremental testing to ensure safety and correctness.

In this article, we focus on that engineering workflow:

Audit & Annotate → Static Analysis → Replace → Refactor Incrementally

Step Action

1 Audit & Annotate – Mark owning vs observer pointers, use GSL

2 Static Analysis – Enable -Wall , run clang-tidy, add sanitizers

3 Replace with Modern Types – unique_ptr , shared_ptr , span , references

4 Refactor Incrementally – Start with leaf modules, remove manual delete

Step 1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.