[llvm-dev] [RFC] Coding Standards: "prefer `int` for regular arithmetic, use `unsigned` only for bitmask and when you intend to rely on wrapping behavior."

Michael Kruse via llvm-dev
2019-06-10T16:24:57Z

Am Sa., 8. Juni 2019 um 13:12 Uhr schrieb Tim Northover via llvm-dev
<llvm-dev at lists.llvm.org>:
> I'd prefer us to have something neater than static_cast<int> for
the
> loop problem before we made that change. Perhaps add an ssize (or
> equivalent) method to all of our internal data structures? They're a
> lot more common than std::* containers.

+1

Since C++20 is also introducing ssize [1] members, this makes a lot of
sense to me. Using it would help avoiding an unsigned comparison as in

    if (IndexOfInterestingElement >= Container.size())
      ...

to sneak in from the start.

Michael

[1] http://wg21.link/p1227r1