Last active
October 8, 2019 09:33
-
-
Save qrealka/2e403891e4324d4569860c9a6d26b0de to your computer and use it in GitHub Desktop.
c++ 17 one allocation strcat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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