From 3058e15460a32138b4b557c47c466f5b267ce3a1 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Wed, 17 Jan 2018 17:51:58 -0800 Subject: [PATCH] StringJoin can take a separator. --- src/utils.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utils.h b/src/utils.h index d5fc55be..e02e18c6 100644 --- a/src/utils.h +++ b/src/utils.h @@ -49,12 +49,14 @@ std::vector SplitString(const std::string& str, std::string LowerPathIfCaseInsensitive(const std::string& path); template -std::string StringJoinMap(const TValues& values, const TMap& map) { +std::string StringJoinMap(const TValues& values, + const TMap& map, + const std::string& sep = ", ") { std::string result; bool first = true; for (auto& entry : values) { if (!first) - result += ", "; + result += sep; first = false; result += map(entry); } @@ -62,8 +64,9 @@ std::string StringJoinMap(const TValues& values, const TMap& map) { } template -std::string StringJoin(const TValues& values) { - return StringJoinMap(values, [](const std::string& entry) { return entry; }); +std::string StringJoin(const TValues& values, const std::string& sep = ", ") { + return StringJoinMap(values, [](const std::string& entry) { return entry; }, + sep); } template