Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » strange syntax

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

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 ;-)

Erin Maus
Member #7,537
July 2006
avatar

It looks like InterpreterBuilder is a class that overloads the function call operator: https://en.cppreference.com/w/cpp/language/operators

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 / she

Peter Hull
Member #1,136
March 2001

It's this:
https://www.tensorflow.org/lite/api_docs/cc/class/tflite/interpreter-builder

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: