Are there cases where a typedef is absolutely necessary?

后端 未结 8 1160
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 01:21

Consider the following excerpt from the safe bool idiom:

typedef void (Testable::*bool_type)() const;
operator bool_type() const;

Is it possibl

8条回答
  •  清歌不尽
    2021-02-05 01:53

    It seems that the grammar demands using a typedef in your case. A conversion-function-id must be of the form operator conversion-type-id. The conversion-type-id cannot contain parentheses. So you must use typedef when converting to a pointer-to-function type, or to a pointer-to-member-function type.

提交回复
热议问题