This is NOT a final patch.
I'm looking for suggestions on how to improve it.
But .. it does solve the OP's problem, and introduces no new ones that I can find.
Changes that have to be made before this is landed:
- Naming; we obviously don't want __Fooby, __Fooby2, etc in our code base.
- Removing the old __duration_divide_result and __duration_divide_result_imp classes which are no longer used
- Looking at operator * which probably needs the same treatment.
- Do we want to grab __has_common_type and put it in <type_traits> where other parts of libc++ can use it?
The reason that this is so pernicious is that common_type will blow up on you in C++03, rather than just SFINAE-ing away. So, you'd better be sure that there is a common type before you ask.
Note that the approach in this patch fails for C++03 (for the cases in the bug report). I don't know how to fix that. But, this patch does NOT break any existing cases in C++03 (Which Howard's 'lightly tested" patch did).