On 6/26/2015 7:45 PM, Parke via Digitalmars-d wrote:
Or, perhaps more precisely: Does the caller of toString need to know the size of the struct that toString will return?
Yes.
In the above example, buf's length is uint.sizeof * 3. But what if buf's length was a function of u (and therefore only known at run-time), rather than a function of uint.sizeof?
In cases where the size cannot be known in advance, the returned struct can malloc/free the extra space.
