you can do it by hand with void* sum approach, but that is sort of a C approach (there are a few places where this is still useful, though). You may also consider a template function. I assume you know you can add atomic types so I assume this is just an example and not your need ... what you do depends a bit on what you need to accomplish.