Ali Çehreli:

Your problem is the exact situation that stdio.ByLine has faced. There, the choice has been to use an internal buffer just like your 'var' and leave the .dup call to the user for when it is needed.

That choice is faster but sometimes causes bugs.

In similar situations I add a boolean template argument that switches on or off the dupping of the given result. On default it's on. So it's safe on default and faster on request, and this goes well with the D zen.

Bye,
bearophile

Reply via email to