[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 2 11:16:21 PDT 2023


zequanwu added a comment.

Hi, compiling llvm-10 code with this change causing compilation errors:

  ../../third_party/swiftshader/third_party/llvm-10.0/llvm/include/llvm/ADT/Optional.h:289:8: error: cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier
    289 |   auto map(const Function &F) &&
        |        ^
  ../../third_party/swiftshader/third_party/llvm-10.0/llvm/include/llvm/ADT/Optional.h:272:8: note: previous declaration is here
    272 |   auto map(const Function &F) const
        |        ^

Code snippet:

  template <typename T> class Optional {
  ...
    template <class Function>
    auto map(const Function &F) &&
        -> Optional<decltype(F(std::move(*this).getValue()))> {
      if (*this) return F(std::move(*this).getValue());
      return None;
    }
  ...
  }

Is it intentional?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140828



More information about the cfe-commits mailing list