
From: Daryle Walker <darylew@hotmail.com>
On 8/27/04 12:42 PM, "Rob Stewart" <stewart@sig.com> wrote:
From: "Jonathan Turkanis" <technews@kangaroologic.com>
"Rob Stewart" <stewart@sig.com> wrote in message news:200408262114.i7QLEOP14442@lawrencewelk.systems.susq.com...
From: "Jonathan Turkanis" <technews@kangaroologic.com> [SNIP]
- multi_newer: How often do you need to write multiple copies of a character to a stream? And isn't it easy to do so already? The name is bad, too. I vote to reject.
I'm sure one doesn't need to write multiple copies of a character to a stream too often, but why reject this manipulator on the grounds that it isn't needed very often?
Because it clutters up the library, making it harder for people to find the parts they really need.
Also, the straightforward way of writing a sequence of repeated characters to a stream makes it immediately obvious what is being done, whereas programmers looking at code written by someone else can't be expected to know what multi_newer does. If a component fills an important need, it's reasonable to expect people to learn about it if they want to understand your code -- otherwise, I don't see the point.
Daryle can build his own defense on why he included multi_newer. It is cleaner than inserting the same character multiple times. You're right that it's not an improvement over inserting std::string('c', n). The name, of course, is a problem, too.
The idea for "multi_newer" just popped into my head. The string solution is worse because it forces an extra memory allocation.
I bring you back to the question at the top: how often does one need to do this? I contend it isn't often and the memory allocation for building the string is most likely swamped by the other overhead in writing it and whatever accompanies it on the output device. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;