← Back to team overview

kicad-developers team mailing list archive

Re: Casting away constness

 

On Sun, Apr 27, 2014 at 02:19:51PM +0200, Lorenzo Marcantonio wrote:
> I agree that misbehaviour is actually improbable, especially if there's
> lot of code to the point of possible elision. That doesn't mean it's
> impossible, anyway.

Sorry all, retraction. In newer C++ member constness has changed slightly.

You cannot return nonconst references or pointer to members *but*
members pointer and references don't became tainted by the constness.

Formally it makes not much sense, but at least the useful cases (like
the current one) became possible. I don't think that call eliding can be
proved safe anymore, however... const now is more for documentation and
error avoidance, not optimization (like pure functions) it seems.

In fact replacing the Next/Back casts with static_cast work fine:D

-- 
Lorenzo Marcantonio
Logos Srl


References