Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enums used with boost::mpl::integral_c may need to be extended. #24

Closed
dabrahams opened this issue Aug 9, 2022 · 5 comments
Closed

Comments

@dabrahams
Copy link
Contributor

This issue suggests that the enums being used with mpl::integral_c need two additional cases. The problem was detected by the newest Clang in trunk.

@dabrahams
Copy link
Contributor Author

Actually the easiest workaround is to add an underlying type (e.g. int) for each of these enums.

enum example : int { zero };
constexpr example x{static_cast<example>(-1)};

@pdimov
Copy link
Member

pdimov commented Nov 16, 2022

Can't add : int in C++03 libraries though.

@pdimov
Copy link
Member

pdimov commented Nov 16, 2022

Something like this

enum int_float_mixture_enum
{
    // for mpl::integral_c<int_float_mixture_enum, integral_to_integral>
    int_float_mixture_enum_unused_first = -1,

    integral_to_integral,
    integral_to_float,
    float_to_integral,
    float_to_float,

    // for mpl::integral_c<int_float_mixture_enum, float_to_float>
    int_float_mixture_enum_unused_last
};

works, but then switch statements start generating "not all enumeration values handled in a switch" warnings. :-/

pdimov added a commit that referenced this issue Nov 16, 2022
@pdimov
Copy link
Member

pdimov commented Nov 16, 2022

Switching to boost::integral_constant seems to work and is the least intrusive fix.

@pdimov
Copy link
Member

pdimov commented Nov 16, 2022

Applied 50a1eae to develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants