Cast trait that moves a unique_ptr during a successful cast.

Synopsis

Declared in <llvm/Support/Casting.h>

template<
    typename To,
    typename From,
    typename Derived = void>
struct UniquePtrCast
    : CastIsPossible<To, From*>

Description

This cast trait provides std::unique_ptr casting. It has the semantics of moving the contents of the input unique_ptr into the output unique_ptr during the cast. It's also a good example of how to implement a move‐only cast.

Base Classes

Name

Description

CastIsPossible<To, From*>

Trait that reports whether a cast from From to To is possible.

Type Aliases

Name

Description

CastResultType

unique_ptr result type produced by this unique_ptr cast.

Self

Derived cast type used to call static helpers through CRTP.

Static Member Functions

Name

Description

castFailed

Returns a null unique_ptr when the cast fails.

doCast

Moves f into a unique_ptr of the cast result type.

doCastIfPossible

Moves and casts f if possible; otherwise returns null.

isPossible

Returns true if a cast from f to To is possible.

Derived Classes

Name

Description

CastInfo<To, std::unique_ptr<From>>

Provide a CastInfo specialized for std::unique_ptr.

Created with MrDocs