Skip to content

Instantly share code, notes, and snippets.

@hnagata
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnagata/10549680 to your computer and use it in GitHub Desktop.
Save hnagata/10549680 to your computer and use it in GitHub Desktop.
#include <sstream>
#include <string>
template<typename T, typename U, typename... R>
void Join(std::stringstream& ss, const T& sep, const U& head, const R&... follows) {
ss << head << sep;
Join(ss, sep, follows...);
}
template<typename T, typename U>
void Join(std::stringstream& ss, const T& sep, const U& head) {
ss << head;
}
template<typename T, typename U, typename... R>
std::string Join(const T& sep, const U& head, const R&... follows) {
std::stringstream ss;
Join(ss, sep, head, follows...);
return ss.str();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment