根据我的理解,typedef语法是:
typedef existing_type new_type_name;
Run Code Online (Sandbox Code Playgroud)
但是,在Chrome的v8命名空间中,有许多typedef似乎与其他语法一起使用.例如,
typedef void(* FunctionCallback )(const FunctionCallbackInfo< Value > &info)
Run Code Online (Sandbox Code Playgroud)
有两点我不明白:
1- FunctionCallbackInfo <Value>是在命名空间中定义的类,而FunctionCallback不是; 应该是先存在的现有类型?
2-没有空格分隔existing_type和new_type_name
读取它的正确方法是什么?
编辑:我正在学习本教程中的所有typedef信息.
您对typedef语法的理解有点不准确.不是:
typedef existing_type new_type_name;
Run Code Online (Sandbox Code Playgroud)
它更像是:
typedef declaration;
Run Code Online (Sandbox Code Playgroud)
因此,您的示例是一个typedef名为的函数指针类型的声明FunctionCallback,它返回void并引用a const FunctionCallbackInfo< Value >作为其唯一参数.