Feature Request: Make TString::Atoi Static

Hi, I am wondering if it is possible to make TString::Atoi (and Atof, Atoll) static member functions, rather than being tied to an instance of TString.

It would be very convenient to use code like this:

char numc[] = "5" Int_t num = TString::Atoi(numc);
without having to actually name the TString anything.

I understand that I can #include and use the regular atoi function, but if ROOT implements its own string class, I think it should be full-featured. I only learned C++ through needing to use ROOT, so my instinct is to look at ROOT-specific solutions first.

Is there any cost or problem with making Atoi a static function?

Jean-François

[quote=“jfcaron”]Hi, I am wondering if it is possible to make TString::Atoi (and Atof, Atoll) static member functions, rather than being tied to an instance of TString.

It would be very convenient to use code like this:

char numc[] = "5" Int_t num = TString::Atoi(numc);
without having to actually name the TString anything.

I understand that I can #include and use the regular atoi function, but if ROOT implements its own string class, I think it should be full-featured. I only learned C++ through needing to use ROOT, so my instinct is to look at ROOT-specific solutions first.

Is there any cost or problem with making Atoi a static function?

Jean-François[/quote]

EDIT: removed a wrong statement about static/non-static member functions.

Yes, why not, we already have several versions of static Itoa, so we can also have Atoi.

More convenient is to just do:

TString s("5");
Int_t n = s.Atoi();

or the same completely without TString:

char numc[] = "5";
Int_t n = atoi(numc);

Besides changing Atoi() from member to static class function cannot be done in a backward compatible way.

Cheers, Fons.