-
#include "tensorstore/data_type.h"
-
template <typename TargetElement,
CastChecking Checking = CastChecking::checked,
typename SourceRef>
StaticCastResultType<RebindDataType<SourceRef, TargetElement>,
SourceRef,
Checking>
tensorstore::StaticDataTypeCast(SourceRef&& source); Casts
source
to have a static data type ofTargetElement
.The source type must be supported by
RebindDataType
and define a nestedElement
type, and both the source and target types must be supported byStaticCast
.The semantics of the
Checking
parameter are the same as forStaticCast
.This cast cannot be used to cast away const qualification of the source element type. To do that, use
ConstDataTypeCast
instead.Examples:
Array<void> array = ...; Result<Array<int>> result = StaticDataTypeCast<int>(array); Result<Array<const int>> result2 = StaticDataTypeCast<const int>(array); Array<const int> unchecked_result = StaticDataTypeCast<const int, unchecked>(array); DataType d = ...; Result<dtype_t<int>> d_static = StaticDataTypeCast<int>(d); dtype_t<int> d_int; DataType d_dynamic = StaticDataTypeCast<void>(d_int);
- Template Parameters:¶
- typename TargetElement¶
Target element type. Depending on the source type,
const
-qualifiedTargetElement
types may or may not be supported.- CastChecking Checking = CastChecking::checked¶
Specifies whether the cast is checked or unchecked.
- Parameters:¶