trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alan M. Carroll" <>
Subject Re: Templates ... WAS: SVN vs GIT
Date Sun, 04 Dec 2011 05:03:41 GMT
I would say the #1 use case for templates is when your other choice is a lot of cut and paste.
The code bloat's the same in both cases and maintenance is definitely easier in the template

Smart pointers are another (although those are already in ATS).

I suppose for me the standard use case is encountering a situation that requires a rule "always
remember to do X" and I think "heck with that, I will make the _compiler_ remember to always
do X". I do restrain myself when working on ATS, though.

I also have strong personal distaste for casting. That's half the reason I don't use APR (the
other half being the lack of constructors & destructors). Although there's an example
of the previous use case. Rather than me remembering to always cast, I could write a template
wrapper for an APR thing (such as a hash table) that remembered to cast for me. And it doesn't
even cause code bloat since it's just doing what I would have typed in myself without the

I would also like to note that there is already quite a bit of template code in ATS (such
as lib/ts/Ptr.h and lib/ts/Vec.h).

Saturday, December 3, 2011, 7:14:59 PM, you wrote:

> I've had some nasty template breakages when upgrading gcc.
> And I don't think it was just the major version shifts (as in 3.x to 4.x).

We have had so little problem we don't even bother coordinating g++ versions on developer
machines, we just use whatever happens to be installed. That could be because I have used
templates so much. I remember one instance where I did some code in template style because
I found it clearer until zwoop complained.

View raw message