...

Richard Kimberly Heck rikiheck at lyx.org
Sun Nov 1 22:37:22 UTC 2020


On 11/1/20 5:00 PM, Richard Kimberly Heck wrote:
> On 11/1/20 4:03 PM, Yuriy Skalko wrote:
>
>> I've started patch #10 after I saw `const` in this code:
>>
>>     void setUsed(bool u) const { used_ = u; }
>>
>> It works because used_ is declared as mutable. Is it really meant to
>> work this way (with breaking constness)? The rest changes followed
>> removing const here to allow compilation.
>>
>> Maybe it is not worth to go this deep since const in C++ is not
>> reliable and cannot guarantee constness of the object: in LyX there
>> are many const methods that modify private implementation via d
>> pointer (Buffer, Paragraph, etc).
> Yes, for sure. Let me have a look at this and see what makes sense.

I'm never entirely sure about mutable members, but it does make sense to
me for used_ to be mutable. It's really just a kind of convenient flag
used when writing the LyX file. It could be replaced by a list of used
authors or something. So it's exactly that kind of thing that it's safe
to update in an otherwise const method. But if it is mutable, then some
of the methods that call it can be made const, as in your patch. I've
committed that bit.

The place I find mutable members most problematic is in OutputParams. I
once tried to sort that out but gave up after a while.

Riki




More information about the lyx-devel mailing list