I’m taking my first foray into C++, specifically the Google RE2 library, and I am stuck on some of the syntax. I am trying to invoke a function with the signature:
static bool FindAndConsumeN(StringPiece* input, const RE2& pattern,
const Arg* const args[], int argc);
With the code:
const re2::RE2::Arg match;
bool isMatched = RE2::FindAndConsumeN(&inputPiece, *expression,new const re2::RE2::Arg[] { &match },0)
However I am getting the compiler error:
Error 3 error C2664: 're2::RE2::FindAndConsumeN' : cannot convert parameter 3 from 'const re2::RE2::Arg (*)[]' to 'const re2::RE2::Arg *const []'
I’ve clearly got the datatype of the third argument wrong, but does anyone know what the correct data type is?
I am compiling the code with Visual Studio 2010
You should use code like this:
argswill be converted toconst Arg* args[].The inner
consthas no deal with calling code, it works only withinFindAndConsumeN.Don’t use
newbecause you can’tdeletearray later.(with
newit would benew const re2::RE2::Arg*[])