Skip to content

Commit 417da74

Browse files
committed
C.20: rephrase example, re #2212
1 parent 0915e25 commit 417da74

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

CppCoreGuidelines.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4878,14 +4878,16 @@ It's the simplest and gives the cleanest semantics.
48784878

48794879
struct Named_map {
48804880
public:
4881-
Named_map() : name("empty") {}
4882-
// ... no default operations declared ...
4881+
Named_map(const string& n) : name(n) {}
4882+
// no copy/move constructors
4883+
// no copy/move assignment operators
4884+
// no destructor
48834885
private:
48844886
string name;
48854887
map<int, int> rep;
48864888
};
48874889

4888-
Named_map nm; // default construct
4890+
Named_map nm("map"); // construct
48894891
Named_map nm2 {nm}; // copy construct
48904892

48914893
Since `std::map` and `string` have all the special functions, no further work is needed.

0 commit comments

Comments
 (0)