cpp: More const and shared_ptr tristate fixes