Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to understand this std::bind usage

I am trying to understand this usage of std::bind usage.
For this example std::bind(&TrtNodeValidator::IsTensorRTCandidate, &validator, std::placeholders::_1) They are trying to bind the function TrtNodeValidator::IsTensorRTCandidate. However, according to the definition of this API, Status TrtNodeValidator::IsTensorRTCandidate(const Node* node); it only accepts one parameter. Why they still need &validator when there exits std::placeholders::_1?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

TrtNodeValidator::IsTensorRTCandidate is a non-static member function.

Aside from its explicit parameters, it requires a TrtNodeValidator* to become this.

std::bind(&TrtNodeValidator::IsTensorRTCandidate, &validator, 
          std::placeholders::_1)

will produce a callable object that calls

(&validator)->IsTensorRTCandidate(std::placeholders::_1)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading