diff --git a/src/stringTools.h b/src/stringTools.h index a53e0a7..0bca142 100644 --- a/src/stringTools.h +++ b/src/stringTools.h @@ -2,6 +2,7 @@ #include #include +#include std::vector splitIntoLines(const std::string& s); @@ -15,4 +16,16 @@ boost::optional toASCII(char32_t ch); std::string toASCII(const std::u32string& s); -std::u32string utf8ToUtf32(const std::string& s); \ No newline at end of file +std::u32string utf8ToUtf32(const std::string& s); + +template +std::string join(T range, const std::string separator) { + std::string result; + bool isFirst = true; + for (const auto& element : range) { + if (!isFirst) result.append(separator); + isFirst = false; + result.append(boost::lexical_cast(element)); + } + return result; +}