diff options
author | Brad King <brad.king@kitware.com> | 2015-01-12 14:41:02 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-01-12 14:41:02 (GMT) |
commit | dd6c596c12070c0fdc71cb11ac154e99111fb6e0 (patch) | |
tree | 27fc1aa3fb5d409e619f590ede5fee3bf477f925 /Source/cmStandardIncludes.h | |
parent | d9a6ea4599eb3b736b4e695a9ffd5d8a51eac059 (diff) | |
parent | 55a73e6b1f70b3c8a783b130dff4c4689cea5ba2 (diff) | |
download | CMake-dd6c596c12070c0fdc71cb11ac154e99111fb6e0.zip CMake-dd6c596c12070c0fdc71cb11ac154e99111fb6e0.tar.gz CMake-dd6c596c12070c0fdc71cb11ac154e99111fb6e0.tar.bz2 |
Merge topic 'join-algorithm'
55a73e6b Use the cmJoin algorithm where possible.
8dc8d756 cmStandardIncludes: Add a join algorithm for string containers.
b5813cee cmInstallCommand: Remove unused variable.
Diffstat (limited to 'Source/cmStandardIncludes.h')
-rw-r--r-- | Source/cmStandardIncludes.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index f50771f..2d988c9 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -143,6 +143,33 @@ static thisClass* SafeDownCast(cmObject *c) \ } \ class cmTypeMacro_UseTrailingSemicolon +template<typename Range> +std::string cmJoin(Range const& r, const char* delimiter) +{ + if (r.empty()) + { + return std::string(); + } + std::ostringstream os; + typedef typename Range::value_type ValueType; + typedef typename Range::const_iterator InputIt; + InputIt first = r.begin(); + InputIt last = r.end(); + --last; + std::copy(first, last, + std::ostream_iterator<ValueType>(os, delimiter)); + + os << *last; + + return os.str(); +} + +template<typename Range> +std::string cmJoin(Range const& r, std::string delimiter) +{ + return cmJoin(r, delimiter.c_str()); +}; + inline bool cmHasLiteralPrefixImpl(const std::string &str1, const char *str2, size_t N) |