[PATCH] D43704: Utility functions for checked arithmetic

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 13:44:33 PST 2018


vsk added inline comments.


================
Comment at: include/llvm/Support/CheckedArithmetic.h:33
+    T LHS, T RHS,
+    std::function<llvm::APInt(llvm::APInt *, const llvm::APInt &, bool &)> Op,
+    T *Res = nullptr) {
----------------
george.karpenkov wrote:
> vsk wrote:
> > I'd rather just have the type of the function be some free template parameter, then, so it's clear the object isn't copied.
> Could you elaborate?
I'm suggesting adding 'typename F' to the template parameter list and using F as the type of Op. It's shorter, and since there's no std::function, it signals to the reader that there are no unnecessary copies happening. Taken together this makes the code easier to read.


https://reviews.llvm.org/D43704





More information about the llvm-commits mailing list