This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: return-value policy question
>Frankly, I can't find in what the second version is simpler and more
>elegant. The former compute the value to return in either branches,
>and in a single return-statement returns the computed value.
>
>Having -- recently -- to monitor return-statements in the compiler I
>found it
>
> * astonishingly helfpul that functions that span may pages have a
> single return statement and very easy to monitor;
>
> * functions that had many return-statements were the ones that
> provided many opportunities for having the auditing worng;
>
> * the functions with a single return-statement are no harder to
> read (actually it was the functions with many return-statements
> that were harder to read).
>
>[...]
100% agreed. Nathan, try stepping through this in gdb.
In addition, for complex types, this enforces NRV.
-benjamin