| Summary: | wrong conversion via (G4String) | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Robert Freudenberg <robert.freudenberg> |
| Component: | global | Assignee: | Gabriele Cosmo <Gabriele.Cosmo> |
| Status: | CLOSED INVALID | ||
| Severity: | minor | ||
| Priority: | P4 | ||
| Version: | 9.1 | ||
| Hardware: | All | ||
| OS: | All | ||
|
Description
Robert Freudenberg
2008-02-26 14:47:11 CET
Indeed forcing a cast of an integer to a string is NOT supposed to happen, and G4String is
not supposed to convert a number to its corresponding string representation.
To achieve this you may want to use the tools that C++ provides you.
I.e, a simple function like the following would do the job:
G4String ItoS(G4int i)
{
std::ostringstream os;
os << i;
return G4String(os.str());
}
Dear Gabriele Cosmo, I'm sorry for my wrong assumption. I supposed that I had read this way of conversion in one of the examples - but it wasn't so... Your small function does the job very well :-) |