Alternative & # 8594; operator ()

Is there a stronger syntax than calling objp->operator()(x, y, z) if objp is a pointer? &objp(x, y, z) does not work. Due to all the characters, this is difficult for Google. Sorry, this is stupid.

+4
source share
3 answers

You can use (*objp)(x, y, z); as an alternative.

+8
source

(*objp)(x, y, z); would be an obvious alternative. I'm not sure if you think it is better or not, though.

+8
source

Do it in two lines;

 MyType& functorRef = *objp; // Use the appropriate type name. functorRef(x, y, z); 

Or in C ++ 11 you can use auto.

 auto& functorRef = *objp; functorRef(x, y, z); 
+1
source

All Articles