adding namespace std to make code easier to understand
#include <string> #include <string_view> #include <vector> #include <numeric> #include <sstream> using namespace std; string Jointup(const vector<string> &name , const string_view delim = " , ") { if (name.empty()) return ""; stringstream ss; ss << name.front(); for_each(next(name.cbegin()), name.cend(), [&ss, delim](auto const& s) { ss << delim << s; }); return ss.str(); }
- #include <string>
- #include <string_view>
- #include <vector>
- #include <numeric>
- #include <sstream>
- using namespace std;
std::string Jointup(const std::vector<std::string> &name , const std::string_view delim = " , ")- string Jointup(const vector<string> &name , const string_view delim = " , ")
- {
- if (name.empty()) return "";
std::stringstream ss;- stringstream ss;
- ss << name.front();
std::for_each(std::next(name.cbegin()), name.cend(), [&ss, delim](auto const& s) { ss << delim << s; });- for_each(next(name.cbegin()), name.cend(), [&ss, delim](auto const& s) { ss << delim << s; });
- return ss.str();
- }