[Feature] Joins set elements to string
[Cause] N/A
[Solution] Similar to join of vector
[Verification] Build, install, run tests.
Change-Id: I7ed488bde84ba6705351ffe26d03c82812fb0eaa
#include <string>
#include <vector>
+#include <set>
#include <sstream>
namespace utils {
return res.str();
}
+template<typename T>
+std::string join(const std::set<T>& vec, const char *delim)
+{
+ std::stringstream res;
+ for (const auto& s : vec) {
+ if (res.tellp()>0) {
+ res << delim;
+ }
+ res << s;
+ }
+ return res.str();
+}
+
std::vector<std::string> split(const std::string& str, const std::string& delim);
} // namespace utils