Andreas Fertig
Read post

More compile-time checks with std::nullptr_t

std::nullptr_t is a C++11 type that holds exactly the nullptr value. By adding a deleted constructor accepting std::nullptr_t to classes like std::string, you can catch undefined behavior (constructing a string from nullptr) at compile-time rather than relying solely on runtime assertions. C++23 already applies this pattern to std::string and std::string_view. C++26 further improves this by allowing deleted functions to carry a message explaining why they were deleted.

    #c++
Aug 04•2m read time•From andreasfertig.com
Post cover image
Table of contents
The current situationImproving the situation
490 Impressions
Andreas Fertig's image
Andreas Fertig

Andreas Fertig's blog offers insights into C++ development, particularly focusing on the C++ Standar...

35 Followers

•

127 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard