This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: return-value policy question
- From: Phil Edwards <phil at jaj dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 29 Apr 2003 14:07:38 -0400
- Subject: Re: return-value policy question
- References: <20030429053012.GG32140@tofu.dreamhost.com>
On Mon, Apr 28, 2003 at 10:30:12PM -0700, Nathan Myers wrote:
> In much of the library implementation I find code like that in
> streambuf::sputc :
>
> int_type __ret;
[assign in multiple branches]
> return __ret;
>
> instead of the simpler and more elegant
>
> if (_M_out_cur < _M_out_end)
> {
> *_M_out_cur = __c;
> _M_move_out_cur(1);
> return traits_type::to_int_type(__c);
> }
> return this->overflow(traits_type::to_int_type(__c));
I find the former /much/ easier to debug, but that's personal preference.
Also, the optimizations being implemented and planned for SSA form tend
to make this sort of thing a moot point. So, *shrug*, whichever.
> or the even simpler and more traditional
>
> return (_M_out_cur < _M_out_end) ?
> traits_type::to_int_type(*_M_out_cur++ = __c) :
> this->overflow(traits_type::to_int_type(__c));
Normally I'm not a style bigot, but Sweet Lord, that's hideously ugly.
Phil
--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams