Are there cases where a typedef is absolutely necessary?

后端 未结 8 1156
爱一瞬间的悲伤
爱一瞬间的悲伤 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 02:00

    One case (unrelated to your question) where a typedef is required is when using the

    va_arg() macro. Quoting the C99 standard (7.15.1.1):

    type* va_arg(va_list ap, type);

    ...

    The parameter type shall be a type name specified such that the type of a pointer to an object that has the specified type can be obtained simply by postfixing a * to type

提交回复
热议问题