mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
style fixes
This commit is contained in:
@@ -5464,7 +5464,7 @@ The compiler is more likely to get the default semantics right and you cannot im
|
|||||||
Tracer& operator=(Tracer&&) = default;
|
Tracer& operator=(Tracer&&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
Because we defined the destructor, we must define the copy and move operations. The `=default` is the best and simplest way of doing that.
|
Because we defined the destructor, we must define the copy and move operations. The `= default` is the best and simplest way of doing that.
|
||||||
|
|
||||||
##### Example, bad
|
##### Example, bad
|
||||||
|
|
||||||
@@ -7484,7 +7484,7 @@ The default is the easiest to read and write.
|
|||||||
|
|
||||||
enum class Direction : char { n, s, e, w,
|
enum class Direction : char { n, s, e, w,
|
||||||
ne, nw, se, sw }; // underlying type saves space
|
ne, nw, se, sw }; // underlying type saves space
|
||||||
|
|
||||||
enum class Web_color : int { red = 0xFF0000,
|
enum class Web_color : int { red = 0xFF0000,
|
||||||
green = 0x00FF00,
|
green = 0x00FF00,
|
||||||
blue = 0x0000FF }; // underlying type is redundant
|
blue = 0x0000FF }; // underlying type is redundant
|
||||||
@@ -12180,10 +12180,10 @@ Not all member functions can be called.
|
|||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
class Vector { // very simplified vector of doubles
|
class Vector { // very simplified vector of doubles
|
||||||
// if elem!=nullptr then elem points to sz doubles
|
// if elem != nullptr then elem points to sz doubles
|
||||||
public:
|
public:
|
||||||
Vector() : elem{nullptr}, sz{0}{}
|
Vector() : elem{nullptr}, sz{0}{}
|
||||||
vector(int s) : elem{new double},sz{s} { /* initialize elements */ }
|
vector(int s) : elem{new double}, sz{s} { /* initialize elements */ }
|
||||||
~Vector() { delete elem; }
|
~Vector() { delete elem; }
|
||||||
double& operator[](int s) { return elem[s]; }
|
double& operator[](int s) { return elem[s]; }
|
||||||
// ...
|
// ...
|
||||||
|
|||||||
Reference in New Issue
Block a user