From 72e8e1c76e1bc034a53da9e71c41eb2a1163f640 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 31 Jul 2018 17:44:47 -0700 Subject: [PATCH] common/str_list: get_str_set(), add second param for template Signed-off-by: Yehuda Sadeh --- src/common/str_list.cc | 7 ------- src/include/str_list.h | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/common/str_list.cc b/src/common/str_list.cc index 33a1157d134..2c6a397d2e7 100644 --- a/src/common/str_list.cc +++ b/src/common/str_list.cc @@ -75,10 +75,3 @@ void get_str_set(const string& str, set& str_set) const char *delims = ";,= \t"; get_str_set(str, delims, str_set); } - -set get_str_set(const string& str, const char *delims) -{ - set result; - get_str_set(str, delims, result); - return result; -} diff --git a/src/include/str_list.h b/src/include/str_list.h index e4cd7bbbd31..518db1cac71 100644 --- a/src/include/str_list.h +++ b/src/include/str_list.h @@ -86,13 +86,22 @@ extern void get_str_set(const std::string& str, * @param [in] delims characters used to split **str** * @param [out] str_list Set modified containing str after it has been split **/ -extern void get_str_set(const std::string& str, - const char *delims, - std::set& str_list); +template > +void get_str_set(const std::string& str, + const char *delims, + std::set& str_list) +{ + str_list.clear(); + for_each_substr(str, delims, [&str_list] (auto token) { + str_list.emplace(token.begin(), token.end()); + }); +} std::set get_str_set(const std::string& str, const char *delims = ";,= \t"); + + /** * Return a String containing the vector **v** joined with **sep** *