-
#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
sourceto the specifiedTargettype.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
SourceRefandTargetare 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::Statusis returned if the cast is not valid. If equal toCastChecking::unchecked, the return type is a bareTargetcast is validated in debug mode only via anassert. A value ofCastChecking::uncheckedmay be more conveniently specified using the special tag valuetensorstore::unchecked.
- Parameters:¶
- Requires:¶