Refactor addValues to use a helper template to avoid unused-function warning with clang