Re: function call without ()
wade@stoner.com wrote:
There seems to be at least one ambiguity not addressed in the paper
(unless I missed it).
struct x
{
operator int(){ return 1; }
int operator()(){ return 2; }
};
x& foo() implicit { static x x_; return x_; }
int i = foo(); // foo().x::operator() or foo().x::operator int() ?
It may not be stated explicitly, but from the definition, which say
that it "...is implicitly called whenever it is mentioned in an
expression context," I'd say that the meaning of the above would have
to be "call foo and apply operator() to the result." (Which means that
a function declared implicit *cannot* be called with the ordinary
function call syntax.)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]