[PATCH] D131842: [ADT] Deprecate Optional::map

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 13 12:07:48 PDT 2022


kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch deprecates Optional::map in favor of Optional::transform
for consistency with std::optional::transform in C++23.

Note that I've migrated all known users of Optional::map.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131842

Files:
  llvm/include/llvm/ADT/Optional.h


Index: llvm/include/llvm/ADT/Optional.h
===================================================================
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -348,6 +348,7 @@
     return None;
   }
   template <class Function>
+  LLVM_DEPRECATED("Use transform instead.", "transform")
   auto map(const Function &F) const & -> Optional<decltype(F(value()))> {
     if (*this)
       return F(value());
@@ -378,6 +379,7 @@
     return None;
   }
   template <class Function>
+  LLVM_DEPRECATED("Use transform instead.", "transform")
   auto map(const Function &F)
       && -> Optional<decltype(F(std::move(*this).value()))> {
     if (*this)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131842.452445.patch
Type: text/x-patch
Size: 669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220813/91d25e45/attachment.bin>


More information about the llvm-commits mailing list