Migrate nullable C++ pointer returns to std::optional<T> in C++17
Replace nullable pointer returns with C++17 std::optional so callers must handle absence and avoid null-dereference bugs.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Replace nullable pointer returns with C++17 std::optional so callers must handle absence and avoid null-dereference bugs.
C++17 structured bindings look simple but hide a reference model that trips up experienced developers. The cv-qualifiers apply to a hidden tuple object, not the individual bindings — and that changes everything about mutation and lifetime.
Learn how std::optional in C++17 gives inline, type‑safe nullable returns, see a worked example, and understand the trade‑offs before adopting it in your codebase.
A decision guide for choosing read-only text parameter types in C++17: compare string_view, const string&, and const char* with a compact trade-off table, concrete example, and validation steps to verify zero allocations and detect dangling views.
Stop treating filesystem paths as plain strings. C++17's std::filesystem offers portable path objects and directory iteration without platform-specific code.
Passing const std::string& to read-only functions forces heap allocations from const char* callers. std::string_view removes that cost, but its non-owning lifetime semantics demand strict discipline.
Stop fighting with slashes and backslashes. Learn how C++17 std::filesystem provides a type-safe, portable way to handle paths and recursive directory traversal.
Decide whether to use std::optional or a sentinel value for representing missing data in C++, weighing safety, storage, and domain constraints.
Learn how C++17's constexpr if lets you write cleaner, type‑dependent template code without SFINAE boilerplate, with a concrete example and practical verification steps.