cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[SUGGESTION] Allow @enum classes as template type arguments

Open MaxSagebaum opened this issue 7 months ago • 2 comments

The enums generated by @enum in cppfront can not be used as template type arguments. E.g:

range_flags: @enum type = {
    not_greedy := 1;
    greedy;
    possessive;
}

S: <flag: range_flags> type = {

}

The error is:

main.cpp2:18:22: error: invalid use of incomplete type 'class range_flags'
main.cpp2:12:7: note: forward declaration of 'class range_flags'
main.cpp2:18:22: error: 'range_flags' is not a valid type for a template non-type parameter because it is not structural
main.cpp2:13:19: note: 'range_flags::_value' is not public

Example on compiler explorer: https://cpp2.godbolt.org/z/v3bvPE6EE

This is basically a feature request. I did not have a look at the current implementation. Would it have merit/support if the generated @enum code would support this?

MaxSagebaum avatar Jul 03 '24 09:07 MaxSagebaum