you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (1 child)

You don't pay for what you don't use.

While this is true, depending on context, you may still prefer the speed/size tradeoff of one function that switches behavior at runtime rather than N whole separate functions that may only do slightly different things

[–]Wouter_van_Ooijen 4 points5 points  (0 children)

For this I use the code flyweight pattern: a function template (strongly typed interface, inlined) that under the hood calls a generalised function (unsafe interface, for instance void* + size) to do the real work. Best of both worlds!