From 69918b07e17cce822ad8f11950da476c42e419ee Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Wed, 24 Aug 2022 08:41:41 +0400 Subject: cmDocumentationEntry: Drop all user provided ctors for C++ >= 14 There is no need for them cuz: - the last field has a default value - all static instances use 2 arguments convertible to `std::string` - "dynamic" instances used for _Generator_ doc entries access fields diectly using default constructed instance Moreover, compiler may generate move ctor/assign when needed. --- Source/CPack/cpack.cxx | 6 +++--- Source/CursesDialog/ccmake.cxx | 10 ++++++---- Source/QtDialog/CMakeSetup.cxx | 5 +++-- Source/cmDocumentation.cxx | 5 +++-- Source/cmDocumentationEntry.h | 19 +++++++++---------- Source/cmDocumentationSection.h | 6 ------ Source/cmakemain.cxx | 10 ++++++---- Source/ctest.cxx | 6 +++--- 8 files changed, 33 insertions(+), 34 deletions(-) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index efb549f..f81c6e8 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -36,11 +36,11 @@ namespace { const cmDocumentationEntry cmDocumentationName = { - nullptr, " cpack - Packaging driver provided by CMake." + {}, + " cpack - Packaging driver provided by CMake." }; -const cmDocumentationEntry cmDocumentationUsage = { nullptr, - " cpack [options]" }; +const cmDocumentationEntry cmDocumentationUsage = { {}, " cpack [options]" }; const cmDocumentationEntry cmDocumentationOptions[14] = { { "-G ", "Override/define CPACK_GENERATOR" }, diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index d61954a..18c1a80 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -25,21 +25,23 @@ namespace { const cmDocumentationEntry cmDocumentationName = { - nullptr, " ccmake - Curses Interface for CMake." + {}, + " ccmake - Curses Interface for CMake." }; const cmDocumentationEntry cmDocumentationUsage[2] = { - { nullptr, + { {}, " ccmake \n" " ccmake " }, - { nullptr, + { {}, "Specify a source directory to (re-)generate a build system for " "it in the current working directory. Specify an existing build " "directory to re-generate its build system." }, }; const cmDocumentationEntry cmDocumentationUsageNote = { - nullptr, "Run 'ccmake --help' for more information." + {}, + "Run 'ccmake --help' for more information." }; #ifndef _WIN32 diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 11f7fe6..50e8e3a 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -24,11 +24,12 @@ namespace { const cmDocumentationEntry cmDocumentationName = { - nullptr, " cmake-gui - CMake GUI." + {}, + " cmake-gui - CMake GUI." }; const cmDocumentationEntry cmDocumentationUsage = { - nullptr, + {}, " cmake-gui [options]\n" " cmake-gui [options] \n" " cmake-gui [options] \n" diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index e626f7e..77c5295 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -47,11 +47,12 @@ const cmDocumentationEntry cmDocumentationStandardOptions[20] = { }; const cmDocumentationEntry cmDocumentationCPackGeneratorsHeader = { - nullptr, "The following generators are available on this platform:" + {}, + "The following generators are available on this platform:" }; const cmDocumentationEntry cmDocumentationCMakeGeneratorsHeader = { - nullptr, + {}, "The following generators are available on this platform (* marks " "default):" }; diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h index aa97391..c66b21e 100644 --- a/Source/cmDocumentationEntry.h +++ b/Source/cmDocumentationEntry.h @@ -9,17 +9,16 @@ /** Standard documentation entry for cmDocumentation's formatting. */ struct cmDocumentationEntry { - std::string Name; - std::string Brief; - char CustomNamePrefix = ' '; +#if __cplusplus <= 201103L cmDocumentationEntry() = default; - cmDocumentationEntry(const char* const n, const char* const b) + cmDocumentationEntry(const std::string& name, const std::string& brief) + : Name{ name } + , Brief{ brief } { - if (n) { - this->Name = n; - } - if (b) { - this->Brief = b; - } } +#endif + + std::string Name = {}; + std::string Brief = {}; + char CustomNamePrefix = ' '; }; diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h index b80131d..b5e24fe 100644 --- a/Source/cmDocumentationSection.h +++ b/Source/cmDocumentationSection.h @@ -52,12 +52,6 @@ public: std::end(entries)); } - /** Append an entry to this section using NULL terminated chars */ - void Append(const char* n, const char* b) - { - this->Entries.emplace_back(n, b); - } - /** prepend some documentation to this section */ template void Prepend(const Iterable& entries) diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 1ca3e55..a155787 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -47,22 +47,24 @@ namespace { #ifndef CMAKE_BOOTSTRAP const cmDocumentationEntry cmDocumentationName = { - nullptr, " cmake - Cross-Platform Makefile Generator." + {}, + " cmake - Cross-Platform Makefile Generator." }; const cmDocumentationEntry cmDocumentationUsage[2] = { - { nullptr, + { {}, " cmake [options] \n" " cmake [options] \n" " cmake [options] -S -B " }, - { nullptr, + { {}, "Specify a source directory to (re-)generate a build system for " "it in the current working directory. Specify an existing build " "directory to re-generate its build system." } }; const cmDocumentationEntry cmDocumentationUsageNote = { - nullptr, "Run 'cmake --help' for more information." + {}, + "Run 'cmake --help' for more information." }; const cmDocumentationEntry cmDocumentationOptions[31] = { diff --git a/Source/ctest.cxx b/Source/ctest.cxx index d26a0d7..fa38a65 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -19,11 +19,11 @@ namespace { const cmDocumentationEntry cmDocumentationName = { - nullptr, " ctest - Testing driver provided by CMake." + {}, + " ctest - Testing driver provided by CMake." }; -const cmDocumentationEntry cmDocumentationUsage = { nullptr, - " ctest [options]" }; +const cmDocumentationEntry cmDocumentationUsage = { {}, " ctest [options]" }; const cmDocumentationEntry cmDocumentationOptions[74] = { { "--preset , --preset=", -- cgit v0.12