Suppose I have:
Foo foo;
is there a shorthand for this?
foo.operator->().operator()(1, 2);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you actually meant
foo.operator->().operator()(1, 2), and that you have control over the classFoo, a simpler form would be(*foo)(1, 2). It requires theoperator*to that defined though, but since we usually expectfoo->barto be equivalent to(*foo).bar, it seems reasonable.If your
Foois a smart pointer class of some sort, which points to an object which defines anoperator(), this would be the most concise way of calling the object’soperator().But without more detail (and without you providing an expression that’s actually valid C++ — there’s no way in which
operator(1, 2)as you wrote it can be valid), it’s impossible to answer your question. I’m just guessing at what you’re trying to do.