#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 specified Target 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 and Target are instances of the same class template, but differ in one or more template arguments. For example, the source type may be ArrayView<void, dynamic_rank> with a target type of ArrayView<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 is Result<Target> and an error absl::Status is returned if the cast is not valid. If equal to CastChecking::unchecked, the return type is a bare Target cast is validated in debug mode only via an assert. A value of CastChecking::unchecked may be more conveniently specified using the special tag value tensorstore::unchecked.

Parameters:
SourceRef &&source

Source value.

Requires:

IsStaticCastConstructible<Target, SourceRef>