Skip to content

Commit

Permalink
C.20: rephrase example, re #2212
Browse files Browse the repository at this point in the history
  • Loading branch information
cubbimew committed Oct 4, 2024
1 parent 0915e25 commit 417da74
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CppCoreGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -4878,14 +4878,16 @@ It's the simplest and gives the cleanest semantics.

struct Named_map {
public:
Named_map() : name("empty") {}
// ... no default operations declared ...
Named_map(const string& n) : name(n) {}
// no copy/move constructors
// no copy/move assignment operators
// no destructor
private:
string name;
map<int, int> rep;
};

Named_map nm; // default construct
Named_map nm("map"); // construct
Named_map nm2 {nm}; // copy construct

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

0 comments on commit 417da74

Please sign in to comment.