In C++, if throw is an expression, what is its type?

后端 未结 4 569
耶瑟儿~
耶瑟儿~ 2020-12-07 13:29

I picked this up in one of my brief forays to reddit:

http://www.smallshire.org.uk/sufficientlysmall/2009/07/31/in-c-throw-is-an-expression/

Basically, the a

4条回答
  •  广开言路
    2020-12-07 14:26

    According to the standard, 5.16 paragraph 2 first point, "The second or the third operand (but not both) is a throw-expression (15.1); the result is of the type of the other and is an rvalue." Therefore, the conditional operator doesn't care what type a throw-expression is, but will just use the other type.

    In fact, 15.1, paragraph 1 says explicitly "A throw-expression is of type void."

提交回复
热议问题