Skip to content

[SUGGESTION] Allow @enum classes as template type arguments #1147

Open
@MaxSagebaum

Description

@MaxSagebaum

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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions