From c166efde7b0b4c08b70dcf8efd6af26f83268595 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 7 Jul 2026 13:28:30 +0200 Subject: [PATCH] Use function call in Example of C.48: Prefer default member initializer Guideline C.48 appears specifically about _constant_ initializers, and its Example only had literal constants (`666`, `"qqq"`, `0`) as initializers. However, the guideline also applies when initializing a member by a function-call, like `numeric_limits::min()`. This commit adjusts the Example accordingly. --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 11125dfd5..7c918cd32 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -5987,7 +5987,7 @@ How would a maintainer know whether `j` was deliberately uninitialized (probably class X2 { int i {666}; string s {"qqq"}; - int j {0}; + int j {numeric_limits::min()}; public: X2() = default; // all members are initialized to their defaults X2(int ii) :i{ii} {} // s and j initialized to their defaults @@ -6001,7 +6001,7 @@ How would a maintainer know whether `j` was deliberately uninitialized (probably string s; int j; public: - X3(int ii = 666, const string& ss = "qqq", int jj = 0) + X3(int ii = 666, const string& ss = "qqq", int jj = numeric_limits::min()) :i{ii}, s{ss}, j{jj} { } // all members are initialized to their defaults // ... };