20.8.1 Definitions [func.def] 1 The following definitions apply to this Clause: 2 A call signature is the name of a return type followed by a parenthesized comma-separated list of zero or more argument types. 3 A callable type is a function object type (20.8) or a pointer to member. 4 A callable object is an object of a callable type.
那么函数看起来就不是callable type了。但是我们可以call函数啊。本人的理解哪里错了?
谢谢
10
10
10
这只是一个定义而已,这个定义只是为了定义 function object 。
能不能用来 call (使用函数调用的“形式”),要看 function call expression 的说明(与callable type 无关):
postfix-expression ( expression-listopt)
普通的:
5.2.2 Function call [expr.call]
1 There are two kinds of function call: ordinary function call and member function63 (9.3) call. A function
call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of
expressions which constitute the arguments to the function. For an ordinary function call, the postfix
expression shall be either an lvalue that refers to a function (in which case the function-to-pointer standard
conversion (4.3) is suppressed on the postfix expression), or it shall have pointer to function type. Calling a
function through an expression whose function type has a language linkage that is different from the language
linkage of the function type of the called function’s definition is undefined (7.5). For a member function
call, the postfix expression shall be an implicit (9.3.1, 9.4) or explicit class member access (5.2.5) whose idexpression is a function member name, or a pointer-to-member expression (5.5) selecting a function member;
the call is as a member of the class object referred to by the object expression. In the case of an implicit
class member access, the implied object is the one pointed to by this. [ Note: a member function call of the
form f() is interpreted as (*this).f() (see 9.3.1). — end note ] If a function or member function name
is used, the name can be overloaded (Clause 13), in which case the appropriate function shall be selected
according to the rules in 13.3. If the selected function is non-virtual, or if the id-expression in the class
member access expression is a qualified-id, that function is called. Otherwise, its final overrider (10.3) in the
dynamic type of the object expression is called. [ Note: the dynamic type is the type of the object referred
to by the current value of the object expression. 12.7 describes the behavior of virtual function calls when
the object expression refers to an object under construction or destruction. — end note ]
重载 operator ():
13.5.4 Function call [over.call]
1 operator() shall be a non-static member function with an arbitrary number of parameters. It can have
default arguments. It implements the function call syntax
postfix-expression ( expression-listopt)
where the postfix-expression evaluates to a class object and the possibly empty expression-list matches the
parameter list of an operator() member function of the class. 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 (13.3.3).
20