Change = to {} for default member initialization (#1973)

* Change = to {} for default member initialization

* Remove nullptr
This commit is contained in:
Andrey Sikorin
2022-09-23 00:07:34 +03:00
committed by GitHub
parent e1735eaf89
commit af048a07b8

View File

@@ -5469,9 +5469,9 @@ However, most realistic `Date` classes have a "first date" (e.g. January 1, 1970
Date() = default; // [See also](#Rc-default) Date() = default; // [See also](#Rc-default)
// ... // ...
private: private:
int dd = 1; int dd {1};
int mm = 1; int mm {1};
int yyyy = 1970; int yyyy {1970};
// ... // ...
}; };
@@ -5591,9 +5591,9 @@ For example, `Vector0<int> v[100]` costs 100 allocations.
Vector1(int n) :elem{new T[n]}, space{elem + n}, last{elem} {} Vector1(int n) :elem{new T[n]}, space{elem + n}, last{elem} {}
// ... // ...
private: private:
own<T*> elem = nullptr; own<T*> elem {};
T* space = nullptr; T* space {};
T* last = nullptr; T* last {};
}; };
Using `{nullptr, nullptr, nullptr}` makes `Vector1{}` cheap, but a special case and implies run-time checks. 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 ##### Example
class X2 { class X2 {
string s = "default"; string s {"default"};
int i = 1; int i {1};
public: public:
// use compiler-generated default constructor // use compiler-generated default constructor
// ... // ...