-
Notifications
You must be signed in to change notification settings - Fork 96
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
Should math.h
be implemented as hidden friends?
#669
Comments
Maybe! The main benefit is that it would let us automatically support types that implicitly convert to, but not from, a Another benefit is reducing the size of overload sets, which can make for shorter compiler error messages and, I think, faster compile times in a few cases. The downside is that it's an intrusive change: we need to open up the guts of Au has done this for Later on, I tried using this for |
To be concrete: which specific functions were you considering? |
math.h
be implemented as non-member functions?math.h
be implemented as hidden friends?
I thought about most if not all, functions from the |
Are constants in Au modeled as units that convert to quantities? |
No, they are constants that convert to quantities. 🙂 |
But I assume that such a constant is a part of the unit of a quantity and simplifies at compile-time when needed? |
I don't understand what you're asking, but I understand what Au does. 🙂 Every The parts I didn't understand or found confusing were:
I hope my above paragraph answered the question. |
I mean something like this: constexpr auto c = speed_of_light;
quantity q1 = 0.4 * c;
quantity q2 = q1 / c;
|
Thanks for giving a concrete example. I think the answers will be just as you expect (with the caveat that this syntax wouldn't work for Au because we don't have deduction guides for C++17's CTAD):
I'm a little uncertain for (3) as to whether we would produce a quantity or just a raw |
Thanks. So, it seems the only drawback of this solution to what we have in mp-units is that a possibly long magnitude of a constant is visible in a quantity type. When two constants are involved, magnitude no longer has a "familiar" value. But you gained implicit constructions from a constant. I also think that Au uses implicit conversions for operators. It means that things like |
|
Should we implement the functions from the
mp_units/math.h
header as non-member hidden friend functions inquantity
andquantity_point
?The text was updated successfully, but these errors were encountered: