CanCast
Function Usage
Checks whether a source type can be cast to a destination type.
Prototype
bool CanCast(const DataType from, const DataType to)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
from |
Input |
Source type. |
to |
Input |
Destination type. |
Returns
true: cast successfully; false: otherwise.
Constraints
None
Example
1 2 3 4 5 6 | // If dtype cannot be cast to int8 type, a return statement is executed. void Func(const DataType dtype) { if (!CanCast(dtype, DT_INT8)) { return; } } |
Parent topic: data_type_utils