[PATCH] D58421: Add partial implementation of std::to_address() as llvm::to_address()

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 19 21:03:58 PST 2019


dblaikie added inline comments.


================
Comment at: include/llvm/ADT/STLExtras.h:1589-1592
+template <class Ptr>
+typename Ptr::element_type *to_address(const Ptr &P) noexcept {
+  return P.operator->();
+}
----------------
dexonsmith wrote:
> Can you use `decltype(std::declval<Ptr>().operator->())` instead of `typename Ptr::element_type *` to avoid requiring an `element_type` typedef?
Yep, or late bound return:

  auto to_address(const Ptr &P) -> decltype(P.operator->()) { return P.operator->(); }

Also probably leave off the noexcept - LLVM doesn't build with exceptions anyway. So there's not a lot/much point in littering noexcept everywhere.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58421





More information about the llvm-commits mailing list