[all-commits] [llvm/llvm-project] 21a344: [Support] Add llvm::transformOptional
kazutakahirata via All-commits
all-commits at lists.llvm.org
Wed Dec 14 14:51:19 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 21a3447564735833909b14b681454997991f35f8
https://github.com/llvm/llvm-project/commit/21a3447564735833909b14b681454997991f35f8
Author: Kazu Hirata <kazu at google.com>
Date: 2022-12-14 (Wed, 14 Dec 2022)
Changed paths:
M llvm/include/llvm/ADT/STLForwardCompat.h
M llvm/unittests/ADT/STLForwardCompatTest.cpp
Log Message:
-----------
[Support] Add llvm::transformOptional
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 llvm::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
Differential Revision: https://reviews.llvm.org/D139779
More information about the All-commits
mailing list