-
#include "tensorstore/static_cast.h"
-
template <typename Target,
CastChecking Checking = CastChecking::checked,
typename SourceRef>
requires IsStaticCastConstructible<Target, SourceRef>
StaticCastResultType<Target, SourceRef, Checking>
tensorstore::StaticCast(SourceRef&& source); Type-erasure-aware conversion of
source
to the specifiedTarget
type.Example:
tensorstore::Box<> b = ...; BoxView<5> b_view = tensorstore::StaticCast<tensorstore::BoxView<5>, tensorstore::unchecked>(b); Result<BoxView<5>> b_view_result = tensorstore::StaticCast<tensorstore::BoxView<5>>(b);
- Template Parameters:¶
- typename Target¶
Target type. Typically, both
SourceRef
andTarget
are instances of the same class template, but differ in one or more template arguments. For example, the source type may beArrayView<void, dynamic_rank>
with a target type ofArrayView<int, 3>
.- CastChecking Checking = CastChecking::checked¶
Specifies whether to validate the cast at run time. If equal to
CastChecking::checked
(the default), the return type isResult<Target>
and an errorabsl::Status
is returned if the cast is not valid. If equal toCastChecking::unchecked
, the return type is a bareTarget
cast is validated in debug mode only via anassert
. A value ofCastChecking::unchecked
may be more conveniently specified using the special tag valuetensorstore::unchecked
.
- Parameters:¶
- Requires:¶