From 417da7404daa2c86abf8a5ebd4a9e97a9b69be00 Mon Sep 17 00:00:00 2001 From: Sergey Zubkov Date: Fri, 4 Oct 2024 09:49:16 -0400 Subject: [PATCH] C.20: rephrase example, re #2212 --- CppCoreGuidelines.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 3ce5b6cbd..702ec6c6d 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -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 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.