Categories
c++

My C++ wants to kill your momma

… well actually it doesn’t. But it sounded good when I made it up. So recently I found myself needing to use a C++ partial function specialisation. No-one was as surpsied as me when this happened.

To say I was anti-templates would be too strong. I find the code they produce hard to follow, regardless of how elegant and efficient they really are. But then they do serve a really useful need. Obviously containers are an example of something where templates are indispensable. So you can’t just write them off.

But now that we have the standard library (and boost) do mere mortals really need to worry or bother about templates in the large? I think the answer to this is probably no.

But then again it depends on what you’re doing. And since I’ve started working on writing a wrapper around the TIBCo/RV library for Ruby I found myself writing a lot of C++ code that was very similar apart from the types involved. So then a little light bulb goes on in my head (40w supermarket own brand, cliche retardant) . Surely I can write a template to do this for me? This will mean that there’s only one code base for a bunch of similar behaviour and when I need to write that internationisation add-on (i18n) for my error messages I’ll only need to change one or two methods instead of a zillion.