On 12/3/11 10:19 AM, Alan M. Carroll wrote:
I have somewhat of a biased view as I was doing template style programming
before C++ had templates (using the Common Lisp Object System) so it's second
nature for me.
P.S. I've definitely found more than one bug in a compiler (both MSVC and g++)
from templates. I used to think that if I wasn't crashing the compiler with my
templates, I wasn't really trying. That's become a bit harder but I expect I
can get back to it when C++0xeleventy1! is generally available.
Yes, we are mainly jerking Alan around, it's what we do here. Nailed it!
But, to add to Alan's good pro's and con's, templates can be difficult to
deal with from a cross platform perspective. If all you use is gcc, then
fine, it's probably not a problem. But for example while I was at Netscape /
Mozilla (which was quite a while ago), templates were generally frowned
upon, because back then, it was virtually impossible to get them to compile
properly in a massively multi-platform environment.
Also, templates can be difficult (in my experience anyways) to debug. The
errors from the compilers are generally crap. And finally, templates can
lead to code bloat (look at STL), which is totally fine for many
applications. But for high performance apps, it should be a consideration,
once you blow your L2/L3 caches, performance will suffer.
These are mostly my naive C++ as a C programmer points of view ;). I like
C++, but typically because of ctor's and dtor's and encapsulation, not
templates :).
Cheers,
-- leif