Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call operator() on "this"?

Tags:

c++

I have a member function which needs to call operator() on the class instance (this), and I could not guess at the right syntax. I tried

  this();
  *this();
  this->();
  this->operator();

and a few other things, but the error messages are not very informative, so I dont know what am I doing wrong.

The closest I found on SE: How do I call a templatized operator()()?

like image 471
Kostas Avatar asked Dec 03 '22 09:12

Kostas


2 Answers

(*this)(/*parameters*/)

is probably the clearest way.

like image 182
Bathsheba Avatar answered Dec 20 '22 09:12

Bathsheba


Answer: use

 this->operator()();
like image 31
Kostas Avatar answered Dec 20 '22 09:12

Kostas