Bruce,

> So the first thing I would suggest is to try the define #define 
> NULL_RE_ARG no_arg (I think no-arg is extern declared in pcrecpp.h so
> I am hoping this works)

This works if I use this as arguments for FullMatch:
        NULL_RE_ARG,
But, oddly enough, it does not work in your original syntax and that
does make me suspicious:
        (n>0?&s[0]:NULL_RE_ARG),
Here's the error:
re.cpp: variable 'pcrecpp::no_arg' can't be auto-imported. Please read
the documentation for ld's --enable-auto-import for details.

But if I keep:
#define NULL_RE_ARG NULL
and then replace, in your original syntax:
(n>0?s[0]:NULL_RE_ARG),
by:
(n>0?&s[0]:NULL_RE_ARG),
It does compile without warnings. I know you retracted &s[] but, as I
said, s[] doesn't compile (even on its own outside of the conditional
statement) because FullMacth is expecting "const pcrecpp::Arg&" and not
"std::string&" (according to the error messages).
Looking back, I should I tried removing s[] while leaving NULL_RE_ARG
defined as NULL yesterday... that would have saved us some time.

Eventhough it compiles, FullMatch is expecting Arg as arguments, not a
pointer to a string (I'm not familiar with the string class but I'm
assuming this is what &s[] returns). Maybe this is what Arg::Parser is
for. And I don't know what it'll make of a NULL... do you think it's
worth testing if this works somehow or do we know it'll fail?

> I am confused by the above.  Do you mean it compiled if  NULL_RE_ARG 
> is defined to new Arg()?  That's interesting but you are right I 
> don't think it would work as I am trying to signal a missing argument
> and a new Arg() would probably not be interpreted that way.

Yes it compiles if I feed FullMatch Arg() as arguments.
This is what the header has to say about this:

pcrecpparg.h:
class Arg {
  public:
   // Empty constructor so we can declare arrays of Arg
   Arg();
   // Constructor specially designed for NULL arguments
   Arg(void*);
...

pcrecpp.h:
// We convert user-passed pointers into special Arg objects
extern Arg no_arg;

This compiles too in case that makes a difference:
Arg* NULL_RE_ARG = new Arg;

>>> `pcrecpp::RE::GlobalReplace(std::string&, std::string&)'
> 
> Yes, the last argument should be a string*, so I think you just have 
> to put an & in front of it in the call.  Same for Extract and plain 
> Replace, I believe.

Yeah, this compiles as expected.

Reply via email to