J
James Kanze
Well, I understand that there are shops where templates are
prohibited by local coding guidelines. I would suppose they
have those rules in place for good reasons. Admittedly, under
those circumstances, using the OutIter signature is not
feasible.
I would, however, maintain that templates _should_ be fine for
many projects.
They're fine in certain places on most projects. On the other
hand, you don't want to make everything a template. If the code
necessary to calculate the values to fill the list, for example,
is a couple of hundred lines, you don't really want it in
a template.
I do see that they interact poorly with the C++ model of
separate compilation and source code file inclusion: taken
together, the package does not really scale all that well.
I am just not certain at which point scaling becomes a valid
reason to ban templates.
The ban is relative. There are places in a lot of applications
where you don't want templates. And there are others where
they're acceptable. But in general, I wouldn't use a template
unless there was an actual requirement to support several
different types. I might write the code using a back iterator
into a vector, with the idea that if the need arose, I could
easily convert it into a template, but until the need arose, I'd
stick with the non-template form. And if the function were not
at the lowest, most stable layer, I'd avoid the template,
period.