Cast trait that wraps value casts in std::optional.
Declared in <llvm/Support/Casting.h>
template<
typename To,
typename From,
typename Derived = void>
struct OptionalValueCast
: CastIsPossible<To, From>
, DefaultDoCastIfPossible<std::optional<To>, From, /* implementation-defined */>
This cast trait provides std::optional<T> casting. This means that if you have a value type, you can cast it to another value type and have dyn_cast return an std::optional<T>.
| Name | Description |
|---|---|
CastIsPossible<To, From> | Trait that reports whether a cast from From to To is possible. |
DefaultDoCastIfPossible<std::optional<To>, From, /* implementation-defined */> | Provides a default doCastIfPossible that uses isPossible and doCast. |
| Name | Description |
|---|---|
castFailed | Returns an empty optional when the cast fails. |
doCast | Constructs a To from f and wraps it in std::optional. |
doCastIfPossible | Casts f to To if possible; otherwise returns castFailed(). |
isPossible | Returns true if a cast from f to To is possible. |
| Name | Description |
|---|---|
CastInfo<To, std::optional<From>> | Provide a CastInfo specialized for casting out of std::optional. |