From c688b401d3adaacc820ef4b589010e8aefa808b1 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sun, 4 Aug 2019 10:49:16 +0200 Subject: cmstd: Modernize CMake system headers Provide a standardized way to handle the C++ "standard" headers customized to be used with current CMake C++ standard constraints. Offer under directory `cm` headers which can be used as direct replacements of the standard ones. For example: #include can be used safely for CMake development in place of the `` standard header. Fixes: #19491 --- CMakeLists.txt | 13 + Source/CMakeLists.txt | 6 +- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 3 +- Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 4 +- Source/CPack/cmCPackDebGenerator.cxx | 4 +- Source/CPack/cmCPackExternalGenerator.cxx | 2 +- Source/CPack/cmCPackExternalGenerator.h | 1 + Source/CPack/cmCPackGenerator.h | 3 +- Source/CPack/cmCPackOSXX11Generator.cxx | 3 +- Source/CPack/cmCPackSTGZGenerator.cxx | 3 +- Source/CTest/cmCTestBuildCommand.h | 2 +- Source/CTest/cmCTestCVS.cxx | 4 +- Source/CTest/cmCTestConfigureCommand.h | 2 +- Source/CTest/cmCTestCoverageCommand.h | 2 +- Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h | 2 +- Source/CTest/cmCTestMemCheckCommand.h | 2 +- Source/CTest/cmCTestReadCustomFilesCommand.h | 2 +- Source/CTest/cmCTestRunScriptCommand.h | 2 +- Source/CTest/cmCTestRunTest.cxx | 2 +- Source/CTest/cmCTestScriptHandler.cxx | 2 +- Source/CTest/cmCTestSleepCommand.h | 2 +- Source/CTest/cmCTestStartCommand.h | 2 +- Source/CTest/cmCTestSubmitCommand.cxx | 2 +- Source/CTest/cmCTestTestCommand.h | 2 +- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/CTest/cmCTestUpdateCommand.h | 2 +- Source/CTest/cmCTestUpdateHandler.cxx | 2 +- Source/CTest/cmCTestUploadCommand.h | 2 +- Source/cmAlgorithms.h | 77 ----- Source/cmArgumentParser.h | 2 +- Source/cmBinUtilsLinuxELFLinker.cxx | 2 +- Source/cmBinUtilsMacOSMachOLinker.cxx | 2 +- Source/cmBinUtilsWindowsPELinker.cxx | 2 +- Source/cmCTest.cxx | 2 +- Source/cmCommands.cxx | 2 +- Source/cmComputeLinkDepends.cxx | 2 +- Source/cmCryptoHash.cxx | 2 +- Source/cmCryptoHash.h | 2 +- Source/cmCustomCommandLines.h | 2 +- Source/cmDefinitions.cxx | 2 +- Source/cmDefinitions.h | 5 +- Source/cmDependsJavaParserHelper.cxx | 2 +- Source/cmELF.cxx | 2 +- Source/cmExportCommand.h | 2 +- Source/cmExportFileGenerator.cxx | 2 +- Source/cmExportLibraryDependenciesCommand.cxx | 2 +- Source/cmFSPermissions.h | 4 +- Source/cmFileCommand.cxx | 5 +- Source/cmFileCopier.h | 3 +- Source/cmFileTimes.cxx | 6 +- Source/cmFindPackageCommand.cxx | 2 +- Source/cmForEachCommand.cxx | 5 +- Source/cmFunctionBlocker.h | 2 +- Source/cmFunctionCommand.cxx | 5 +- Source/cmGeneratorExpressionEvaluationFile.h | 3 +- Source/cmGeneratorExpressionNode.cxx | 3 +- Source/cmGeneratorTarget.cxx | 3 +- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 3 +- Source/cmGlobalVisualStudioGenerator.cxx | 3 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmIfCommand.cxx | 5 +- Source/cmIncludeDirectoryCommand.h | 2 +- Source/cmInstallCommand.h | 2 +- Source/cmLinkDirectoriesCommand.h | 2 +- Source/cmListCommand.cxx | 3 +- Source/cmLoadCacheCommand.h | 2 +- Source/cmLoadCommandCommand.cxx | 2 +- Source/cmLocalGenerator.cxx | 3 +- Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- Source/cmMachO.cxx | 2 +- Source/cmMacroCommand.cxx | 5 +- Source/cmMakefile.cxx | 5 +- Source/cmMakefile.h | 2 +- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMakefileUtilityTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmOutputConverter.h | 3 +- Source/cmParseArgumentsCommand.cxx | 2 +- Source/cmProjectCommand.h | 2 +- Source/cmQtAutoGen.h | 2 +- Source/cmQtAutoGenGlobalInitializer.cxx | 2 +- Source/cmQtAutoGenInitializer.cxx | 2 +- Source/cmQtAutoGenInitializer.h | 3 +- Source/cmQtAutoGenerator.cxx | 3 +- Source/cmQtAutoGenerator.h | 3 +- Source/cmQtAutoMocUic.cxx | 10 +- Source/cmQtAutoMocUic.h | 3 +- Source/cmQtAutoRcc.cxx | 3 +- Source/cmRuntimeDependencyArchive.cxx | 2 +- Source/cmServer.cxx | 3 +- Source/cmServer.h | 3 +- Source/cmServerProtocol.cxx | 2 +- Source/cmSetTargetPropertiesCommand.h | 2 +- Source/cmSourceGroupCommand.h | 2 +- Source/cmState.cxx | 2 +- Source/cmStateDirectory.cxx | 11 +- Source/cmStateSnapshot.cxx | 6 +- Source/cmStateSnapshot.h | 2 +- Source/cmString.hxx | 2 +- Source/cmStringAlgorithms.h | 4 +- Source/cmStringCommand.cxx | 4 +- Source/cmSubcommandTable.h | 3 +- Source/cmSystemTools.h | 2 +- Source/cmTarget.cxx | 2 +- Source/cmTargetCompileDefinitionsCommand.h | 2 +- Source/cmTargetCompileFeaturesCommand.h | 2 +- Source/cmTargetCompileOptionsCommand.h | 2 +- Source/cmTargetIncludeDirectoriesCommand.h | 2 +- Source/cmTargetLinkDirectoriesCommand.h | 2 +- Source/cmTargetLinkLibrariesCommand.h | 2 +- Source/cmTargetLinkOptionsCommand.h | 2 +- Source/cmTargetPrecompileHeadersCommand.h | 2 +- Source/cmTargetSourcesCommand.h | 2 +- Source/cmTryCompileCommand.h | 2 +- Source/cmTryRunCommand.h | 2 +- Source/cmUVProcessChain.cxx | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- Source/cmVisualStudioGeneratorOptions.cxx | 6 +- Source/cmWhileCommand.cxx | 5 +- Source/cmWorkerPool.cxx | 2 +- Source/cmWorkerPool.h | 2 +- Source/cmWriteFileCommand.cxx | 3 +- Source/cm_memory.hxx | 31 -- Source/cm_optional.hxx | 343 --------------------- Source/cm_static_string_view.hxx | 2 +- Source/cm_string_view.cxx | 301 ------------------- Source/cm_string_view.hxx | 217 -------------- Source/cm_sys_stat.h | 2 +- Source/cm_thread.hxx | 48 --- Source/cm_utility.hxx | 35 --- Source/cmake.cxx | 10 +- Tests/CMakeLib/testArgumentParser.cxx | 2 +- Tests/CMakeLib/testOptional.cxx | 5 +- Tests/CMakeLib/testString.cxx | 2 +- Tests/CMakeLib/testStringAlgorithms.cxx | 3 +- Tests/CMakeLib/testUVProcessChain.cxx | 2 +- Utilities/IWYU/mapping.imp | 1 - Utilities/std/.gitattributes | 1 + Utilities/std/CMakeLists.txt | 10 + Utilities/std/cm/bits/string_view.cxx | 301 +++++++++++++++++++ Utilities/std/cm/iterator | 78 +++++ Utilities/std/cm/memory | 32 ++ Utilities/std/cm/optional | 344 ++++++++++++++++++++++ Utilities/std/cm/shared_mutex | 76 +++++ Utilities/std/cm/string_view | 218 ++++++++++++++ Utilities/std/cm/utility | 34 +++ bootstrap | 28 +- 151 files changed, 1336 insertions(+), 1218 deletions(-) delete mode 100644 Source/cm_memory.hxx delete mode 100644 Source/cm_optional.hxx delete mode 100644 Source/cm_string_view.cxx delete mode 100644 Source/cm_string_view.hxx delete mode 100644 Source/cm_thread.hxx delete mode 100644 Source/cm_utility.hxx create mode 100644 Utilities/std/.gitattributes create mode 100644 Utilities/std/CMakeLists.txt create mode 100644 Utilities/std/cm/bits/string_view.cxx create mode 100644 Utilities/std/cm/iterator create mode 100644 Utilities/std/cm/memory create mode 100644 Utilities/std/cm/optional create mode 100644 Utilities/std/cm/shared_mutex create mode 100644 Utilities/std/cm/string_view create mode 100644 Utilities/std/cm/utility diff --git a/CMakeLists.txt b/CMakeLists.txt index 21e8c46..da99a6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,11 +368,24 @@ macro (CMAKE_BUILD_UTILITIES) # Setup third-party libraries. # Everything in the tree should be able to include files from the # Utilities directory. + if (CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using -isystem option generate error "template with C linkage" + include_directories("${CMake_SOURCE_DIR}/Utilities/std") + else() + include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities/std") + endif() + include_directories( ${CMake_BINARY_DIR}/Utilities ${CMake_SOURCE_DIR}/Utilities ) + #--------------------------------------------------------------------- + # Build CMake std library for CMake and CTest. + set(CMAKE_STD_LIBRARY cmstd) + add_subdirectory(Utilities/std) + CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std") + # check for the use of system libraries versus builtin ones # (a macro defined in this file) CMAKE_HANDLE_SYSTEM_LIBRARIES() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 65cd6c9..c7648f1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -439,9 +439,6 @@ set(SRCS cmXMLWriter.h cmake.cxx cmake.h - cm_string_view.cxx - cm_string_view.hxx - cm_static_string_view.hxx cmCommand.cxx cmCommand.h @@ -683,13 +680,13 @@ set(SRCS cmWriteFileCommand.cxx cmWriteFileCommand.h + cm_static_string_view.hxx cm_get_date.h cm_get_date.c cm_utf8.h cm_utf8.c cm_codecvt.hxx cm_codecvt.cxx - cm_thread.hxx cmDuration.h cmDuration.cxx @@ -855,6 +852,7 @@ endforeach() # create a library used by the command line and the GUI add_library(CMakeLib ${SRCS}) target_link_libraries(CMakeLib cmsys + ${CMAKE_STD_LIBRARY} ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} ${CMAKE_TAR_LIBRARIES} ${CMAKE_CURL_LIBRARIES} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index f784832..683f275 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -11,8 +11,9 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmUuid.h" -#include "cm_string_view.hxx" + #include +#include #include "cmWIXDirectoriesSourceWriter.h" #include "cmWIXFeaturesSourceWriter.h" diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index dd3caf9..7705d83 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -9,10 +9,10 @@ #include "cmSystemTools.h" #include "cmUuid.h" -#include "cm_sys_stat.h" - #include "cmCMakeToWixPath.h" +#include "cm_sys_stat.h" + cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename, GuidType componentGuidType) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0e64b5a..4f299f7 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -10,9 +10,11 @@ #include "cmGeneratedFileStream.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" #include "cmsys/Glob.hxx" + +#include "cm_sys_stat.h" + #include #include #include diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index 5dc6ace..05e5c21 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -17,7 +17,7 @@ #include #include -#include "cm_memory.hxx" +#include int cmCPackExternalGenerator::InitializeInternal() { diff --git a/Source/CPack/cmCPackExternalGenerator.h b/Source/CPack/cmCPackExternalGenerator.h index 176d6a9..b77e45b 100644 --- a/Source/CPack/cmCPackExternalGenerator.h +++ b/Source/CPack/cmCPackExternalGenerator.h @@ -4,6 +4,7 @@ #define cmCPackExternalGenerator_h #include "cmCPackGenerator.h" + #include "cm_sys_stat.h" #include diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index fc00b09..33026c1 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -10,9 +10,10 @@ #include #include +#include "cm_sys_stat.h" + #include "cmCPackComponentGroup.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" class cmCPackLog; class cmGlobalGenerator; diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 992299a..cd65694 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -4,13 +4,14 @@ #include +#include "cm_sys_stat.h" + #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" cmCPackOSXX11Generator::cmCPackOSXX11Generator() = default; diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index eb48c37..eb1e24c 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -8,11 +8,12 @@ #include #include +#include "cm_sys_stat.h" + #include "cmArchiveWrite.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" cmCPackSTGZGenerator::cmCPackSTGZGenerator() : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr", ".sh") diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index a62c301..14f70bf 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestBuildHandler; class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index b9b90c8..5baeecd 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -7,10 +7,12 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" -#include "cm_string_view.hxx" #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" + +#include + #include cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log) diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 4677c83..36ca7d5 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 24b96c0..75aefdf 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 84250cb..4232b9e 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index 837a687..5dad4e7 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -7,7 +7,7 @@ #include -#include "cm_memory.hxx" +#include #include "cmCTestTestCommand.h" #include "cmCommand.h" diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index db2ac5e..8199cbc 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index 6961f6e..d262a83 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 3629a50..d8a5923 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -20,7 +20,7 @@ #include #include -#include "cm_memory.hxx" +#include cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler) : MultiTestHandler(multiHandler) diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 354e3c4..c988e3a 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -5,7 +5,7 @@ #include "cmsys/Directory.hxx" #include "cmsys/Process.h" -#include "cm_memory.hxx" +#include #include "cmCTest.h" #include "cmCTestBuildCommand.h" diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index 7b17081..b98079d 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index 7c71f36..598c937 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -13,7 +13,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index d16aac0..2e2cf1a 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -13,7 +13,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index d74136c..a9ba3ab 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 10f9f9b..ee0d8c8 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCTest.h" diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index 55c4b80..5b0e07e 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index a6a3542..c4cb233 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -20,7 +20,7 @@ #include #include -#include "cm_memory.hxx" +#include static const char* cmCTestUpdateHandlerUpdateStrings[] = { "Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4" diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 9e49769..39314f2 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 60b746c..06ea9f6 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -238,81 +238,4 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t) return std::find_if(r.begin(), r.end(), [&t](T const& i) { return i != t; }); } -template -std::reverse_iterator cmMakeReverseIterator(Iter it) -{ - return std::reverse_iterator(it); -} - -namespace cm { - -#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L - -using std::size; - -#else - -// std::size backport from C++17. -template -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - size(C const& c) -> decltype(c.size()) -{ - return c.size(); -} - -template -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - std::size_t - size(const T (&)[N]) throw() -{ - return N; -} - -#endif - -template -int isize(const T& t) -{ - return static_cast(cm::size(t)); -} - -#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L - -using std::cbegin; -using std::cend; - -#else - -// std::c{begin,end} backport from C++14 -template -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto cbegin(C const& c) -# else -constexpr auto cbegin(C const& c) noexcept(noexcept(std::begin(c))) -# endif - -> decltype(std::begin(c)) -{ - return std::begin(c); -} - -template -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto cend(C const& c) -# else -constexpr auto cend(C const& c) noexcept(noexcept(std::end(c))) -# endif - -> decltype(std::end(c)) -{ - return std::end(c); -} - -#endif - -} // namespace cm - #endif diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index 6cfe946..b6798bc 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -6,7 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmBinUtilsLinuxELFLinker.cxx b/Source/cmBinUtilsLinuxELFLinker.cxx index 6316a29..a1125a9 100644 --- a/Source/cmBinUtilsLinuxELFLinker.cxx +++ b/Source/cmBinUtilsLinuxELFLinker.cxx @@ -15,7 +15,7 @@ #include -#include "cm_memory.hxx" +#include static std::string ReplaceOrigin(const std::string& rpath, const std::string& origin) diff --git a/Source/cmBinUtilsMacOSMachOLinker.cxx b/Source/cmBinUtilsMacOSMachOLinker.cxx index 7ff8584..b1f718b 100644 --- a/Source/cmBinUtilsMacOSMachOLinker.cxx +++ b/Source/cmBinUtilsMacOSMachOLinker.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include cmBinUtilsMacOSMachOLinker::cmBinUtilsMacOSMachOLinker( cmRuntimeDependencyArchive* archive) diff --git a/Source/cmBinUtilsWindowsPELinker.cxx b/Source/cmBinUtilsWindowsPELinker.cxx index 5a9ad66..bfafaeb 100644 --- a/Source/cmBinUtilsWindowsPELinker.cxx +++ b/Source/cmBinUtilsWindowsPELinker.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include #ifdef _WIN32 # include diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 5e17ce8..1031f40 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -29,7 +29,7 @@ # include // IWYU pragma: keep #endif -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCTestBuildAndTestHandler.h" diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 38fcf5b..262590b 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cm_memory.hxx" +#include #include "cmCommands.h" #include "cmPolicies.h" diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 2ee4ca2..ce2c0ae 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -23,7 +23,7 @@ #include #include -#include "cm_memory.hxx" +#include /* diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index f9f9581..ff683ad 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -6,7 +6,7 @@ #include "cm_rhash.h" #include "cmsys/FStream.hxx" -#include "cm_memory.hxx" +#include static unsigned int const cmCryptoHashAlgoToId[] = { /* clang-format needs this comment to break after the opening brace */ diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 145ff91..05552bd 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h index 213aeb1..ead5792 100644 --- a/Source/cmCustomCommandLines.h +++ b/Source/cmCustomCommandLines.h @@ -9,7 +9,7 @@ #include #include -#include "cm_string_view.hxx" // IWYU pragma: keep +#include // IWYU pragma: keep /** Data structure to represent a single command line. */ class cmCustomCommandLine : public std::vector diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 2a117c1..32f47b0 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDefinitions.h" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 008821d..72e88b5 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -5,11 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" - #include "cmLinkedTree.h" + #include "cmString.hxx" +#include + #include #include #include diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 63a96d0..18b49b8 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -5,8 +5,8 @@ #include "cmDependsJavaLexer.h" #include "cmSystemTools.h" -#include "cm_string_view.hxx" #include "cmsys/FStream.hxx" +#include #include #include #include diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 12f996d..06b5511 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -4,8 +4,8 @@ #include "cmAlgorithms.h" #include "cm_kwiml.h" -#include "cm_memory.hxx" #include "cmsys/FStream.hxx" +#include #include #include #include diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index 50463af..819a3c3 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e588f7b..f9a28cd 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -24,7 +24,7 @@ #include #include -#include "cm_memory.hxx" +#include static std::string cmExportFileGeneratorEscape(std::string const& str) { diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index bab394a..fd2401e 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -6,7 +6,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmExecutionStatus.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmFSPermissions.h b/Source/cmFSPermissions.h index 7a6e708..fef72e6 100644 --- a/Source/cmFSPermissions.h +++ b/Source/cmFSPermissions.h @@ -5,10 +5,10 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_sys_stat.h" - #include +#include "cm_sys_stat.h" + namespace cmFSPermissions { // Table of permissions flags. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4701d29..c7a0e55 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -20,7 +20,9 @@ #include #include -#include "cm_memory.hxx" +#include + +#include "cm_sys_stat.h" #include "cmAlgorithms.h" #include "cmArgumentParser.h" @@ -44,7 +46,6 @@ #include "cmSubcommandTable.h" #include "cmSystemTools.h" #include "cmTimestamp.h" -#include "cm_sys_stat.h" #include "cmake.h" #if !defined(CMAKE_BOOTSTRAP) diff --git a/Source/cmFileCopier.h b/Source/cmFileCopier.h index 263a365..8fc481c 100644 --- a/Source/cmFileCopier.h +++ b/Source/cmFileCopier.h @@ -6,9 +6,10 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmFileTimeCache.h" -#include "cm_sys_stat.h" #include "cmsys/RegularExpression.hxx" +#include "cm_sys_stat.h" + #include #include diff --git a/Source/cmFileTimes.cxx b/Source/cmFileTimes.cxx index 3824e9b..54ac4ed 100644 --- a/Source/cmFileTimes.cxx +++ b/Source/cmFileTimes.cxx @@ -2,11 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileTimes.h" -#include "cm_sys_stat.h" - #include -#include "cm_memory.hxx" +#include + +#include "cm_sys_stat.h" #if defined(_WIN32) # include "cmSystemTools.h" diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index fea7e08..17e9869 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -18,7 +18,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmMakefile.h" diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index d563a1d..44392ba 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -6,9 +6,10 @@ #include #include -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h index 87bdccd..59bb892 100644 --- a/Source/cmFunctionBlocker.h +++ b/Source/cmFunctionBlocker.h @@ -7,7 +7,7 @@ #include -#include "cm_string_view.hxx" +#include #include "cmListFileCache.h" diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index fdc5e50..b3ddfe0 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -5,9 +5,10 @@ #include #include -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmAlgorithms.h" #include "cmExecutionStatus.h" diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 06ebeac..c3bc4c8 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -10,9 +10,10 @@ #include #include +#include "cm_sys_stat.h" + #include "cmGeneratorExpression.h" #include "cmPolicies.h" -#include "cm_sys_stat.h" class cmLocalGenerator; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 6cb7a96..d524867 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -29,12 +29,13 @@ #include "cmsys/RegularExpression.hxx" #include "cmsys/String.h" +#include + #include #include #include #include #include -#include #include #include #include diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3a321c5..136996e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -17,6 +17,8 @@ #include #include +#include + #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" #include "cmCustomCommand.h" @@ -42,7 +44,6 @@ #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" #include "cmTargetPropertyComputer.h" -#include "cm_string_view.hxx" #include "cmake.h" class cmMessenger; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9ce6324..7bba874 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index c7a0330..0b211b8 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -7,7 +7,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index b355775..92316d3 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -11,10 +11,11 @@ #include "cmState.h" #include "cmStringAlgorithms.h" #include "cmUuid.h" -#include "cm_string_view.hxx" #include "cmake.h" #include "cmsys/Encoding.hxx" +#include + #include #include #include diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index a0ce740..61e8f58 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -10,7 +10,8 @@ #include #include -#include "cmAlgorithms.h" +#include + #include "cmCallVisualStudioMacro.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4d41fd7..643cc99 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index f719041..b36d96b 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -2,9 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIfCommand.h" -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 4df94eb..bcaae9d 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 28bf443..9ffb842 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index 1a439de..489d90f 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 826abf5..7bf35c3 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -16,7 +16,8 @@ #include #include -#include "cm_memory.hxx" +#include + #include "cm_static_string_view.hxx" #include "cmAlgorithms.h" diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index 45e52f0..37f0372 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 6f5df46..1e02632 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -10,7 +10,7 @@ #include -#include "cm_memory.hxx" +#include #include "cmCPluginAPI.cxx" #include "cmCPluginAPI.h" diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index afcd69f..840f55f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -30,7 +30,6 @@ #include "cmTarget.h" #include "cmTestGenerator.h" #include "cmVersion.h" -#include "cm_string_view.hxx" #include "cmake.h" #include "cmsys/RegularExpression.hxx" @@ -39,6 +38,8 @@ # include "cmCryptoHash.h" #endif +#include + #include #include #include diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f80695d..6c1dfc9 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCustomCommand.h" // IWYU pragma: keep diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index bec3ad8..ee5eb00 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include // Include the Mach-O format information system header. #include diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index af97761..ba9947a 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -5,9 +5,10 @@ #include #include -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmAlgorithms.h" #include "cmExecutionStatus.h" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c593939..c67c367 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -10,12 +10,11 @@ #include #include #include -#include -#include #include #include -#include "cm_memory.hxx" +#include +#include #include "cmAlgorithms.h" #include "cmCommandArgumentParserHelper.h" diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6d695a7..bf405a5 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -17,7 +17,7 @@ #include #include -#include "cm_string_view.hxx" +#include #include "cmAlgorithms.h" #include "cmListFileCache.h" diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e44ca7b..91bd47e 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b37a933..faa0d67 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index d4045b3..47e2665 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -7,7 +7,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 97742c1..bd5abd1 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -10,7 +10,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCustomCommand.h" // IWYU pragma: keep diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 37e9e0e..8c88f6c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 671efe7..c2053c7 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -6,7 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmStateSnapshot.h" -#include "cm_string_view.hxx" + +#include #include diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 0b320b6..c802fb4 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -14,7 +14,7 @@ #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_string_view.hxx" +#include static std::string EscapeArg(const std::string& arg) { diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index 8b9bcc8..ffbd330 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index 71969ee..2a28c1e 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index abc69d0..576a034 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -17,7 +17,7 @@ #include "cmSystemTools.h" #include "cmTarget.h" -#include "cm_memory.hxx" +#include #include diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index ad4e4d5..9045722 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -41,7 +41,7 @@ #include #include -#include "cm_memory.hxx" +#include namespace { diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index bedda30..7ce9fad 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -6,7 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" #include "cmQtAutoGen.h" -#include "cm_string_view.hxx" + +#include #include #include diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 086b68c..eb829fa 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -2,7 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGenerator.h" -#include "cm_memory.hxx" +#include + #include "cmsys/FStream.hxx" #include "cmGlobalGenerator.h" diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 371b25c..f60acb0 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -7,7 +7,8 @@ #include "cmFileTime.h" #include "cmQtAutoGen.h" -#include "cm_string_view.hxx" + +#include #include #include diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 4e4875e..5cd1ba1 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2,6 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoMocUic.h" +#include +#include +#include + +#include + #include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" @@ -9,13 +15,9 @@ #include "cmQtAutoGen.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_memory.hxx" #include "cmake.h" #include "cmsys/FStream.hxx" -#include -#include -#include #if defined(__APPLE__) # include #endif diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 43123f2..15b66ca 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -9,9 +9,10 @@ #include "cmQtAutoGen.h" #include "cmQtAutoGenerator.h" #include "cmWorkerPool.h" -#include "cm_string_view.hxx" #include "cmsys/RegularExpression.hxx" +#include + #include #include #include diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index cd3e034..1bf8ca4 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -11,7 +11,8 @@ #include "cmQtAutoGen.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_string_view.hxx" + +#include #include diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 1b3f387..ed2e3e4 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -27,7 +27,7 @@ #include #include -#include "cm_memory.hxx" +#include #if defined(_WIN32) static void AddVisualStudioPath(std::vector& paths, diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index 9df1883..f150cf3 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -20,7 +20,8 @@ #include #include -#include "cm_memory.hxx" +#include +#include void on_signal(uv_signal_t* signal, int signum) { diff --git a/Source/cmServer.h b/Source/cmServer.h index ab2ad23..9b12604 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -5,11 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_jsoncpp_value.h" -#include "cm_thread.hxx" #include "cm_uv.h" #include "cmUVHandlePtr.h" +#include + #include #include #include diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index d576f36..f889129 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -23,7 +23,7 @@ #include #include -#include "cm_memory.hxx" +#include // Get rid of some windows macros: #undef max diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 7e4606e..e77b752 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 87a6114..6273d92 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 7463bf8..93ad2d7 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCacheManager.h" #include "cmCommand.h" diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index ede00a0..1262f53 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -5,9 +5,10 @@ #include #include -#include #include +#include + #include "cmAlgorithms.h" #include "cmProperty.h" #include "cmPropertyMap.h" @@ -177,7 +178,7 @@ cmStringRange GetPropertyContent(T const& content, U contentEndPosition) { auto end = content.begin() + contentEndPosition; - auto rbegin = cmMakeReverseIterator(end); + auto rbegin = cm::make_reverse_iterator(end); rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); return cmMakeRange(rbegin.base(), end); @@ -189,7 +190,7 @@ cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces, { auto entryEnd = content.begin() + contentEndPosition; - auto rbegin = cmMakeReverseIterator(entryEnd); + auto rbegin = cm::make_reverse_iterator(entryEnd); rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); auto it = backtraces.begin() + std::distance(content.begin(), rbegin.base()); @@ -270,7 +271,7 @@ void cmStateDirectory::PrependIncludeDirectoriesEntry( this->Snapshot_.Position->IncludeDirectoryPosition; auto rend = this->DirectoryState->IncludeDirectories.rend(); - auto rbegin = cmMakeReverseIterator(entryEnd); + auto rbegin = cm::make_reverse_iterator(entryEnd); rbegin = std::find(rbegin, rend, cmPropertySentinal); auto entryIt = rbegin.base(); @@ -440,7 +441,7 @@ void cmStateDirectory::PrependLinkDirectoriesEntry( this->Snapshot_.Position->LinkDirectoriesPosition; auto rend = this->DirectoryState->LinkDirectories.rend(); - auto rbegin = cmMakeReverseIterator(entryEnd); + auto rbegin = cm::make_reverse_iterator(entryEnd); rbegin = std::find(rbegin, rend, cmPropertySentinal); auto entryIt = rbegin.base(); diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 28d5170..645907c 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -5,10 +5,10 @@ #include #include -#include #include -#include "cmAlgorithms.h" +#include + #include "cmDefinitions.h" #include "cmListFileCache.h" #include "cmPropertyMap.h" @@ -279,7 +279,7 @@ void InitializeContentFromParent(T& parentContent, T& thisContent, auto parentBegin = parentContent.begin(); auto parentEnd = parentContent.end(); - auto parentRbegin = cmMakeReverseIterator(parentEnd); + auto parentRbegin = cm::make_reverse_iterator(parentEnd); auto parentRend = parentContent.rend(); parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal); auto parentIt = parentRbegin.base(); diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h index da39127..021fd53 100644 --- a/Source/cmStateSnapshot.h +++ b/Source/cmStateSnapshot.h @@ -9,7 +9,7 @@ #include #include -#include "cm_string_view.hxx" +#include #include "cmLinkedTree.h" #include "cmPolicies.h" diff --git a/Source/cmString.hxx b/Source/cmString.hxx index a401ad1..6223b78 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -6,7 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index cb6b8ba..6631e98 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -6,7 +6,9 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmRange.h" -#include "cm_string_view.hxx" + +#include + #include #include #include diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 809d05e..28616c2 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -9,12 +9,12 @@ #include #include #include -#include #include +#include + #include "cm_static_string_view.hxx" -#include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" diff --git a/Source/cmSubcommandTable.h b/Source/cmSubcommandTable.h index 21342bb..6e39a1f 100644 --- a/Source/cmSubcommandTable.h +++ b/Source/cmSubcommandTable.h @@ -6,7 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" + +#include #include #include diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index e7eef33..108215c 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -8,9 +8,9 @@ #include "cmCryptoHash.h" #include "cmDuration.h" #include "cmProcessOutput.h" -#include "cm_string_view.hxx" #include "cmsys/Process.h" #include "cmsys/SystemTools.hxx" // IWYU pragma: export +#include #include #include #include diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8900ebf..ca12c87 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCustomCommand.h" diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 25af21d..f85dc0a 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h index 07948fa..39597ca 100644 --- a/Source/cmTargetCompileFeaturesCommand.h +++ b/Source/cmTargetCompileFeaturesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index a571cfb..b328ba2 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 6defab2..f6481db 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetLinkDirectoriesCommand.h b/Source/cmTargetLinkDirectoriesCommand.h index a2fcfa9..a651d73 100644 --- a/Source/cmTargetLinkDirectoriesCommand.h +++ b/Source/cmTargetLinkDirectoriesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 6698ce0..caf2cf4 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetLinkLibraryType.h" diff --git a/Source/cmTargetLinkOptionsCommand.h b/Source/cmTargetLinkOptionsCommand.h index 3710739..918a8d7 100644 --- a/Source/cmTargetLinkOptionsCommand.h +++ b/Source/cmTargetLinkOptionsCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetPrecompileHeadersCommand.h b/Source/cmTargetPrecompileHeadersCommand.h index 1ddf2af..7e4558e 100644 --- a/Source/cmTargetPrecompileHeadersCommand.h +++ b/Source/cmTargetPrecompileHeadersCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h index 90fd45f..1cff8c3 100644 --- a/Source/cmTargetSourcesCommand.h +++ b/Source/cmTargetSourcesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index ec9f8b8..e525e85 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmCoreTryCompile.h" diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index bacfcdb..c53a694 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmCoreTryCompile.h" diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index 2c37a64..3adc47a 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -13,7 +13,7 @@ #include #include -#include "cm_memory.hxx" +#include struct cmUVProcessChain::InternalData { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ba72294..4b83595 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -21,7 +21,7 @@ #include #include -#include "cm_memory.hxx" +#include static void ConvertToWindowsSlash(std::string& s); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 3e423e9..1139aa9 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -1,5 +1,7 @@ #include "cmVisualStudioGeneratorOptions.h" +#include + #include "cmAlgorithms.h" #include "cmLocalVisualStudioGenerator.h" #include "cmOutputConverter.h" @@ -269,8 +271,8 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags() } if (keyValue[1].front() == '\'' && keyValue[1].back() == '\'') { - keyValue[1] = - keyValue[1].substr(1, std::max(0, cm::isize(keyValue[1]) - 2)); + keyValue[1] = keyValue[1].substr( + 1, std::max(std::string::size_type(0), keyValue[1].length() - 2)); } if (keyValue[0] == "level") { diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index a396852..bd71546 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -2,9 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWhileCommand.h" -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx index 5ac81df..9d279ab 100644 --- a/Source/cmWorkerPool.cxx +++ b/Source/cmWorkerPool.cxx @@ -17,7 +17,7 @@ #include #include -#include "cm_memory.hxx" +#include /** * @brief libuv pipe buffer class diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h index bf07299..9179922 100644 --- a/Source/cmWorkerPool.h +++ b/Source/cmWorkerPool.h @@ -10,7 +10,7 @@ #include #include -#include "cm_memory.hxx" +#include // -- Types class cmWorkerPoolInternal; diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index fdf07bb..264dd3f 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -2,13 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWriteFileCommand.h" +#include "cm_sys_stat.h" + #include "cmsys/FStream.hxx" #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" // cmLibraryCommand bool cmWriteFileCommand(std::vector const& args, diff --git a/Source/cm_memory.hxx b/Source/cm_memory.hxx deleted file mode 100644 index 9f5e678..0000000 --- a/Source/cm_memory.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_memory_hxx -#define cm_memory_hxx - -#include "cmConfigure.h" // IWYU pragma: keep - -#include // IWYU pragma: export -#if !defined(CMake_HAVE_CXX_MAKE_UNIQUE) -# include -#endif - -namespace cm { - -#if defined(CMake_HAVE_CXX_MAKE_UNIQUE) - -using std::make_unique; - -#else - -template -std::unique_ptr make_unique(Args&&... args) -{ - return std::unique_ptr(new T(std::forward(args)...)); -} - -#endif - -} // namespace cm - -#endif diff --git a/Source/cm_optional.hxx b/Source/cm_optional.hxx deleted file mode 100644 index 295571d..0000000 --- a/Source/cm_optional.hxx +++ /dev/null @@ -1,343 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_optional_hxx -#define cm_optional_hxx - -#include "cmConfigure.h" // IWYU pragma: keep - -#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CMake_HAVE_CXX_OPTIONAL -#endif - -#if defined(CMake_HAVE_CXX_OPTIONAL) -# include -#else -# include "cm_utility.hxx" -# include -# include -#endif - -namespace cm { - -#if defined(CMake_HAVE_CXX_OPTIONAL) - -using std::nullopt_t; -using std::nullopt; -using std::optional; -using std::bad_optional_access; -using std::make_optional; - -#else - -class bad_optional_access : public std::exception -{ - using std::exception::exception; -}; - -struct nullopt_t -{ - explicit constexpr nullopt_t(int) {} -}; - -constexpr nullopt_t nullopt{ 0 }; - -template -class optional -{ -public: - using value_type = T; - - optional() noexcept = default; - optional(nullopt_t) noexcept; - optional(const optional& other); - optional(optional&& other) noexcept; - - template - explicit optional(cm::in_place_t, Args&&... args); - - template < - typename U = T, - typename = typename std::enable_if< - std::is_constructible::value && - !std::is_same::type, cm::in_place_t>::value && - !std::is_same::type, - cm::optional>::value>::type> - optional(U&& v); - - ~optional(); - - optional& operator=(nullopt_t) noexcept; - optional& operator=(const optional& other); - optional& operator=(optional&& other) noexcept; - - template < - typename U = T, - typename = typename std::enable_if< - !std::is_same::type, cm::optional>::value && - std::is_constructible::value && std::is_assignable::value && - (!std::is_scalar::value || - !std::is_same::type, T>::value)>::type> - optional& operator=(U&& v); - - const T* operator->() const; - T* operator->(); - const T& operator*() const&; - T& operator*() &; - const T&& operator*() const&&; - T&& operator*() &&; - - explicit operator bool() const noexcept; - bool has_value() const noexcept; - - T& value() &; - const T& value() const&; - - T&& value() &&; - const T&& value() const&&; - - template - T value_or(U&& default_value) const&; - - template - T value_or(U&& default_value) &&; - - void swap(optional& other) noexcept; - void reset() noexcept; - - template - T& emplace(Args&&... args); - -private: - bool _has_value = false; - std::allocator _allocator; - union _mem_union - { - T value; - - // Explicit constructor and destructor is required to make this work - _mem_union() noexcept {} - ~_mem_union() noexcept {} - } _mem; -}; - -template -optional::type> make_optional(T&& value) -{ - return optional::type>(std::forward(value)); -} - -template -optional make_optional(Args&&... args) -{ - return optional(in_place, std::forward(args)...); -} - -template -optional::optional(nullopt_t) noexcept -{ -} - -template -optional::optional(const optional& other) -{ - *this = other; -} - -template -optional::optional(optional&& other) noexcept -{ - *this = std::move(other); -} - -template -template -optional::optional(cm::in_place_t, Args&&... args) -{ - this->emplace(std::forward(args)...); -} - -template -template -optional::optional(U&& v) -{ - this->emplace(std::forward(v)); -} - -template -optional::~optional() -{ - this->reset(); -} - -template -optional& optional::operator=(nullopt_t) noexcept -{ - this->reset(); - return *this; -} - -template -optional& optional::operator=(const optional& other) -{ - if (other.has_value()) { - if (this->has_value()) { - this->value() = *other; - } else { - this->emplace(*other); - } - } else { - this->reset(); - } - return *this; -} - -template -optional& optional::operator=(optional&& other) noexcept -{ - if (other.has_value()) { - if (this->has_value()) { - this->value() = std::move(*other); - } else { - this->emplace(std::move(*other)); - } - } else { - this->reset(); - } - return *this; -} - -template -template -optional& optional::operator=(U&& v) -{ - if (this->has_value()) { - this->value() = v; - } else { - this->emplace(std::forward(v)); - } - return *this; -} - -template -const T* optional::operator->() const -{ - return &**this; -} - -template -T* optional::operator->() -{ - return &**this; -} - -template -const T& optional::operator*() const& -{ - return this->_mem.value; -} - -template -T& optional::operator*() & -{ - return this->_mem.value; -} - -template -const T&& optional::operator*() const&& -{ - return std::move(**this); -} - -template -T&& optional::operator*() && -{ - return std::move(**this); -} - -template -bool optional::has_value() const noexcept -{ - return this->_has_value; -} - -template -optional::operator bool() const noexcept -{ - return this->has_value(); -} - -template -T& optional::value() & -{ - if (!this->has_value()) { - throw cm::bad_optional_access{}; - } - return **this; -} - -template -const T& optional::value() const& -{ - if (!this->has_value()) { - throw cm::bad_optional_access{}; - } - return **this; -} - -template -template -T optional::value_or(U&& default_value) const& -{ - return bool(*this) ? **this : static_cast(std::forward(default_value)); -} - -template -template -T optional::value_or(U&& default_value) && -{ - return bool(*this) ? std::move(**this) - : static_cast(std::forward(default_value)); -} - -template -void optional::swap(optional& other) noexcept -{ - if (this->has_value()) { - if (other.has_value()) { - using std::swap; - swap(**this, *other); - } else { - other.emplace(std::move(**this)); - this->reset(); - } - } else if (other.has_value()) { - this->emplace(std::move(*other)); - other.reset(); - } -} - -template -void optional::reset() noexcept -{ - if (this->has_value()) { - this->_has_value = false; - std::allocator_traits>::destroy(this->_allocator, - &**this); - } -} - -template -template -T& optional::emplace(Args&&... args) -{ - this->reset(); - std::allocator_traits>::construct( - this->_allocator, &**this, std::forward(args)...); - this->_has_value = true; - return this->value(); -} - -#endif -} - -#endif diff --git a/Source/cm_static_string_view.hxx b/Source/cm_static_string_view.hxx index 1bef0c6..8351cd7 100644 --- a/Source/cm_static_string_view.hxx +++ b/Source/cm_static_string_view.hxx @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" +#include #include diff --git a/Source/cm_string_view.cxx b/Source/cm_string_view.cxx deleted file mode 100644 index 61fa80e..0000000 --- a/Source/cm_string_view.cxx +++ /dev/null @@ -1,301 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ - -#include "cm_string_view.hxx" - -#ifndef CMake_HAVE_CXX_STRING_VIEW - -# include "cm_kwiml.h" - -# include -# include -# include - -namespace cm { - -string_view::const_reference string_view::at(size_type pos) const -{ - if (pos >= size_) { - throw std::out_of_range("Index out of range in string_view::at"); - } - return data_[pos]; -} - -string_view::size_type string_view::copy(char* dest, size_type count, - size_type pos) const -{ - if (pos > size_) { - throw std::out_of_range("Index out of range in string_view::copy"); - } - size_type const rcount = std::min(count, size_ - pos); - traits_type::copy(dest, data_ + pos, rcount); - return rcount; -} - -string_view string_view::substr(size_type pos, size_type count) const -{ - if (pos > size_) { - throw std::out_of_range("Index out of range in string_view::substr"); - } - size_type const rcount = std::min(count, size_ - pos); - return string_view(data_ + pos, rcount); -} - -int string_view::compare(string_view v) const noexcept -{ - size_type const rlen = std::min(size_, v.size_); - int c = traits_type::compare(data_, v.data_, rlen); - if (c == 0) { - if (size_ < v.size_) { - c = -1; - } else if (size_ > v.size_) { - c = 1; - } - } - return c; -} - -int string_view::compare(size_type pos1, size_type count1, string_view v) const -{ - return substr(pos1, count1).compare(v); -} - -int string_view::compare(size_type pos1, size_type count1, string_view v, - size_type pos2, size_type count2) const -{ - return substr(pos1, count1).compare(v.substr(pos2, count2)); -} - -int string_view::compare(const char* s) const -{ - return compare(string_view(s)); -} - -int string_view::compare(size_type pos1, size_type count1, const char* s) const -{ - return substr(pos1, count1).compare(string_view(s)); -} - -int string_view::compare(size_type pos1, size_type count1, const char* s, - size_type count2) const -{ - return substr(pos1, count1).compare(string_view(s, count2)); -} - -string_view::size_type string_view::find(string_view v, size_type pos) const - noexcept -{ - for (; pos + v.size_ <= size_; ++pos) { - if (std::char_traits::compare(data_ + pos, v.data_, v.size_) == 0) { - return pos; - } - } - return npos; -} - -string_view::size_type string_view::find(char c, size_type pos) const noexcept -{ - return find(string_view(&c, 1), pos); -} - -string_view::size_type string_view::find(const char* s, size_type pos, - size_type count) const -{ - return find(string_view(s, count), pos); -} - -string_view::size_type string_view::find(const char* s, size_type pos) const -{ - return find(string_view(s), pos); -} - -string_view::size_type string_view::rfind(string_view v, size_type pos) const - noexcept -{ - if (size_ >= v.size_) { - for (pos = std::min(pos, size_ - v.size_) + 1; pos > 0;) { - --pos; - if (std::char_traits::compare(data_ + pos, v.data_, v.size_) == - 0) { - return pos; - } - } - } - return npos; -} - -string_view::size_type string_view::rfind(char c, size_type pos) const noexcept -{ - return rfind(string_view(&c, 1), pos); -} - -string_view::size_type string_view::rfind(const char* s, size_type pos, - size_type count) const -{ - return rfind(string_view(s, count), pos); -} - -string_view::size_type string_view::rfind(const char* s, size_type pos) const -{ - return rfind(string_view(s), pos); -} - -string_view::size_type string_view::find_first_of(string_view v, - size_type pos) const noexcept -{ - for (; pos < size_; ++pos) { - if (traits_type::find(v.data_, v.size_, data_[pos])) { - return pos; - } - } - return npos; -} - -string_view::size_type string_view::find_first_of(char c, size_type pos) const - noexcept -{ - return find_first_of(string_view(&c, 1), pos); -} - -string_view::size_type string_view::find_first_of(const char* s, size_type pos, - size_type count) const -{ - return find_first_of(string_view(s, count), pos); -} - -string_view::size_type string_view::find_first_of(const char* s, - size_type pos) const -{ - return find_first_of(string_view(s), pos); -} - -string_view::size_type string_view::find_last_of(string_view v, - size_type pos) const noexcept -{ - if (size_ > 0) { - for (pos = std::min(pos, size_ - 1) + 1; pos > 0;) { - --pos; - if (traits_type::find(v.data_, v.size_, data_[pos])) { - return pos; - } - } - } - return npos; -} - -string_view::size_type string_view::find_last_of(char c, size_type pos) const - noexcept -{ - return find_last_of(string_view(&c, 1), pos); -} - -string_view::size_type string_view::find_last_of(const char* s, size_type pos, - size_type count) const -{ - return find_last_of(string_view(s, count), pos); -} - -string_view::size_type string_view::find_last_of(const char* s, - size_type pos) const -{ - return find_last_of(string_view(s), pos); -} - -string_view::size_type string_view::find_first_not_of(string_view v, - size_type pos) const - noexcept -{ - for (; pos < size_; ++pos) { - if (!traits_type::find(v.data_, v.size_, data_[pos])) { - return pos; - } - } - return npos; -} - -string_view::size_type string_view::find_first_not_of(char c, - size_type pos) const - noexcept -{ - return find_first_not_of(string_view(&c, 1), pos); -} - -string_view::size_type string_view::find_first_not_of(const char* s, - size_type pos, - size_type count) const -{ - return find_first_not_of(string_view(s, count), pos); -} - -string_view::size_type string_view::find_first_not_of(const char* s, - size_type pos) const -{ - return find_first_not_of(string_view(s), pos); -} - -string_view::size_type string_view::find_last_not_of(string_view v, - size_type pos) const - noexcept -{ - if (size_ > 0) { - for (pos = std::min(pos, size_ - 1) + 1; pos > 0;) { - --pos; - if (!traits_type::find(v.data_, v.size_, data_[pos])) { - return pos; - } - } - } - return npos; -} - -string_view::size_type string_view::find_last_not_of(char c, - size_type pos) const - noexcept -{ - return find_last_not_of(string_view(&c, 1), pos); -} - -string_view::size_type string_view::find_last_not_of(const char* s, - size_type pos, - size_type count) const -{ - return find_last_not_of(string_view(s, count), pos); -} - -string_view::size_type string_view::find_last_not_of(const char* s, - size_type pos) const -{ - return find_last_not_of(string_view(s), pos); -} - -std::ostream& operator<<(std::ostream& o, string_view v) -{ - return o.write(v.data(), v.size()); -} - -std::string& operator+=(std::string& s, string_view v) -{ - s.append(v.data(), v.size()); - return s; -} -} - -std::hash::result_type std::hash::operator()( - argument_type const& s) const noexcept -{ - // FNV-1a hash. - static KWIML_INT_uint64_t const fnv_offset_basis = 0xcbf29ce484222325; - static KWIML_INT_uint64_t const fnv_prime = 0x100000001b3; - KWIML_INT_uint64_t h = fnv_offset_basis; - for (char const& c : s) { - h = h ^ KWIML_INT_uint64_t(KWIML_INT_uint8_t(c)); - h = h * fnv_prime; - } - return result_type(h); -} -#else -// Avoid empty translation unit. -void cm_string_view_cxx() -{ -} -#endif diff --git a/Source/cm_string_view.hxx b/Source/cm_string_view.hxx deleted file mode 100644 index 04de797..0000000 --- a/Source/cm_string_view.hxx +++ /dev/null @@ -1,217 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_string_view_hxx -#define cm_string_view_hxx - -#include "cmConfigure.h" // IWYU pragma: keep - -#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L -# define CMake_HAVE_CXX_STRING_VIEW -#endif - -#ifdef CMake_HAVE_CXX_STRING_VIEW -# include -namespace cm { -using std::string_view; -} -#else -# include -# include -# include -# include -# include - -namespace cm { - -class string_view -{ -public: - using traits_type = std::string::traits_type; - using value_type = char; - using pointer = char*; - using const_pointer = const char*; - using reference = char&; - using const_reference = char const&; - using const_iterator = const char*; - using iterator = const_iterator; - using const_reverse_iterator = std::reverse_iterator; - using reverse_iterator = const_reverse_iterator; - using size_type = std::string::size_type; - using difference_type = std::string::difference_type; - - static size_type const npos = static_cast(-1); - - string_view() noexcept = default; - string_view(string_view const&) noexcept = default; - - string_view(const char* s, size_t count) noexcept - : data_(s) - , size_(count) - { - } - - string_view(const char* s) noexcept - : data_(s) - , size_(traits_type::length(s)) - { - } - - // C++17 does not define this constructor. Instead it defines - // a conversion operator on std::string to create a string_view. - // Since this implementation is used in C++11, std::string does - // not have that conversion. - string_view(std::string const& s) noexcept - : data_(s.data()) - , size_(s.size()) - { - } - - // C++17 does not define this conversion. Instead it defines - // a constructor on std::string that can take a string_view. - // Since this implementation is used in C++11, std::string does - // not have that constructor. - explicit operator std::string() const { return std::string(data_, size_); } - - string_view& operator=(string_view const&) = default; - - const_iterator begin() const noexcept { return data_; } - const_iterator end() const noexcept { return data_ + size_; } - const_iterator cbegin() const noexcept { return begin(); } - const_iterator cend() const noexcept { return end(); } - - const_reverse_iterator rbegin() const noexcept - { - return const_reverse_iterator(end()); - } - const_reverse_iterator rend() const noexcept - { - return const_reverse_iterator(begin()); - } - const_reverse_iterator crbegin() const noexcept { return rbegin(); } - const_reverse_iterator crend() const noexcept { return rend(); } - - const_reference operator[](size_type pos) const noexcept - { - return data_[pos]; - } - const_reference at(size_type pos) const; - const_reference front() const noexcept { return data_[0]; } - const_reference back() const noexcept { return data_[size_ - 1]; } - const_pointer data() const noexcept { return data_; } - - size_type size() const noexcept { return size_; } - size_type length() const noexcept { return size_; } - size_type max_size() const noexcept { return npos - 1; } - bool empty() const noexcept { return size_ == 0; } - - void remove_prefix(size_type n) noexcept - { - data_ += n; - size_ -= n; - } - void remove_suffix(size_type n) noexcept { size_ -= n; } - void swap(string_view& v) noexcept - { - string_view tmp = v; - v = *this; - *this = tmp; - } - - size_type copy(char* dest, size_type count, size_type pos = 0) const; - string_view substr(size_type pos = 0, size_type count = npos) const; - - int compare(string_view v) const noexcept; - int compare(size_type pos1, size_type count1, string_view v) const; - int compare(size_type pos1, size_type count1, string_view v, size_type pos2, - size_type count2) const; - int compare(const char* s) const; - int compare(size_type pos1, size_type count1, const char* s) const; - int compare(size_type pos1, size_type count1, const char* s, - size_type count2) const; - - size_type find(string_view v, size_type pos = 0) const noexcept; - size_type find(char c, size_type pos = 0) const noexcept; - size_type find(const char* s, size_type pos, size_type count) const; - size_type find(const char* s, size_type pos = 0) const; - - size_type rfind(string_view v, size_type pos = npos) const noexcept; - size_type rfind(char c, size_type pos = npos) const noexcept; - size_type rfind(const char* s, size_type pos, size_type count) const; - size_type rfind(const char* s, size_type pos = npos) const; - - size_type find_first_of(string_view v, size_type pos = 0) const noexcept; - size_type find_first_of(char c, size_type pos = 0) const noexcept; - size_type find_first_of(const char* s, size_type pos, size_type count) const; - size_type find_first_of(const char* s, size_type pos = 0) const; - - size_type find_last_of(string_view v, size_type pos = npos) const noexcept; - size_type find_last_of(char c, size_type pos = npos) const noexcept; - size_type find_last_of(const char* s, size_type pos, size_type count) const; - size_type find_last_of(const char* s, size_type pos = npos) const; - - size_type find_first_not_of(string_view v, size_type pos = 0) const noexcept; - size_type find_first_not_of(char c, size_type pos = 0) const noexcept; - size_type find_first_not_of(const char* s, size_type pos, - size_type count) const; - size_type find_first_not_of(const char* s, size_type pos = 0) const; - - size_type find_last_not_of(string_view v, size_type pos = npos) const - noexcept; - size_type find_last_not_of(char c, size_type pos = npos) const noexcept; - size_type find_last_not_of(const char* s, size_type pos, - size_type count) const; - size_type find_last_not_of(const char* s, size_type pos = npos) const; - -private: - const char* data_ = nullptr; - size_type size_ = 0; -}; - -std::ostream& operator<<(std::ostream& o, string_view v); - -std::string& operator+=(std::string& s, string_view v); - -inline bool operator==(string_view l, string_view r) noexcept -{ - return l.compare(r) == 0; -} - -inline bool operator!=(string_view l, string_view r) noexcept -{ - return l.compare(r) != 0; -} - -inline bool operator<(string_view l, string_view r) noexcept -{ - return l.compare(r) < 0; -} - -inline bool operator<=(string_view l, string_view r) noexcept -{ - return l.compare(r) <= 0; -} - -inline bool operator>(string_view l, string_view r) noexcept -{ - return l.compare(r) > 0; -} - -inline bool operator>=(string_view l, string_view r) noexcept -{ - return l.compare(r) >= 0; -} -} - -namespace std { - -template <> -struct hash -{ - using argument_type = cm::string_view; - using result_type = size_t; - result_type operator()(argument_type const& s) const noexcept; -}; -} - -#endif -#endif diff --git a/Source/cm_sys_stat.h b/Source/cm_sys_stat.h index d3b9ef2..eb874c7 100644 --- a/Source/cm_sys_stat.h +++ b/Source/cm_sys_stat.h @@ -14,6 +14,6 @@ using gid_t = unsigned short; #include // include sys/stat.h after sys/types.h -#include +#include // IWYU pragma: export #endif diff --git a/Source/cm_thread.hxx b/Source/cm_thread.hxx deleted file mode 100644 index b1f0645..0000000 --- a/Source/cm_thread.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef CM_THREAD_HXX -#define CM_THREAD_HXX - -#include "cmConfigure.h" // IWYU pragma: keep -#include "cm_uv.h" - -namespace cm { - -class shared_mutex -{ - uv_rwlock_t _M_; - -public: - shared_mutex() { uv_rwlock_init(&_M_); } - ~shared_mutex() { uv_rwlock_destroy(&_M_); } - - shared_mutex(shared_mutex const&) = delete; - shared_mutex& operator=(shared_mutex const&) = delete; - - void lock() { uv_rwlock_wrlock(&_M_); } - void unlock() { uv_rwlock_wrunlock(&_M_); } - - void lock_shared() { uv_rwlock_rdlock(&_M_); } - void unlock_shared() { uv_rwlock_rdunlock(&_M_); } -}; - -template -class shared_lock -{ - T& _mutex; - -public: - shared_lock(T& m) - : _mutex(m) - { - _mutex.lock_shared(); - } - - ~shared_lock() { _mutex.unlock_shared(); } - - shared_lock(shared_lock const&) = delete; - shared_lock& operator=(shared_lock const&) = delete; -}; -} - -#endif diff --git a/Source/cm_utility.hxx b/Source/cm_utility.hxx deleted file mode 100644 index 99d7f8b..0000000 --- a/Source/cm_utility.hxx +++ /dev/null @@ -1,35 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_utility_hxx -#define cm_utility_hxx - -#include "cmConfigure.h" // IWYU pragma: keep - -#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CMake_HAVE_CXX_IN_PLACE -#endif - -#if defined(CMake_HAVE_CXX_IN_PLACE) -# include -#endif - -namespace cm { - -#if defined(CMake_HAVE_CXX_IN_PLACE) - -using std::in_place_t; -using std::in_place; - -#else - -struct in_place_t -{ - explicit in_place_t() = default; -}; - -constexpr in_place_t in_place{}; - -#endif -} - -#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9a66805..96d903e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2,7 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmake.h" -#include "cm_memory.hxx" +#include +#include +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) +# include +#endif + +#include "cm_sys_stat.h" #include "cmAlgorithms.h" #include "cmCommands.h" @@ -28,8 +34,6 @@ #include "cmUtils.hxx" #include "cmVersionConfig.h" #include "cmWorkingDirectory.h" -#include "cm_string_view.hxx" -#include "cm_sys_stat.h" #if !defined(CMAKE_BOOTSTRAP) # include "cm_jsoncpp_writer.h" diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx index 788fece..909f71b 100644 --- a/Tests/CMakeLib/testArgumentParser.cxx +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -4,7 +4,7 @@ #include "cmArgumentParser.h" #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx index a5e30fb..cefe9fa 100644 --- a/Tests/CMakeLib/testOptional.cxx +++ b/Tests/CMakeLib/testOptional.cxx @@ -1,9 +1,8 @@ -#include "cm_optional.hxx" -#include "cm_utility.hxx" +#include +#include #include #include -#include #include class EventLogger; diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index 075892f..3b47a9c 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -4,7 +4,7 @@ #include "cmString.hxx" #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index a92a910..4e48f6e 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -3,7 +3,8 @@ #include // IWYU pragma: keep -#include "cm_string_view.hxx" +#include + #include #include #include diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx index 63c9943..8cee49d 100644 --- a/Tests/CMakeLib/testUVProcessChain.cxx +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -15,7 +15,7 @@ #include -#include "cm_memory.hxx" +#include struct ExpectedStatus { diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index 78026fa..ef31e8b 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -95,7 +95,6 @@ { include: [ "", public, "\"cm_kwiml.h\"", public ] }, # Self-sufficient wrapper for - { include: [ "", public, "\"cm_sys_stat.h\"", public ] }, { symbol: [ "mode_t", private, "\"cm_sys_stat.h\"", public ] }, # Wrappers for 3rd-party libraries used from the system. diff --git a/Utilities/std/.gitattributes b/Utilities/std/.gitattributes new file mode 100644 index 0000000..cd20549 --- /dev/null +++ b/Utilities/std/.gitattributes @@ -0,0 +1 @@ +cm/* our-c-style diff --git a/Utilities/std/CMakeLists.txt b/Utilities/std/CMakeLists.txt new file mode 100644 index 0000000..63c0a60 --- /dev/null +++ b/Utilities/std/CMakeLists.txt @@ -0,0 +1,10 @@ + +# source files for CMake std library +set(SRCS cm/bits/string_view.cxx + cm/memory + cm/optional + cm/shared_mutex + cm/string_view + cm/utility) + +add_library(cmstd STATIC ${SRCS}) diff --git a/Utilities/std/cm/bits/string_view.cxx b/Utilities/std/cm/bits/string_view.cxx new file mode 100644 index 0000000..3b283da --- /dev/null +++ b/Utilities/std/cm/bits/string_view.cxx @@ -0,0 +1,301 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include // IWYU pragma: associated + +#ifndef CMake_HAVE_CXX_STRING_VIEW + +# include "cm_kwiml.h" + +# include +# include +# include + +namespace cm { + +string_view::const_reference string_view::at(size_type pos) const +{ + if (pos >= size_) { + throw std::out_of_range("Index out of range in string_view::at"); + } + return data_[pos]; +} + +string_view::size_type string_view::copy(char* dest, size_type count, + size_type pos) const +{ + if (pos > size_) { + throw std::out_of_range("Index out of range in string_view::copy"); + } + size_type const rcount = std::min(count, size_ - pos); + traits_type::copy(dest, data_ + pos, rcount); + return rcount; +} + +string_view string_view::substr(size_type pos, size_type count) const +{ + if (pos > size_) { + throw std::out_of_range("Index out of range in string_view::substr"); + } + size_type const rcount = std::min(count, size_ - pos); + return string_view(data_ + pos, rcount); +} + +int string_view::compare(string_view v) const noexcept +{ + size_type const rlen = std::min(size_, v.size_); + int c = traits_type::compare(data_, v.data_, rlen); + if (c == 0) { + if (size_ < v.size_) { + c = -1; + } else if (size_ > v.size_) { + c = 1; + } + } + return c; +} + +int string_view::compare(size_type pos1, size_type count1, string_view v) const +{ + return substr(pos1, count1).compare(v); +} + +int string_view::compare(size_type pos1, size_type count1, string_view v, + size_type pos2, size_type count2) const +{ + return substr(pos1, count1).compare(v.substr(pos2, count2)); +} + +int string_view::compare(const char* s) const +{ + return compare(string_view(s)); +} + +int string_view::compare(size_type pos1, size_type count1, const char* s) const +{ + return substr(pos1, count1).compare(string_view(s)); +} + +int string_view::compare(size_type pos1, size_type count1, const char* s, + size_type count2) const +{ + return substr(pos1, count1).compare(string_view(s, count2)); +} + +string_view::size_type string_view::find(string_view v, size_type pos) const + noexcept +{ + for (; pos + v.size_ <= size_; ++pos) { + if (std::char_traits::compare(data_ + pos, v.data_, v.size_) == 0) { + return pos; + } + } + return npos; +} + +string_view::size_type string_view::find(char c, size_type pos) const noexcept +{ + return find(string_view(&c, 1), pos); +} + +string_view::size_type string_view::find(const char* s, size_type pos, + size_type count) const +{ + return find(string_view(s, count), pos); +} + +string_view::size_type string_view::find(const char* s, size_type pos) const +{ + return find(string_view(s), pos); +} + +string_view::size_type string_view::rfind(string_view v, size_type pos) const + noexcept +{ + if (size_ >= v.size_) { + for (pos = std::min(pos, size_ - v.size_) + 1; pos > 0;) { + --pos; + if (std::char_traits::compare(data_ + pos, v.data_, v.size_) == + 0) { + return pos; + } + } + } + return npos; +} + +string_view::size_type string_view::rfind(char c, size_type pos) const noexcept +{ + return rfind(string_view(&c, 1), pos); +} + +string_view::size_type string_view::rfind(const char* s, size_type pos, + size_type count) const +{ + return rfind(string_view(s, count), pos); +} + +string_view::size_type string_view::rfind(const char* s, size_type pos) const +{ + return rfind(string_view(s), pos); +} + +string_view::size_type string_view::find_first_of(string_view v, + size_type pos) const noexcept +{ + for (; pos < size_; ++pos) { + if (traits_type::find(v.data_, v.size_, data_[pos])) { + return pos; + } + } + return npos; +} + +string_view::size_type string_view::find_first_of(char c, size_type pos) const + noexcept +{ + return find_first_of(string_view(&c, 1), pos); +} + +string_view::size_type string_view::find_first_of(const char* s, size_type pos, + size_type count) const +{ + return find_first_of(string_view(s, count), pos); +} + +string_view::size_type string_view::find_first_of(const char* s, + size_type pos) const +{ + return find_first_of(string_view(s), pos); +} + +string_view::size_type string_view::find_last_of(string_view v, + size_type pos) const noexcept +{ + if (size_ > 0) { + for (pos = std::min(pos, size_ - 1) + 1; pos > 0;) { + --pos; + if (traits_type::find(v.data_, v.size_, data_[pos])) { + return pos; + } + } + } + return npos; +} + +string_view::size_type string_view::find_last_of(char c, size_type pos) const + noexcept +{ + return find_last_of(string_view(&c, 1), pos); +} + +string_view::size_type string_view::find_last_of(const char* s, size_type pos, + size_type count) const +{ + return find_last_of(string_view(s, count), pos); +} + +string_view::size_type string_view::find_last_of(const char* s, + size_type pos) const +{ + return find_last_of(string_view(s), pos); +} + +string_view::size_type string_view::find_first_not_of(string_view v, + size_type pos) const + noexcept +{ + for (; pos < size_; ++pos) { + if (!traits_type::find(v.data_, v.size_, data_[pos])) { + return pos; + } + } + return npos; +} + +string_view::size_type string_view::find_first_not_of(char c, + size_type pos) const + noexcept +{ + return find_first_not_of(string_view(&c, 1), pos); +} + +string_view::size_type string_view::find_first_not_of(const char* s, + size_type pos, + size_type count) const +{ + return find_first_not_of(string_view(s, count), pos); +} + +string_view::size_type string_view::find_first_not_of(const char* s, + size_type pos) const +{ + return find_first_not_of(string_view(s), pos); +} + +string_view::size_type string_view::find_last_not_of(string_view v, + size_type pos) const + noexcept +{ + if (size_ > 0) { + for (pos = std::min(pos, size_ - 1) + 1; pos > 0;) { + --pos; + if (!traits_type::find(v.data_, v.size_, data_[pos])) { + return pos; + } + } + } + return npos; +} + +string_view::size_type string_view::find_last_not_of(char c, + size_type pos) const + noexcept +{ + return find_last_not_of(string_view(&c, 1), pos); +} + +string_view::size_type string_view::find_last_not_of(const char* s, + size_type pos, + size_type count) const +{ + return find_last_not_of(string_view(s, count), pos); +} + +string_view::size_type string_view::find_last_not_of(const char* s, + size_type pos) const +{ + return find_last_not_of(string_view(s), pos); +} + +std::ostream& operator<<(std::ostream& o, string_view v) +{ + return o.write(v.data(), v.size()); +} + +std::string& operator+=(std::string& s, string_view v) +{ + s.append(v.data(), v.size()); + return s; +} +} + +std::hash::result_type std::hash::operator()( + argument_type const& s) const noexcept +{ + // FNV-1a hash. + static KWIML_INT_uint64_t const fnv_offset_basis = 0xcbf29ce484222325; + static KWIML_INT_uint64_t const fnv_prime = 0x100000001b3; + KWIML_INT_uint64_t h = fnv_offset_basis; + for (char const& c : s) { + h = h ^ KWIML_INT_uint64_t(KWIML_INT_uint8_t(c)); + h = h * fnv_prime; + } + return result_type(h); +} +#else +// Avoid empty translation unit. +void cm_string_view_cxx() +{ +} +#endif diff --git a/Utilities/std/cm/iterator b/Utilities/std/cm/iterator new file mode 100644 index 0000000..083bce3 --- /dev/null +++ b/Utilities/std/cm/iterator @@ -0,0 +1,78 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_iterator +#define cm_iterator + +#include // IWYU pragma: export + +namespace cm { + +#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L +using std::make_reverse_iterator; + +using std::cbegin; +using std::cend; +#else +template +std::reverse_iterator make_reverse_iterator(Iter it) +{ + return std::reverse_iterator(it); +} + +// std::c{begin,end} backport from C++14 +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +auto cbegin(C const& c) +# else +constexpr auto cbegin(C const& c) noexcept(noexcept(std::begin(c))) +# endif + -> decltype(std::begin(c)) +{ + return std::begin(c); +} + +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +auto cend(C const& c) +# else +constexpr auto cend(C const& c) noexcept(noexcept(std::end(c))) +# endif + -> decltype(std::end(c)) +{ + return std::end(c); +} +#endif + +#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L +using std::size; +#else + +// std::size backport from C++17. +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + size(C const& c) -> decltype(c.size()) +{ + return c.size(); +} + +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + std::size_t + size(const T (&)[N]) throw() +{ + return N; +} + +#endif + +} // namespace cm + +#endif diff --git a/Utilities/std/cm/memory b/Utilities/std/cm/memory new file mode 100644 index 0000000..8ebded2 --- /dev/null +++ b/Utilities/std/cm/memory @@ -0,0 +1,32 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_memory +#define cm_memory + +#include // IWYU pragma: export +#if !defined(CMake_HAVE_CXX_MAKE_UNIQUE) +# include +#endif + +namespace cm { + +#if defined(CMake_HAVE_CXX_MAKE_UNIQUE) + +using std::make_unique; + +#else + +template +std::unique_ptr make_unique(Args&&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} + +#endif + +} // namespace cm + +#endif diff --git a/Utilities/std/cm/optional b/Utilities/std/cm/optional new file mode 100644 index 0000000..80b0951 --- /dev/null +++ b/Utilities/std/cm/optional @@ -0,0 +1,344 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_optional +#define cm_optional + +#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CMake_HAVE_CXX_OPTIONAL +#endif + +#if defined(CMake_HAVE_CXX_OPTIONAL) +# include // IWYU pragma: export +#else +# include + +# include +#endif + +namespace cm { + +#if defined(CMake_HAVE_CXX_OPTIONAL) + +using std::nullopt_t; +using std::nullopt; +using std::optional; +using std::bad_optional_access; +using std::make_optional; + +#else + +class bad_optional_access : public std::exception +{ + using std::exception::exception; +}; + +struct nullopt_t +{ + explicit constexpr nullopt_t(int) {} +}; + +constexpr nullopt_t nullopt{ 0 }; + +template +class optional +{ +public: + using value_type = T; + + optional() noexcept = default; + optional(nullopt_t) noexcept; + optional(const optional& other); + optional(optional&& other) noexcept; + + template + explicit optional(cm::in_place_t, Args&&... args); + + template < + typename U = T, + typename = typename std::enable_if< + std::is_constructible::value && + !std::is_same::type, cm::in_place_t>::value && + !std::is_same::type, + cm::optional>::value>::type> + optional(U&& v); + + ~optional(); + + optional& operator=(nullopt_t) noexcept; + optional& operator=(const optional& other); + optional& operator=(optional&& other) noexcept; + + template < + typename U = T, + typename = typename std::enable_if< + !std::is_same::type, cm::optional>::value && + std::is_constructible::value && std::is_assignable::value && + (!std::is_scalar::value || + !std::is_same::type, T>::value)>::type> + optional& operator=(U&& v); + + const T* operator->() const; + T* operator->(); + const T& operator*() const&; + T& operator*() &; + const T&& operator*() const&&; + T&& operator*() &&; + + explicit operator bool() const noexcept; + bool has_value() const noexcept; + + T& value() &; + const T& value() const&; + + T&& value() &&; + const T&& value() const&&; + + template + T value_or(U&& default_value) const&; + + template + T value_or(U&& default_value) &&; + + void swap(optional& other) noexcept; + void reset() noexcept; + + template + T& emplace(Args&&... args); + +private: + bool _has_value = false; + std::allocator _allocator; + union _mem_union + { + T value; + + // Explicit constructor and destructor is required to make this work + _mem_union() noexcept {} + ~_mem_union() noexcept {} + } _mem; +}; + +template +optional::type> make_optional(T&& value) +{ + return optional::type>(std::forward(value)); +} + +template +optional make_optional(Args&&... args) +{ + return optional(in_place, std::forward(args)...); +} + +template +optional::optional(nullopt_t) noexcept +{ +} + +template +optional::optional(const optional& other) +{ + *this = other; +} + +template +optional::optional(optional&& other) noexcept +{ + *this = std::move(other); +} + +template +template +optional::optional(cm::in_place_t, Args&&... args) +{ + this->emplace(std::forward(args)...); +} + +template +template +optional::optional(U&& v) +{ + this->emplace(std::forward(v)); +} + +template +optional::~optional() +{ + this->reset(); +} + +template +optional& optional::operator=(nullopt_t) noexcept +{ + this->reset(); + return *this; +} + +template +optional& optional::operator=(const optional& other) +{ + if (other.has_value()) { + if (this->has_value()) { + this->value() = *other; + } else { + this->emplace(*other); + } + } else { + this->reset(); + } + return *this; +} + +template +optional& optional::operator=(optional&& other) noexcept +{ + if (other.has_value()) { + if (this->has_value()) { + this->value() = std::move(*other); + } else { + this->emplace(std::move(*other)); + } + } else { + this->reset(); + } + return *this; +} + +template +template +optional& optional::operator=(U&& v) +{ + if (this->has_value()) { + this->value() = v; + } else { + this->emplace(std::forward(v)); + } + return *this; +} + +template +const T* optional::operator->() const +{ + return &**this; +} + +template +T* optional::operator->() +{ + return &**this; +} + +template +const T& optional::operator*() const& +{ + return this->_mem.value; +} + +template +T& optional::operator*() & +{ + return this->_mem.value; +} + +template +const T&& optional::operator*() const&& +{ + return std::move(**this); +} + +template +T&& optional::operator*() && +{ + return std::move(**this); +} + +template +bool optional::has_value() const noexcept +{ + return this->_has_value; +} + +template +optional::operator bool() const noexcept +{ + return this->has_value(); +} + +template +T& optional::value() & +{ + if (!this->has_value()) { + throw cm::bad_optional_access{}; + } + return **this; +} + +template +const T& optional::value() const& +{ + if (!this->has_value()) { + throw cm::bad_optional_access{}; + } + return **this; +} + +template +template +T optional::value_or(U&& default_value) const& +{ + return bool(*this) ? **this : static_cast(std::forward(default_value)); +} + +template +template +T optional::value_or(U&& default_value) && +{ + return bool(*this) ? std::move(**this) + : static_cast(std::forward(default_value)); +} + +template +void optional::swap(optional& other) noexcept +{ + if (this->has_value()) { + if (other.has_value()) { + using std::swap; + swap(**this, *other); + } else { + other.emplace(std::move(**this)); + this->reset(); + } + } else if (other.has_value()) { + this->emplace(std::move(*other)); + other.reset(); + } +} + +template +void optional::reset() noexcept +{ + if (this->has_value()) { + this->_has_value = false; + std::allocator_traits>::destroy(this->_allocator, + &**this); + } +} + +template +template +T& optional::emplace(Args&&... args) +{ + this->reset(); + std::allocator_traits>::construct( + this->_allocator, &**this, std::forward(args)...); + this->_has_value = true; + return this->value(); +} + +#endif +} + +#endif diff --git a/Utilities/std/cm/shared_mutex b/Utilities/std/cm/shared_mutex new file mode 100644 index 0000000..2ac9447 --- /dev/null +++ b/Utilities/std/cm/shared_mutex @@ -0,0 +1,76 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_shared_mutex +#define cm_shared_mutex + +#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L +# define CMake_HAVE_CXX_SHARED_LOCK +#endif +#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L +# define CMake_HAVE_CXX_SHARED_MUTEX +#endif + +#if defined(CMake_HAVE_CXX_SHARED_LOCK) +# include // IWYU pragma: export +#endif +#if !defined(CMake_HAVE_CXX_SHARED_MUTEX) +# include "cm_uv.h" +#endif + +namespace cm { +#if defined(CMake_HAVE_CXX_SHARED_MUTEX) +using std::shared_mutex; +#else +class shared_mutex +{ + uv_rwlock_t _M_; + +public: + using native_handle_type = uv_rwlock_t*; + + shared_mutex() { uv_rwlock_init(&_M_); } + ~shared_mutex() { uv_rwlock_destroy(&_M_); } + + shared_mutex(shared_mutex const&) = delete; + shared_mutex& operator=(shared_mutex const&) = delete; + + void lock() { uv_rwlock_wrlock(&_M_); } + bool try_lock() { return uv_rwlock_trywrlock(&_M_) == 0; } + void unlock() { uv_rwlock_wrunlock(&_M_); } + + void lock_shared() { uv_rwlock_rdlock(&_M_); } + void unlock_shared() { uv_rwlock_rdunlock(&_M_); } + + native_handle_type native_handle() { return &_M_; } +}; +#endif + +#if defined(CMake_HAVE_CXX_SHARED_LOCK) +using std::shared_lock; +#else +template +class shared_lock +{ + T& _mutex; + +public: + using mutex_type = T; + + shared_lock(T& m) + : _mutex(m) + { + _mutex.lock_shared(); + } + + ~shared_lock() { _mutex.unlock_shared(); } + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; +}; +#endif +} + +#endif diff --git a/Utilities/std/cm/string_view b/Utilities/std/cm/string_view new file mode 100644 index 0000000..4d359cb --- /dev/null +++ b/Utilities/std/cm/string_view @@ -0,0 +1,218 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_string_view +#define cm_string_view + +#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L +# define CMake_HAVE_CXX_STRING_VIEW +#endif + +#ifdef CMake_HAVE_CXX_STRING_VIEW +# include // IWYU pragma: export +namespace cm { +using std::string_view; +} +#else +# include +# include +# include +# include +# include + +namespace cm { + +class string_view +{ +public: + using traits_type = std::string::traits_type; + using value_type = char; + using pointer = char*; + using const_pointer = const char*; + using reference = char&; + using const_reference = char const&; + using const_iterator = const char*; + using iterator = const_iterator; + using const_reverse_iterator = std::reverse_iterator; + using reverse_iterator = const_reverse_iterator; + using size_type = std::string::size_type; + using difference_type = std::string::difference_type; + + static size_type const npos = static_cast(-1); + + string_view() noexcept = default; + string_view(string_view const&) noexcept = default; + + string_view(const char* s, size_t count) noexcept + : data_(s) + , size_(count) + { + } + + string_view(const char* s) noexcept + : data_(s) + , size_(traits_type::length(s)) + { + } + + // C++17 does not define this constructor. Instead it defines + // a conversion operator on std::string to create a string_view. + // Since this implementation is used in C++11, std::string does + // not have that conversion. + string_view(std::string const& s) noexcept + : data_(s.data()) + , size_(s.size()) + { + } + + // C++17 does not define this conversion. Instead it defines + // a constructor on std::string that can take a string_view. + // Since this implementation is used in C++11, std::string does + // not have that constructor. + explicit operator std::string() const { return std::string(data_, size_); } + + string_view& operator=(string_view const&) = default; + + const_iterator begin() const noexcept { return data_; } + const_iterator end() const noexcept { return data_ + size_; } + const_iterator cbegin() const noexcept { return begin(); } + const_iterator cend() const noexcept { return end(); } + + const_reverse_iterator rbegin() const noexcept + { + return const_reverse_iterator(end()); + } + const_reverse_iterator rend() const noexcept + { + return const_reverse_iterator(begin()); + } + const_reverse_iterator crbegin() const noexcept { return rbegin(); } + const_reverse_iterator crend() const noexcept { return rend(); } + + const_reference operator[](size_type pos) const noexcept + { + return data_[pos]; + } + const_reference at(size_type pos) const; + const_reference front() const noexcept { return data_[0]; } + const_reference back() const noexcept { return data_[size_ - 1]; } + const_pointer data() const noexcept { return data_; } + + size_type size() const noexcept { return size_; } + size_type length() const noexcept { return size_; } + size_type max_size() const noexcept { return npos - 1; } + bool empty() const noexcept { return size_ == 0; } + + void remove_prefix(size_type n) noexcept + { + data_ += n; + size_ -= n; + } + void remove_suffix(size_type n) noexcept { size_ -= n; } + void swap(string_view& v) noexcept + { + string_view tmp = v; + v = *this; + *this = tmp; + } + + size_type copy(char* dest, size_type count, size_type pos = 0) const; + string_view substr(size_type pos = 0, size_type count = npos) const; + + int compare(string_view v) const noexcept; + int compare(size_type pos1, size_type count1, string_view v) const; + int compare(size_type pos1, size_type count1, string_view v, size_type pos2, + size_type count2) const; + int compare(const char* s) const; + int compare(size_type pos1, size_type count1, const char* s) const; + int compare(size_type pos1, size_type count1, const char* s, + size_type count2) const; + + size_type find(string_view v, size_type pos = 0) const noexcept; + size_type find(char c, size_type pos = 0) const noexcept; + size_type find(const char* s, size_type pos, size_type count) const; + size_type find(const char* s, size_type pos = 0) const; + + size_type rfind(string_view v, size_type pos = npos) const noexcept; + size_type rfind(char c, size_type pos = npos) const noexcept; + size_type rfind(const char* s, size_type pos, size_type count) const; + size_type rfind(const char* s, size_type pos = npos) const; + + size_type find_first_of(string_view v, size_type pos = 0) const noexcept; + size_type find_first_of(char c, size_type pos = 0) const noexcept; + size_type find_first_of(const char* s, size_type pos, size_type count) const; + size_type find_first_of(const char* s, size_type pos = 0) const; + + size_type find_last_of(string_view v, size_type pos = npos) const noexcept; + size_type find_last_of(char c, size_type pos = npos) const noexcept; + size_type find_last_of(const char* s, size_type pos, size_type count) const; + size_type find_last_of(const char* s, size_type pos = npos) const; + + size_type find_first_not_of(string_view v, size_type pos = 0) const noexcept; + size_type find_first_not_of(char c, size_type pos = 0) const noexcept; + size_type find_first_not_of(const char* s, size_type pos, + size_type count) const; + size_type find_first_not_of(const char* s, size_type pos = 0) const; + + size_type find_last_not_of(string_view v, size_type pos = npos) const + noexcept; + size_type find_last_not_of(char c, size_type pos = npos) const noexcept; + size_type find_last_not_of(const char* s, size_type pos, + size_type count) const; + size_type find_last_not_of(const char* s, size_type pos = npos) const; + +private: + const char* data_ = nullptr; + size_type size_ = 0; +}; + +std::ostream& operator<<(std::ostream& o, string_view v); + +std::string& operator+=(std::string& s, string_view v); + +inline bool operator==(string_view l, string_view r) noexcept +{ + return l.compare(r) == 0; +} + +inline bool operator!=(string_view l, string_view r) noexcept +{ + return l.compare(r) != 0; +} + +inline bool operator<(string_view l, string_view r) noexcept +{ + return l.compare(r) < 0; +} + +inline bool operator<=(string_view l, string_view r) noexcept +{ + return l.compare(r) <= 0; +} + +inline bool operator>(string_view l, string_view r) noexcept +{ + return l.compare(r) > 0; +} + +inline bool operator>=(string_view l, string_view r) noexcept +{ + return l.compare(r) >= 0; +} +} + +namespace std { + +template <> +struct hash +{ + using argument_type = cm::string_view; + using result_type = size_t; + result_type operator()(argument_type const& s) const noexcept; +}; +} + +#endif +#endif diff --git a/Utilities/std/cm/utility b/Utilities/std/cm/utility new file mode 100644 index 0000000..3acac4f --- /dev/null +++ b/Utilities/std/cm/utility @@ -0,0 +1,34 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_utility +#define cm_utility + +#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CMake_HAVE_CXX_IN_PLACE +#endif + +#include // IWYU pragma: export + +namespace cm { + +#if defined(CMake_HAVE_CXX_IN_PLACE) + +using std::in_place_t; +using std::in_place; + +#else + +struct in_place_t +{ + explicit in_place_t() = default; +}; + +constexpr in_place_t in_place{}; + +#endif +} + +#endif diff --git a/bootstrap b/bootstrap index 9504250..123e256 100755 --- a/bootstrap +++ b/bootstrap @@ -453,7 +453,6 @@ CMAKE_CXX_SOURCES="\ cmake \ cmakemain \ cmcmd \ - cm_string_view \ " if ${cmake_system_mingw}; then @@ -464,6 +463,17 @@ if ${cmake_system_mingw}; then " fi +CMAKE_STD_CXX_HEADERS="\ + memory \ + optional \ + shared_mutex \ + string_view \ + utility \ +" +CMAKE_STD_CXX_SOURCES="\ + string_view \ +" + LexerParser_CXX_SOURCES="\ cmCommandArgumentLexer \ cmCommandArgumentParser \ @@ -1346,6 +1356,8 @@ cmake_compiler_settings_comment="/* * * Sources: * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} + * STD Sources: + * ${CMAKE_STD_CXX_HEADERS} ${CMAKE_STD_CXX_SOURCES} * LexerParser Sources: * ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} * kwSys Sources: @@ -1412,9 +1424,12 @@ done cmake_generate_file "${cmake_bootstrap_dir}/cmThirdParty.h" "" # Generate Makefile -dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" +dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.hxx `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" +for h in ${CMAKE_STD_CXX_HEADERS}; do + dep="${dep} `cmake_escape \"${cmake_source_dir}\"`/Utilities/std/cm/${h}" +done objs="" -for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do +for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${CMAKE_STD_CXX_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do objs="${objs} ${a}.o" done for a in ${LIBUV_C_SOURCES}; do @@ -1498,6 +1513,7 @@ cmake_cxx_flags="${cmake_cxx_flags} \ -I`cmake_escape \"${cmake_bootstrap_dir}\"` \ -I`cmake_escape \"${cmake_source_dir}/Source\"` \ -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \ + -I`cmake_escape \"${cmake_source_dir}/Utilities/std\"` \ -I`cmake_escape \"${cmake_source_dir}/Utilities\"`" echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} ${libs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile" @@ -1512,6 +1528,12 @@ for a in ${CMAKE_C_SOURCES}; do echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done +for a in ${CMAKE_STD_CXX_SOURCES}; do + src=`cmake_escape "${cmake_source_dir}/Utilities/std/cm/bits/${a}.cxx"` + src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` + echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" +done for a in ${LexerParser_CXX_SOURCES}; do src=`cmake_escape "${cmake_source_dir}/Source/LexerParser/${a}.cxx"` src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` -- cgit v0.12