[ 
https://issues.apache.org/jira/browse/THRIFT-5843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17909421#comment-17909421
 ] 

Yuxuan Wang commented on THRIFT-5843:
-------------------------------------

Sorry I haven't worked with c++ for a while so please pardon my ignorance: is 
this scoped enumeration closed or open? e.g. does it require the handling of 
the cases comprehensive and will cause compilation errors when there are enum 
values missed?

Closed enumerations (that requires comprehensive handling) have 
backward-compatibility issues: if someone adds a new enum value to thrift, then 
that could suddenly break the c++ code handling it as the current code handle 
the enum values is suddenly no longer comprehensive.

> Represent Thrift enums as C++ enum classes
> ------------------------------------------
>
>                 Key: THRIFT-5843
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5843
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C++ - Compiler
>    Affects Versions: 0.21.0
>            Reporter: Tim Crews
>            Priority: Minor
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Add a *cpp:enum_classes* option to the C++ compiler so that a Thrift enum 
> declaration like this:
> {{enum PrintDirection}}
> {
> {{  Down = 68,}}
> {{  Up = 85}}
> {{}}}
> becomes a C++ [scoped 
> enumeration|https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations]
>  declaration like this:
> {{enum class PrintDirection {}}
> {{  Down = 68,}}
> {{  Up = 85}}
> {{};}}
> This is very similar to the existing *cpp::pure_enums* option, but it 
> addresses the drawback that all of the enumerators (the values like Down and 
> Up) are in the same namespace as the enumerators from other enum types.
> I already have a working implementation of this feature that I have been 
> using on a private fork of Thrift for about five years, so the only work 
> required would be to prepare the pull request.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to