[PATCH] D139779: [Support] Add transformOptional
Kazu Hirata via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 10 15:22:48 PST 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.
llvm::Optional<T> has transform, which is equivalent to
std::optional<T>::transform. The problem is that
std::optional<T>::transform won't be available until C++23, implying
that we probably cannot use it in our codebase untli 2028 or so. We
certainly don't want to keep llvm::Optional just for transform.
This patch adds transformOptional to STLForwardCompat.h so that we can
use transform during the migration to std::optional and beyond.
I've shamelessly borrowed the implementation and test from
llvm/include/llvm/ADT/Optional.h and
llvm/unittests/ADT/OptionalTest.cpp, respectively.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139779
Files:
llvm/include/llvm/ADT/STLForwardCompat.h
llvm/unittests/ADT/STLForwardCompatTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139779.481884.patch
Type: text/x-patch
Size: 5362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221210/a0160af0/attachment.bin>
More information about the llvm-commits
mailing list