Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I didn't understand the change proposed in DR 2145 for [dcl.fct.def.general]/2

The change proposed in DR 2145 was responsible for the change in [dcl.fct.def.general]/2 from C++14 to C++17, as follows:

C++14:

The declarator in a function-definition shall have the form
      D1 ( parameter-declaration-clause ) cv-qualifier-seqopt ref-qualifieropt
             exception-specificationopt attribute-specifier-seqopt trailing-return-typeopt
as described in 8.3.5. A function shall be defined only in namespace or class scope.

C++17:

In a function-definition, either void declarator ; or declarator ; shall be a well-formed function declaration as described in 11.3.5. A function shall be defined only in namespace or class scope.

Frankly, I didn't understand the motivation for the change, neither the new wording in C++17.

like image 487
Alexander Avatar asked Jan 21 '26 23:01

Alexander


1 Answers

As T.C. pointed out in the comment,

The intention is to allow stuff like int (f()) { return 1; } which is banned by the previous wording but allowed in practice.

like image 172
xskxzr Avatar answered Jan 23 '26 14:01

xskxzr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!