diff options
Diffstat (limited to 'include/cru/base/StringUtil.h')
| -rw-r--r-- | include/cru/base/StringUtil.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/cru/base/StringUtil.h b/include/cru/base/StringUtil.h index 5c1c4be7..d3afda1d 100644 --- a/include/cru/base/StringUtil.h +++ b/include/cru/base/StringUtil.h @@ -39,6 +39,22 @@ struct SplitOptions { static constexpr SplitOption RemoveSpace = SplitOption::FromOffset(2); }; +template <typename R> +std::string Join(std::string_view sep, const R& range) { + bool start = true; + std::string result; + for (const auto& s : range) { + if (start) { + result += s; + start = false; + } else { + result += sep; + result += s; + } + } + return result; +} + std::vector<std::string> CRU_BASE_API Split(std::string_view str, std::string_view sep, SplitOption options = {}); |
