Presumably (from the code) the value is irrelevant, since it is overwritten, the key is calculating the type T
.
This approach can be extended to pre-allocated buffers if applied twice (inner-outer, just guess a buffer type and get a new one if guessed wrong, doing it in each iteration), but I need to think about how to package and simplify this.