- Online Community Forums » Programming Questions » strange syntax

This thread is locked; no one can reply to it. rss feed Print
strange syntax
Member #2,902
November 2002

I was helping a collegue with tensor flow and I came across this syntax...

I've never seen this in C++

InterpreterBuilder(*pModel, resolver)(&pInterpreter);

where pModel is a pointer and strangely enough pInterpreter is a pointer too so in that case the address of a pointer is passed ??? that would be a pointer pointer which makes no sense in this case....

anyone ?

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

Aaron Bolyard
Member #7,537
July 2006

It looks like InterpreterBuilder is a class that overloads the function call operator:

So you're calling the constructor then calling the overload. Or it could be a function that returns an object that overloads the function call operator but that seems less likely.

I've never used Tensorflow so I don't know for certain but those are two possible explanations for that syntax.

ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / them / their - Erin Maus

Peter Hull
Member #1,136
March 2001

It's this:

The code is doing something like

std::unique_ptr<Interpreter>* pInterpreter= ...;
FlatBuffer* pModel = ...;
OpResolver resolver = ...;
InterpreterBuilder builder(*pModel, resolver); // construct
TfLiteStatus status = builder(&pInterpreter); // call operator()

and the last line is really

TfLiteStatus status = builder.operator()(&pInterpreter);

Go to: