cpp implementation of Plus One