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

C++20: require implicit conversion for hana::is_convertible by static_cast #492

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ecatmur
Copy link

@ecatmur ecatmur commented Aug 9, 2021

In C++20, static_cast can perform aggregate construction (__cpp_aggregate_paren_init). This breaks the example https://github.com/boostorg/hana/blob/master/example/core/convert/is_convertible.cpp#L13 by allowing construction of Employee from its single direct base Person.

Change the maybe_static_cast control expression to require implicit conversion. Since this doesn't allow conversion to cv void, add a to_impl for cv void To.

In C++20, static_cast can perform aggregate construction (__cpp_aggregate_paren_init). This breaks the example by allowing construction of Employee from its single direct base Person.

Change the maybe_static_cast control expression to require implicit conversion. Since this doesn't allow conversion to cv void, add a to_impl for cv void To.
@ecatmur
Copy link
Author

ecatmur commented Aug 10, 2021

Of course, this change would disallow explicit converting constructors and conversion operators. An alternative would be to change the example (example/core/convert/is_convertible.cpp).

@gjasny
Copy link

gjasny commented Jul 6, 2022

Without that patch Visual Studio v17.3.0-pre.2.0 fails to compile the examples.

@gjasny
Copy link

gjasny commented Jul 18, 2022

next developer preview v17.3.0-pre.3.0 fixes compilation.

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

Successfully merging this pull request may close these issues.

2 participants