Информация об изменениях

Сообщение Re[5]: return void от 15.06.2023 12:23

Изменено 15.06.2023 12:29 andrey.desman

Re[5]: return void
Здравствуйте, rg45, Вы писали:

R>Да, твоя правда. У меня на компе собрана полная коллекция всех стандартов, начиная с C++98, я только что пробежался по всем от начала и вижу, что данная формулировка появилась только начиная с C++17. Выходит, что до этого эта фича шла на правах расширения, причем, не только в gcc, но и в msvc (и вероятно в других компилерах тоже). Мне даже запомнилось, что достаточно давно (лет десять назад, наверное) у меня был пост на РСДН, в котором я акцентировал внимание на этой возможности.


2005 год.

3.9.1 Fundamental types
The void type has an empty set of values. The void type is an incomplete type that cannot be completed. It is used as
the return type for functions that do not return a value. Any expression can be explicitly converted to type cv void (5.4).
An expression of type void shall be used only as an expression statement (6.2), as an operand of a comma expression
(5.18), as a second or third operand of ?: (5.16), as the operand of typeid, or as the expression in a return statement
(6.6.3) for a function with the return type void.

Re[5]: return void
Здравствуйте, rg45, Вы писали:

R>Да, твоя правда. У меня на компе собрана полная коллекция всех стандартов, начиная с C++98, я только что пробежался по всем от начала и вижу, что данная формулировка появилась только начиная с C++17. Выходит, что до этого эта фича шла на правах расширения, причем, не только в gcc, но и в msvc (и вероятно в других компилерах тоже). Мне даже запомнилось, что достаточно давно (лет десять назад, наверное) у меня был пост на РСДН, в котором я акцентировал внимание на этой возможности.


2005 год.

3.9.1 Fundamental types
The void type has an empty set of values. The void type is an incomplete type that cannot be completed. It is used as
the return type for functions that do not return a value. Any expression can be explicitly converted to type cv void (5.4).
An expression of type void shall be used only as an expression statement (6.2), as an operand of a comma expression
(5.18), as a second or third operand of ?: (5.16), as the operand of typeid, or as the expression in a return statement
(6.6.3) for a function with the return type void.


6.6.3 The return statement [stmt.return]
3 A return statement with an expression of type “cv void” can be used only in functions with a return type of cv void; the
expression is evaluated just before the function returns to its caller.