llvm-project
0029815a - [ADT] Support `.Default` with `nullptr` and `nullopt` values in TypeSwitch (#165724)

Commit
8 days ago
[ADT] Support `.Default` with `nullptr` and `nullopt` values in TypeSwitch (#165724) In the previous implementation, this would fail for cases like `TypeSwitch<T*, std::optional<U>>` because `std::nullopt` does not match `ResultT` exactly and the overload for callable types would be selected. Add new overloads that support `nullptr` and `std::nullopt`. These can be added alongside generic callables because we wouldn't want to call any 'null' function refs anyway. I selected the `nullptr` and `nullopt` specializations because how often they appear in the codebase -- currently, you will see lots of code like `.Default(std::optional<T>())` that can be simplified with this patch.
Author
Parents
Loading