Skip to content

Instantly share code, notes, and snippets.

@qrealka
Last active October 8, 2019 09:33
Show Gist options
  • Save qrealka/2e403891e4324d4569860c9a6d26b0de to your computer and use it in GitHub Desktop.
Save qrealka/2e403891e4324d4569860c9a6d26b0de to your computer and use it in GitHub Desktop.
c++ 17 one allocation strcat
// fine for string_view or const char*. todo: use std::forward
// from Marco Magdy
template<typename.. Args>
auto strcat(Args... args)
{
const auto total = (... + args.size());
std::string s;
s.reserve(total);
(s += ... += args);
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment