From af048a07b804e38557af9045154551682f08f698 Mon Sep 17 00:00:00 2001 From: Andrey Sikorin Date: Fri, 23 Sep 2022 00:07:34 +0300 Subject: [PATCH] Change = to {} for default member initialization (#1973) * Change = to {} for default member initialization * Remove nullptr --- CppCoreGuidelines.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 645d26e..5a4aa84 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -5469,9 +5469,9 @@ However, most realistic `Date` classes have a "first date" (e.g. January 1, 1970 Date() = default; // [See also](#Rc-default) // ... private: - int dd = 1; - int mm = 1; - int yyyy = 1970; + int dd {1}; + int mm {1}; + int yyyy {1970}; // ... }; @@ -5591,9 +5591,9 @@ For example, `Vector0 v[100]` costs 100 allocations. Vector1(int n) :elem{new T[n]}, space{elem + n}, last{elem} {} // ... private: - own elem = nullptr; - T* space = nullptr; - T* last = nullptr; + own elem {}; + T* space {}; + T* last {}; }; Using `{nullptr, nullptr, nullptr}` makes `Vector1{}` cheap, but a special case and implies run-time checks. @@ -5622,8 +5622,8 @@ Using in-class member initializers lets the compiler generate the function for y ##### Example class X2 { - string s = "default"; - int i = 1; + string s {"default"}; + int i {1}; public: // use compiler-generated default constructor // ...