[RFC] Enum improvements
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Sat Nov 28 17:10:47 UTC 2020
Le 28/11/2020 à 16:11, Richard Kimberly Heck a écrit :
> On 11/28/20 3:42 AM, Yuriy Skalko wrote:
>> Now LyX requires C++11 and we can use its new enum features:
>>
>> 1. Enum base type. It will allow forward declarations of enums in
>> headers to break weak, unnecessary dependencies like BufferParams.h
>> ---> InsetQuotes.h. This will also improve compilation speed.
>>
>> 2. Scoped enums. It will allow better type safety. Also some commonly
>> used enum declarations can be moved out of classes (that used solely
>> for limiting scope of enum values).
>
> In case anyone else is curious, I found this explanation:
>
> https://smartbear.com/blog/develop/closer-to-perfection-get-to-know-c11-scoped-and-ba/
>
> The first bit, involving headers, looks most useful.
I agree that the first one is the most promising.
Another thing to look at: we have plenty of enums used a bitfields where
we have defined special operators (some are mine) I only realized
recently that it does not make sense. A good example is KeyModifier. I
suspect that we should use 'int' instead of casting back to the original
enum type. There are complex tamplate-based solutions to this, but I am
not sure they are worth the hassle.
JMarc
More information about the lyx-devel
mailing list