[PATCH] D106279: [llvm] Add enum iteration to Sequence

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 20 05:32:09 PDT 2021


courbet added inline comments.


================
Comment at: llvm/include/llvm/ADT/Sequence.h:37
 
-private:
-  struct Forward {
-    static void increment(T &V) { ++V; }
-    static void decrement(T &V) { --V; }
-    static void offset(T &V, difference_type Offset) { V += Offset; }
-    static T add(const T &V, difference_type Offset) { return V + Offset; }
-    static difference_type difference(const T &A, const T &B) { return A - B; }
-  };
-
-  struct Reverse {
-    static void increment(T &V) { --V; }
-    static void decrement(T &V) { ++V; }
-    static void offset(T &V, difference_type Offset) { V -= Offset; }
-    static T add(const T &V, difference_type Offset) { return V - Offset; }
-    static difference_type difference(const T &A, const T &B) { return B - A; }
-  };
-
-  using Op = std::conditional_t<!IsReversed, Forward, Reverse>;
-
-public:
+struct StrongInt {
   // default-constructible
----------------
gchatelet wrote:
> gchatelet wrote:
> > courbet wrote:
> > > `OverflowCheckingInt` ?
> > > `OverflowCheckingInt` ?
> > 
> > I went with `SafeInt` as it's shorter and conveys the idea.
> > > `OverflowCheckingInt` ?
> > 
> > I went with `SafeInt` as it's shorter and conveys the idea.
> 
> @courbet `CheckedInt` maybe?
`CheckedInt` sounds good


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106279/new/

https://reviews.llvm.org/D106279



More information about the llvm-commits mailing list