cpp: RTypesI: use static locals in place of duplicated globals

Testing: run the unit and integration tests; they might pass if you run them enough times (something is broken outside this PR)