WPILibC++ 2024.3.2
|
This struct provides a method for customizing the way a cast is performed. More...
#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include/wpi/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 wpi::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 wpi::CastInfo< To, From, Enable >::CastReturnType = typename cast_retty<To, From>::ret_type |
using wpi::CastInfo< To, From, Enable >::Self = CastInfo<To, From, Enable> |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |