Skip to content

Instantly share code, notes, and snippets.

@BraynStorm
Created August 2, 2018 20:43
Show Gist options
  • Save BraynStorm/567770d6f1a105da1acaecdd2844890f to your computer and use it in GitHub Desktop.
Save BraynStorm/567770d6f1a105da1acaecdd2844890f to your computer and use it in GitHub Desktop.
template <typename Head, typename... Tail>
auto join(Head &&head, Tail &&... tail) {
return [&](std::string_view separator = "") {
std::ostringstream stream;
stream << std::forward<Head>(head);
((stream << separator << std::forward<Tail>(tail)), ...);
return stream.str();
};
}
/*
* Usage
*/
int main(){
std::cout << join("asdf", 12341, '5')("->") << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment