Tag: C++17
24 posts
-
C++17 std::filesystem in Practice: Directory Iteration, Copy and Remove, Symlinks and TOCTOU Races
std::filesystem in practice: directory iteration that survives permission errors, copy and remove options, space queries, symlinks, TOCTOU races, and choosing between exceptions and error_code.
-
C++ [[nodiscard]] Guide: Ignore Return Values Safely
Turn ignored return values into compiler warnings with [[nodiscard]]: error codes, RAII guards, factories, C++20 reason strings, and missing-warning cases.
-
C++ scoped_lock — Scoped locking, std::lock, and deadlock
Lock several mutexes at once with C++17 std::scoped_lock to avoid deadlock, and when lock_guard or unique_lock fits better, with a bank-transfer example.
-
C++ RVO and NRVO: Copy Elision and Why return std::move(local) Backfires
RVO vs NRVO, C++17 guaranteed elision for prvalues, why std::move on return blocks NRVO, what benchmarks really show, and a practical checklist.
-
C++ Range-Based for: auto, References, and Temporaries
Range-based for in C++: auto vs auto& vs const auto&, proxy iterators, temporaries, C++17 structured bindings, custom begin/end, and production patterns.
-
C++ std::filesystem File Status: file_status, symlink_status, perms, and Timestamps
C++17 std::filesystem file_status·perms, status and symlink_status, file_type·permission checks, backup·log cleanup practice, Windows and POSIX.
-
C++17 constexpr Lambdas: Implicit constexpr, Captures, and Limits
How C++17 constexpr lambdas work: when a lambda is implicitly constexpr, capture rules for constant evaluation, real GCC errors, and C++20 changes.
-
Modern C++ Syntax Cheatsheet: C++11 to C++20 Features and Their Pitfalls
Scannable modern C++ reference: each C++11/14/17/20 feature with the standard that added it, a snippet verified on g++ 10.3, and the pitfall that bites.
-
C++17 Structured Bindings: How auto [a, b] Works, What It Copies, and Where It Dangles
How C++17 structured bindings decompose pairs, tuples, arrays and structs, what auto vs auto& really copies, where they dangle, and how to make a type bindable.
-
C++17 std::variant: Access, std::visit, valueless_by_exception and Conversion Traps
Using std::variant safely: get vs get_if, std::visit with overloaded{}, why a double can silently hit your int handler, valueless variants and size cost.
-
std::apply and make_from_tuple in C++17: Calling Functions with Tuple Arguments
How C++17 std::apply unpacks a tuple into a function call, make_from_tuple for constructors, deferred and async calls, memoization, and when a parameter pack is simpler than tuple plus apply.
-
std::filesystem Across Platforms: Paths, Directory Iteration, File Operations and Permissions
Write std::filesystem code that works on Windows and Linux: path joining and normalization, recursive iteration, copy/move/delete, permissions and errors.
-
What Is C++? History, Standards , Use Cases, and How to
C++ overview for beginners: evolution from C, C++11/17/20/23, game/systems/finance use cases, pros and cons, myths, learning roadmap, and production.
-
C++17 Parallel Algorithms: Execution Policies, Toolchain Support, and Why Exceptions Call terminate
Using std::execution::par and par_unseq with sort, transform and reduce: what each policy permits, TBB and compiler support, data races, std::terminate on exceptions, and when it pays off.
-
C++ std::filesystem::path | Cross-platform paths in C++17
A deep look at std::filesystem::path internals: encoding, normalization, and equality pitfalls on Windows and POSIX.
-
std::optional in Practice: value_or, C++23 and_then/transform, and When Not to Use It
std::optional vs nullptr and exceptions: value_or, and_then, transform, or_else, performance, and production error-handling patterns (C++17–C++23).
-
C++ `if constexpr` | Compile-Time Branching in Templates
Use `if constexpr` to discard untaken branches during instantiation—unlike runtime `if`, avoiding ill-formed code in unused branches for templates.
-
Walking Directories with std::filesystem: directory_iterator, Recursion, Symlinks and error_code
directory_iterator vs recursive_directory_iterator, directory_options, symlinks, error_code overloads, filtering, disk usage, and performance tips.
-
C++ std::variant vs union: Type Safety, Overhead and When to Use Each
std::variant vs union: how variant tracks the active type and dispatches with std::visit, what a raw union leaves to you, and migrating legacy unions.
-
std::any vs void* in C++: Checked Casts, Heap Costs and C Callback Context
std::any vs void* in C++17: bad_any_cast vs nullptr casts, exact type matching, small buffer limits, copyable-only storage, and safe void* C callback context.
-
C++ CTAD and Deduction Guides: Class Template Argument Deduction (C++17)
How C++17 CTAD deduces class template arguments from constructors, when you need a user-defined deduction guide (iterator pairs, const char* to std::string), explicit guides, and the surprises with braces, copies and string literals.
-
C++ string vs string_view: Fast, Non-Owning String Handling
std::string vs std::string_view: avoid copies in read-only APIs, allocation costs, lifetime rules, substring performance, and null-termination caveats.
-
std::optional vs Nullable Pointer vs Out-Parameter in C++: Choosing How to Return 'Maybe a Value'
std::optional vs T* vs out-param in C++: who owns the result, optional<T&> before C++26, value() vs operator*, optional<bool> traps, dangling lookups.
-
C++17 std::any: any_cast Forms, Type Safety, and When variant Is the Better Choice
How std::any holds a value of any copyable type, what each any_cast form does on a type mismatch, the heap-allocation cost to expect, and when std::variant or void* is the better fit.