diff options
39 files changed, 116 insertions, 78 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 63c2fcc7fe..c66c87acc0 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -3,12 +3,12 @@ #include "cmCTestMultiProcessHandler.h" #include "cmAffinity.h" -#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestRunTest.h" #include "cmCTestTestHandler.h" #include "cmDuration.h" #include "cmListFileCache.h" +#include "cmRange.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index ac4753c87b..0d6670af64 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -2,10 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestP4.h" -#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" +#include "cmRange.h" #include "cmSystemTools.h" #include "cmsys/RegularExpression.hxx" diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index 102380862f..4956a471c2 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -4,9 +4,9 @@ #include <sstream> -#include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmTarget.h" class cmExecutionStatus; diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index c47092abd4..7947188a58 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -5,8 +5,8 @@ #include <sstream> #include <string.h> -#include "cmAlgorithms.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmSystemTools.h" class cmExecutionStatus; diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 1c4160b1d5..2ff1ed0408 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmRange.h" + #include "cm_kwiml.h" #include <algorithm> #include <functional> @@ -156,69 +158,12 @@ private: }; } -template <typename const_iterator_> -struct cmRange -{ - typedef const_iterator_ const_iterator; - typedef typename std::iterator_traits<const_iterator>::value_type value_type; - typedef typename std::iterator_traits<const_iterator>::difference_type - difference_type; - cmRange(const_iterator begin_, const_iterator end_) - : Begin(begin_) - , End(end_) - { - } - const_iterator begin() const { return Begin; } - const_iterator end() const { return End; } - bool empty() const { return std::distance(Begin, End) == 0; } - difference_type size() const { return std::distance(Begin, End); } - - cmRange& advance(KWIML_INT_intptr_t amount) & - { - std::advance(this->Begin, amount); - return *this; - } - cmRange advance(KWIML_INT_intptr_t amount) && - { - std::advance(this->Begin, amount); - return std::move(*this); - } - - cmRange& retreat(KWIML_INT_intptr_t amount) & - { - std::advance(End, -amount); - return *this; - } - - cmRange retreat(KWIML_INT_intptr_t amount) && - { - std::advance(End, -amount); - return std::move(*this); - } - -private: - const_iterator Begin; - const_iterator End; -}; - typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange; class cmListFileBacktrace; typedef cmRange<std::vector<cmListFileBacktrace>::const_iterator> cmBacktraceRange; -template <typename Iter1, typename Iter2> -cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end) -{ - return cmRange<Iter1>(begin, end); -} - -template <typename Range> -cmRange<typename Range::const_iterator> cmMakeRange(Range const& range) -{ - return cmRange<typename Range::const_iterator>(range.begin(), range.end()); -} - template <typename Range> void cmDeleteAll(Range const& r) { @@ -334,14 +279,6 @@ 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 <typename Range> -cmRange<typename Range::const_reverse_iterator> cmReverseRange( - Range const& range) -{ - return cmRange<typename Range::const_reverse_iterator>(range.rbegin(), - range.rend()); -} - template <class Iter> std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it) { diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 5ed6c29b7b..186deb60cc 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -9,6 +9,7 @@ #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 70d167553a..01d4c07e02 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmComputeTargetDepends.h" -#include "cmAlgorithms.h" #include "cmComputeComponentGraph.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -12,6 +11,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmState.h" #include "cmStateTypes.h" diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 9e90547b4c..93ff8f4d54 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -13,6 +13,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmStateTypes.h" #include "cmSystemTools.h" diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 1b509efcd8..89629c7686 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -4,9 +4,9 @@ #include <stddef.h> -#include "cmAlgorithms.h" #include "cmCustomCommandLines.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSystemTools.h" diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 96c9e15127..59ef48d99a 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -34,6 +34,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmSystemTools.h" #include "cmTimestamp.h" #include "cm_sys_stat.h" diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index f92f66e239..2e5e29cf3f 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -9,6 +9,7 @@ #include "cmAlgorithms.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmSearchPath.h" #include "cmState.h" #include "cmStateTypes.h" diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 0d22ed8e77..7ebd211621 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -23,6 +23,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmSearchPath.h" #include "cmState.h" #include "cmStateTypes.h" diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 39430d0c13..08003eb71d 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -11,6 +11,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmSystemTools.h" cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf) diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 264a3385cb..9d75b721c3 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -8,6 +8,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmState.h" // define the class for function commands diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6f5e9bd293..c73286c812 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -28,6 +28,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPropertyMap.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" #include "cmState.h" diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fa0ffcc611..ede5713b26 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -35,6 +35,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmState.h" #include "cmStateDirectory.h" diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 31bcacfe3b..d9a9d9b11b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -26,6 +26,7 @@ #include "cmMessageType.h" #include "cmNinjaLinkLineComputer.h" #include "cmOutputConverter.h" +#include "cmRange.h" #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 647c786e2b..c64bd8a64d 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallCommandArguments.h" -#include "cmAlgorithms.h" +#include "cmRange.h" #include "cmSystemTools.h" #include <utility> diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 1b72ce6289..b068e46c7a 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -2,12 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallFilesCommand.h" -#include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmInstallFilesGenerator.h" #include "cmInstallGenerator.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmSystemTools.h" class cmExecutionStatus; diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 297babfd8e..9322746b22 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -19,6 +19,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmStringReplaceHelper.h" #include "cmSystemTools.h" diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 7eb4a03d57..765fa30be0 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -22,6 +22,7 @@ #include "cmMakefile.h" #include "cmMakefileTargetGenerator.h" #include "cmOutputConverter.h" +#include "cmRange.h" #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 7279d5fcf8..6565f02602 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -10,6 +10,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmState.h" #include "cmSystemTools.h" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 560181f7a2..2e4d10624c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -31,6 +31,7 @@ #include "cmInstallSubdirectoryGenerator.h" #include "cmListFileCache.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" #include "cmState.h" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cb595fdb4b..340e405705 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -21,6 +21,7 @@ #include "cmMakefileLibraryTargetGenerator.h" #include "cmMakefileUtilityTargetGenerator.h" #include "cmOutputConverter.h" +#include "cmRange.h" #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 1a21ae41bb..2724030c24 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -6,6 +6,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmMessenger.h" +#include "cmRange.h" #include "cmSystemTools.h" class cmExecutionStatus; diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 6231aab03e..ab8d1039b3 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -10,6 +10,7 @@ #include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmSystemTools.h" class cmExecutionStatus; diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index 8b42119437..9a764c6780 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQTWrapCPPCommand.h" -#include "cmAlgorithms.h" #include "cmCustomCommandLines.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSystemTools.h" diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index 6a620c11c5..2223e2d825 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQTWrapUICommand.h" -#include "cmAlgorithms.h" #include "cmCustomCommandLines.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSystemTools.h" diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 55204d708e..5917e27337 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -3,6 +3,7 @@ #include "cmRST.h" #include "cmAlgorithms.h" +#include "cmRange.h" #include "cmSystemTools.h" #include "cmVersion.h" diff --git a/Source/cmRange.h b/Source/cmRange.h new file mode 100644 index 0000000000..5a2f699b59 --- /dev/null +++ b/Source/cmRange.h @@ -0,0 +1,77 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmRange_h +#define cmRange_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include "cm_kwiml.h" +#include <algorithm> +#include <iterator> + +template <typename const_iterator_> +struct cmRange +{ + typedef const_iterator_ const_iterator; + typedef typename std::iterator_traits<const_iterator>::value_type value_type; + typedef typename std::iterator_traits<const_iterator>::difference_type + difference_type; + cmRange(const_iterator begin_, const_iterator end_) + : Begin(begin_) + , End(end_) + { + } + const_iterator begin() const { return Begin; } + const_iterator end() const { return End; } + bool empty() const { return std::distance(Begin, End) == 0; } + difference_type size() const { return std::distance(Begin, End); } + + cmRange& advance(KWIML_INT_intptr_t amount) & + { + std::advance(this->Begin, amount); + return *this; + } + cmRange advance(KWIML_INT_intptr_t amount) && + { + std::advance(this->Begin, amount); + return std::move(*this); + } + + cmRange& retreat(KWIML_INT_intptr_t amount) & + { + std::advance(End, -amount); + return *this; + } + + cmRange retreat(KWIML_INT_intptr_t amount) && + { + std::advance(End, -amount); + return std::move(*this); + } + +private: + const_iterator Begin; + const_iterator End; +}; + +template <typename Iter1, typename Iter2> +cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end) +{ + return cmRange<Iter1>(begin, end); +} + +template <typename Range> +cmRange<typename Range::const_iterator> cmMakeRange(Range const& range) +{ + return cmRange<typename Range::const_iterator>(range.begin(), range.end()); +} + +template <typename Range> +cmRange<typename Range::const_reverse_iterator> cmReverseRange( + Range const& range) +{ + return cmRange<typename Range::const_reverse_iterator>(range.rbegin(), + range.rend()); +} + +#endif diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 6bd071cfb1..41555e8e3a 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -5,6 +5,7 @@ #include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmSystemTools.h" diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 2a0ccb410a..0d8f1cc0bf 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -4,11 +4,11 @@ #include <sstream> -#include "cmAlgorithms.h" #include "cmGlobalGenerator.h" #include "cmInstalledFile.h" #include "cmMakefile.h" #include "cmProperty.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmState.h" #include "cmSystemTools.h" diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 15c8a613a1..31273ccd90 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -11,6 +11,7 @@ #include "cmAlgorithms.h" #include "cmProperty.h" #include "cmPropertyMap.h" +#include "cmRange.h" #include "cmState.h" #include "cmStatePrivate.h" #include "cmStateTypes.h" diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 44ba82a2d7..252d9859dd 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -13,6 +13,7 @@ #include "cmCryptoHash.h" #include "cmGeneratorExpression.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmStringReplaceHelper.h" #include "cmSystemTools.h" #include "cmTimestamp.h" diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index f0e8077e7f..254644a17f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -5,6 +5,7 @@ #include "cmAlgorithms.h" #include "cmDuration.h" #include "cmProcessOutput.h" +#include "cmRange.h" #include "cm_sys_stat.h" #include "cm_uv.h" diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d1e4f06702..46f930a2d1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -21,6 +21,7 @@ #include "cmMessageType.h" #include "cmMessenger.h" #include "cmProperty.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" #include "cmSourceFileLocationKind.h" diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index a0e309da37..571cd09094 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -5,7 +5,6 @@ #include <ostream> #include <utility> -#include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmListFileCache.h" @@ -13,6 +12,7 @@ #include "cmOutputConverter.h" #include "cmProperty.h" #include "cmPropertyMap.h" +#include "cmRange.h" #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTest.h" diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index d863339666..3a2cd7f16c 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -5,10 +5,10 @@ #include "cmsys/FStream.hxx" #include <stdio.h> -#include "cmAlgorithms.h" #include "cmDuration.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmSystemTools.h" diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index adfce37441..1f238d61c3 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -9,6 +9,7 @@ #include "cmMakefile.h" #include "cmQtAutoGeneratorMocUic.h" #include "cmQtAutoGeneratorRcc.h" +#include "cmRange.h" #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" |