hatcat / cg30_issues

The public issues repository for the book "Beautiful C++"
4 stars 1 forks source link

Code error on p.280 #28

Open hatcat opened 2 years ago

hatcat commented 2 years ago

I may be the 17th person to report this ... but there's a very tiny nit on p280 of the published book.

"If we rewrite this function while observing ES.5: "Keep scopes small," we might arrive at this:

int f2(int a, int b, float c) { if (a > b) return; prepare_for_invocation(); return my_special_type{a, b}.magical_invocation(c); }

The sample code on has correctly got "return a;" on the first line of f2. https://godbolt.org/z/cg30-ch5.4