llvm::OptionalValueCast

Cast trait that wraps value casts in std::optional.

Synopsis

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 */>

Description

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>.

Base Classes

NameDescription
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.

Static Member Functions

NameDescription
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.

Derived Classes

NameDescription
CastInfo<To, std::optional<From>> Provide a CastInfo specialized for casting out of std::optional.