Handling G4String in G4 v 11.0

I am trying to get someGeant4 code (not mine) that worked successfully under geant4 10.2.p02 working under Geant4 11.0.2. In module RunSimulation.cc I have:

G4String OutDir;

std::string::reverse_iterator dirIter = OutDir.rbegin();
if ((G4String) *dirIter != /) OutDir += /;

This is giving me a compilation error:
'/pathto/RunSimulation.cc: In function ‘int main(int, char**)’:
/pathto/RunSimulation.cc:120:25: error: no matching function for call to ‘G4String::G4String(char&)’
120 | if ((G4String) *dirIter != “/”) OutDir += “/”; ’

The code worked for Geant4 10.2.p02, but the release notes for Geant4 11.0 describe changes made to G4String. I have read Appendix 10 A1 of the release notes for Geant4 11.0 (Changes required for advanced use of G4String). However, nothing there suggests why the above code no longer works or how to fix it.

I thought that G4String inherited from std::string, so the reverse iterator construct should be OK. Alternatively, is there any need to use G4String and could I just change OutDir to a std::string?

Any help is appreciated. Thanks.

The problem code is using the now removed constructor of G4String that took a single char argument. In v11, constructors of G4String that didn’t match those of std::string were removed - the example in the notes only shows the modification for explicit use, whereas this code is exercising implicit use. The problem is:

(G4String) *dirIter != "/")

Dereferencing dirIter gives a char& and thus an implicit call to G4String::G4String(char&). All that’s needed is to compare characters directly:

auto dirIter = OutDir.rbegin();

if(*dirIter != '/') OutDir += '/';

That should also be fully backward compatible - the aim of the changes in v11 was to bring G4String as close as possible to std::string.

Thank you for your help. The changes to G4String make more sense to me now.