Definition of operator() in over.call

36 переглядів
Перейти до першого непрочитаного повідомлення

barry....@gmail.com

не прочитано,
8 черв. 2017 р., 11:13:3008.06.17
Кому: ISO C++ Standard - Discussion
Overloading operator() is defined in [over.call] as:

Thus, a call x(arg1,...) is interpreted as x.operator()(arg1, ...) for a class object x of type T if T​::​operator()(T1, T2, T3) exists and if the operator is selected as the best match function by the overload resolution mechanism ([over.match.best]).

What does the second half of that even mean? What are T1, T2, T3 and what does it mean for T::operator() to exist? Why not just say that x(arg1, ...) means x.operator()(arg1, ...) and stop there?

Bo Persson

не прочитано,
8 черв. 2017 р., 11:29:1408.06.17
Кому: std-dis...@isocpp.org
On 2017-06-08 17:13, barry....@gmail.com wrote:
> Overloading operator() is defined in [over.call]
> <http://eel.is/c++draft/over.call> as:
>
> Thus, a call x(arg1,...) is interpreted as x.operator()(arg1, ...)
> for a class object x of type T ifT​::​operator()(T1, T2, T3) exists
> and if the operator is selected as the best match function by the
> overload resolution mechanism ([over.match.best]
> <http://eel.is/c++draft/over.match.best>).
> <http://eel.is/c++draft/over.call#1.sentence-4>
>
>
> What does the second half of that even mean? What are T1, T2, T3 and
> what does it mean for T::operator() to exist? Why not just say that
> x(arg1, ...) means x.operator()(arg1, ...) and stop there?
>

There could be more than one operator(), so we also have to consider the
parameter types T1, T2, T3 and corresponding arguments to select the
best match.


Bo Persson


Johannes Schaub

не прочитано,
8 черв. 2017 р., 11:47:1708.06.17
Кому: std-dis...@isocpp.org
The meaning of "x(...)" where x is a class-type object is defined in
http://eel.is/c++draft/over.call.object . The purpose of [over.call]
is to specify how many parameters a function call operator may have
and whether it may be a non-member function. All the rewriting and
overload resolution concerns are handled by over.match. You can call
the function constrained at [over.call] also by explicitly giving its
name, so over.call is not concerned with the rewriting rules when you
call it by using a class object as the callee (note: despite the
naming, over.call.object is not a subsection of [over.call].
over.call.object is a in a different sections-tree). I suspect that
the "Thus..." utterations in [over.oper] can therefore be made notes,
but I'm not totally sure.
Відповісти всім
Відповісти автору
Переслати
0 нових повідомлень