struct CastInfo
Declaration
template <typename To, typename From, typename Enable = void>
struct CastInfo { /* full declaration omitted */ };
Description
This struct provides a method for customizing the way a cast is performed. It inherits from CastIsPossible, to support the case of declaring many CastIsPossible specializations without having to specialize the full CastInfo. In order to specialize different behaviors, specify different functions in your CastInfo specialization. For isa < > customization, provide: `static bool isPossible(const From &f )` For cast < > customization, provide: `static To doCast(const From &f )` For dyn_cast < > and the *_if_present < > variants' customization, provide: `static To castFailed()` and `static To doCastIfPossible(const From &f )` Your specialization might look something like this: template < > struct CastInfo <foo , bar> : public CastIsPossible <foo , bar> { static inline foo doCast(const bar &b ) { return foo(const_cast <bar & >(b)); } static inline foo castFailed() { return foo(); } static inline foo doCastIfPossible(const bar &b ) { if (!CastInfo <foo , bar>::isPossible(b)) return castFailed(); return doCast(b); } };
Declared at: llvm/include/llvm/Support/Casting.h:477
Templates
- To
- From
- Enable = void
Method Overview
- public static inline llvm::CastInfo::CastReturnType castFailed()
- public static inline llvm::CastInfo::CastReturnType doCast(const From & f)
- public static inline llvm::CastInfo::CastReturnType doCastIfPossible(const From & f)
Methods
¶static inline llvm::CastInfo::CastReturnType
castFailed()
static inline llvm::CastInfo::CastReturnType
castFailed()
Declared at: llvm/include/llvm/Support/Casting.h:491
¶static inline llvm::CastInfo::CastReturnType
doCast(const From& f)
static inline llvm::CastInfo::CastReturnType
doCast(const From& f)
Declared at: llvm/include/llvm/Support/Casting.h:482
Parameters
- const From& f
¶static inline llvm::CastInfo::CastReturnType
doCastIfPossible(const From& f)
static inline llvm::CastInfo::CastReturnType
doCastIfPossible(const From& f)
Declared at: llvm/include/llvm/Support/Casting.h:493
Parameters
- const From& f