Problem compiling with TPRegexp

Hello,

I’m having a hard time compiling code that uses TString::Index( TPRegExp, … ). The error message complains, well, see for yourself:

The program is simply (in a file called testP.c):

What am I missing?

What you do is wrong. TString::Index expects an argument passed by reference, not by value. Change your code to

TString ss; TRegexp rex(","); ss.Index( rex, Ssiz_t( 0 ) ); ss.Index( rex, Ssiz_t( 0 ) );
Rene

Thanks Rene,

I forgot that the compilers protect against using temporary variables for a non-const pass by reference. I think it used to yield only a warning message when I learnt C++ :slight_smile:

But in this case, this is a mild interface bug - TString::Index should accept a const TPRegexp. I guess there’s something tricky in the implementation (I see it neither in TString.h, nor in TString.cxx), but I’m sure this is fixable.

Cheers,
Amnon