Support Software for Vector Reduction/Transformation Operators Version of the Day
Default traits class for all conversions of value types. More...
Default traits class for all conversions of value types.
This default traits class simply does an implicit type conversion. Therefore, any conversions that are built into the language and are safe do not need a traits class specialization and should not generate any compiler warnings. For example, the conversions
short type to
long type, and an enum value to
int are all always value preserving and should never result in a compiler warning or any aberrant runtime behavior.
All other conversions that cause compiler warnings and/or could result in aberrant runtime behavior (e.g.
type to and from
unsigned type, to and from floating point and integral types, etc.), or do not have compiler defined conversions (e.g.
double etc.) should be given specializations of this class template. If an unsafe or non-supported conversion is requested by a client (i.e. through
asSafe()) then this default traits class will be instantiated and the compiler will either generate a warning message (if the conversion is supported but is unsafe) or will not compile the code (if the conversion is not supported by default in C++). When this happens, a specialization can be added or the client code can be changed to avoid the conversion.