Repository: fmtlib/fmt
File: include/fmt/format-inl.h (C/C++)

Code before:
  constexpr uint64_t high() const noexcept { return high_; }
  constexpr uint64_t low() const noexcept { return low_; }

  uint128_wrapper& operator+=(uint64_t n) noexcept {
#if FMT_HAS_BUILTIN(__builtin_addcll)
    unsigned long long carry;
    low_ = __builtin_addcll(low_, n, 0, &carry);
    high_ += carry;
#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64)
    unsigned long long result;
    auto carry = __builtin_ia32_addcarryx_u64(0, low_, n, &result);
    low_ = result;
    high_ += carry;
#elif defined(_MSC_VER) && defined(_M_X64)
    auto carry = _addcarry_u64(0, low_, n, &low_);
    _addcarry_u64(carry, high_, 0, &high_);
#else
    low_ += n;
    high_ += (low_ < n ? 1 : 0);
#endif
    return *this;
  }
};

// Compilers should be able to optimize this into the ror instruction.
inline std::uint32_t rotr(uint32_t n, uint32_t r) noexcept {
  r &= 31;
  return (n >> r) | (n << (32 - r));
}
inline std::uint64_t rotr(uint64_t n, uint32_t r) noexcept {
  r &= 63;
  return (n >> r) | (n << (64 - r));
}

// Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox.
namespace dragonbox {
// Computes 128-bit result of multiplication of two 64-bit unsigned integers.
inline uint128_wrapper umul128(uint64_t x, uint64_t y) noexcept {
#if FMT_USE_INT128
  auto p = static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
  return {static_cast<uint64_t>(p >> 64), static_cast<uint64_t>(p)};
#elif defined(_MSC_VER) && defined(_M_X64)
  uint128_wrapper result;
  result.low_ = _umul128(x, y, &result.high_);
  return result;
#else
  const uint64_t mask = (uint64_t(1) << 32) - uint64_t(1);

  uint64_t a = x >> 32;
  uint64_t b = x & mask;
  uint64_t c = y >> 32;

Review comment (suggestion):
nit: I suggest dropping `std::` in the return type for consistency (and the same in the overload below).

Code after:
  constexpr uint64_t high() const noexcept { return high_; }
  constexpr uint64_t low() const noexcept { return low_; }

  uint128_wrapper& operator+=(uint64_t n) noexcept {
#if FMT_HAS_BUILTIN(__builtin_addcll)
    unsigned long long carry;
    low_ = __builtin_addcll(low_, n, 0, &carry);
    high_ += carry;
#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64)
    unsigned long long result;
    auto carry = __builtin_ia32_addcarryx_u64(0, low_, n, &result);
    low_ = result;
    high_ += carry;
#elif defined(_MSC_VER) && defined(_M_X64)
    auto carry = _addcarry_u64(0, low_, n, &low_);
    _addcarry_u64(carry, high_, 0, &high_);
#else
    low_ += n;
    high_ += (low_ < n ? 1 : 0);
#endif
    return *this;
  }
};

// Compilers should be able to optimize this into the ror instruction.
FMT_CONSTEXPR inline uint32_t rotr(uint32_t n, uint32_t r) noexcept {
  r &= 31;
  return (n >> r) | (n << (32 - r));
}
FMT_CONSTEXPR inline uint64_t rotr(uint64_t n, uint32_t r) noexcept {
  r &= 63;
  return (n >> r) | (n << (64 - r));
}

// Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox.
namespace dragonbox {
// Computes 128-bit result of multiplication of two 64-bit unsigned integers.
inline uint128_wrapper umul128(uint64_t x, uint64_t y) noexcept {
#if FMT_USE_INT128
  auto p = static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
  return {static_cast<uint64_t>(p >> 64), static_cast<uint64_t>(p)};
#elif defined(_MSC_VER) && defined(_M_X64)
  uint128_wrapper result;
  result.low_ = _umul128(x, y, &result.high_);
  return result;
#else
  const uint64_t mask =
      static_cast<uint64_t>(std::numeric_limits<uint32_t>::max());

  uint64_t a = x >> 32;
  uint64_t b = x & mask;