Fix build errors in cpp/reduce