While reviewing #32520, I noticed that the function ToIntegral() could be improved:
-
Instead of manually asserting
std::is_integral_v<T>, the template can be constrained with the standardstd::integralfor clearer intent. -
Annotation with
[[nodiscard]]andnoexcept. Compilers will warn if the return value is discarded and sincestd::from_charsis guaranteed to throw nothing, declaring the wrappernoexceptmakes the exception guarantee explicit. -
With C++23, the integral overloads of
std::from_charsareconstexpr, allowingToIntegralto become aconstexprfunction.