-
Notifications
You must be signed in to change notification settings - Fork 56
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
is_constructible has unexpected results #36
Comments
AMDG
That's not quite good enough. In quantity, you need
to check for conversion_helper::convert. conversion_helper
is where you'll put the check for conversion_factor.
The only reason that Boost.Units doesn't do this already
is that it was written in the days when SFINAE was a lot
less reliable. Even what we have was quite finicky on
VC7.1, VC8, and Sun CC 5.9. I'm fine with it if it doesn't
work in C++03. Although you can make it work by providing
a fallback ellipsis overload with the sizeof trick, it's
probably not worth the effort.
In Christ,
Steven Watanabe
|
@swatanabe You are right that makes sense. I came to the same conclusion now. Let's see if I can spin a PR out of this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://godbolt.org/z/W-7Nvg
This fails to compile before it is able to check the static assertion with the following error:
This has consequences for using boost::units inside a boost::variant as the constructor of the variant cannot reliably detect if the given source operand can be converted to any of the contained storage types of the variant.
In our source code base with a vendored-in copy of Boost, I fixed the issue by adding a check that
conversion_factor
is a defined function for the given source and target units of a quantity. If that is not the case, the constructor for explicit conversions is disabled. This does not work with an output test case at this point in time.Furthermore, the current solution only fixes the problem in C++11 and beyond.
Before digging deeper and creating a proper PR, I wanted to know if I am looking at the right approach or if I am off on the wrong foot.
The text was updated successfully, but these errors were encountered: