LLVM 20.0.0git
|
This struct provides a method for customizing the way a cast is performed. More...
#include "llvm/Support/Casting.h"
Public Types | |
using | Self = CastInfo< To, From, Enable > |
using | CastReturnType = typename cast_retty< To, From >::ret_type |
Static Public Member Functions | |
static CastReturnType | doCast (const From &f) |
static CastReturnType | castFailed () |
static CastReturnType | doCastIfPossible (const From &f) |
Static Public Member Functions inherited from llvm::CastIsPossible< To, From, Enable > | |
static bool | isPossible (const From &f) |
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); } };
using llvm::CastInfo< To, From, Enable >::CastReturnType = typename cast_retty<To, From>::ret_type |
|
inlinestatic |
Definition at line 490 of file Casting.h.
Referenced by llvm::cast_if_present(), llvm::CastInfo< To, From, Enable >::doCastIfPossible(), and llvm::dyn_cast_if_present().
|
inlinestatic |
Definition at line 481 of file Casting.h.
References From.
Referenced by llvm::cast(), and llvm::CastInfo< To, From, Enable >::doCastIfPossible().
|
inlinestatic |
Definition at line 492 of file Casting.h.
References llvm::CastInfo< To, From, Enable >::castFailed(), llvm::CastInfo< To, From, Enable >::doCast(), and llvm::CastIsPossible< To, From, Enable >::isPossible().
Referenced by llvm::dyn_cast(), and llvm::dyn_cast_if_present().