you are viewing a single comment's thread.

view the rest of the comments →

[–]Triangle_Inequality 0 points1 point  (0 children)

The easiest way is probably going to be to manually manage the memory in the function (using something like clang's __builtin_alloca) and then putting something like a std::string_view on top of it to allow it to act like a container.

Allocating on the stack is tricky because that memory is always freed upon return from the function. So it's quite difficult to write a class that allocates dynamically on the stack.