microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
10.25k stars 1.51k forks source link

`<ratio>`: use `constexpr` functions instead of template-based calculation #2291

Closed AlexGuteniev closed 2 years ago

AlexGuteniev commented 3 years ago

Now that we can do everything in constexpr and have if constexpr, this can be expressed simpler. Probably it would improve throughput and / or readability

Some of calculations to change to functions:

https://github.com/microsoft/STL/blob/d8f03cf399d730780b6ca0e5321a9ff4fc76bb0f/stl/inc/ratio#L51-L64

sam20908 commented 2 years ago

The use of TMPs was to implement LWG-2094, which makes overflow a SFINAE error instead of emitting diagnostics. There is no way to achieve the same thing with constexpr functions. I think this issue cannot be fixed.

AlexGuteniev commented 2 years ago

I think that if DevCom-1202945 is fixed, this still can be addressed.