- char buf[2 + std::max(
- 2 + DoubleToStringConverter::kMaxFixedDigitsBeforePoint +
- DoubleToStringConverter::kMaxFixedDigitsAfterPoint,
- std::max(8 + DoubleToStringConverter::kMaxExponentialDigits,
- 7 + DoubleToStringConverter::kMaxPrecisionDigits))];
- StringBuilder builder(buf + 1, static_cast<int> (sizeof(buf) - 1));
+ constexpr int bufLen =
+ 2 + constexpr_max(
+ 2 + DoubleToStringConverter::kMaxFixedDigitsBeforePoint +
+ DoubleToStringConverter::kMaxFixedDigitsAfterPoint,
+ constexpr_max(8 + DoubleToStringConverter::kMaxExponentialDigits,
+ 7 + DoubleToStringConverter::kMaxPrecisionDigits));
+ char buf[bufLen];
+ StringBuilder builder(buf + 1, bufLen - 1);