You can also overload it, so that it can be given as implicit parameter.
Modern C++ compilers are also able to do escape analysis and remove new altogether,
https://godbolt.org/z/f9vnxG88K
If you try AVR instead of X64, the optimization will be missing, which is only a side effect of the backend not having as much attention in what it looks into.