implement c++ tweak from http://andybrown.me.uk