#include "tensorstore/cast.h"
template <typename TargetElementType,
         
 int&... ExplicitArgumentBarrier,
         
 typename ElementType,
         
 DimensionIndex Rank,
         
 ReadWriteMode Mode>
auto tensorstore::Cast(
    
TensorStore<ElementType, Rank, Mode> store,
    
StaticDataType<TargetElementType> target_dtype = {});
template <int&... ExplicitArgumentBarrier,
         
 typename ElementType,
         
 DimensionIndex Rank,
         
 ReadWriteMode Mode>
Result<TensorStore<void,
                  
 Rank,
                  
 (Mode == ReadWriteMode::read_write
                       
 ? ReadWriteMode::dynamic
                       
 : Mode)>>
tensorstore::Cast(TensorStore<ElementType, Rank, Mode> store,
                  
DataType target_dtype);

Returns a view of a TensorStore with a converted data type.

The returned TensorStore supports read/write mode if, and only if, the input store supports the same mode and the necessary conversion is defined.

For example:

TensorStore<int32_t, 2, ReadWriteMode::read_write> a = ...;

// type: TensorStore<int64_t, 2, ReadWriteMode::read_write>
auto b = Cast<int64_t>(a);
// Supports both reading and writing, since `int32 <-> int64` conversion
// is supported in both directions.

// type: TensorStore<std::string, 2, ReadWriteMode::read>
auto c = Cast<std::string>(a);
// Supports reading only, since `int32 -> string` conversion is
// supported but `string -> int32` is not.

TensorStore<std::string, 2, ReadWriteMode::read_write> d = ...;

// type: TensorStore<std::string, 2, ReadWriteMode::write>
auto d = Cast<int32_t>(d);
// Supports writing only, since `int32 -> string` conversion is
// supported but `string -> int32` is not.
Template Parameters:
typename TargetElementType

The target element type, must be unqualified.

Parameters:
TensorStore<ElementType, Rank, Mode> store

The TensorStore to convert.

StaticDataType<TargetElementType> target_dtype = {}
DataType target_dtype

May be specified in order to allow TargetElementType to be inferred.

Error absl::StatusCode::kInvalidArgument:

if neither reading nor writing would be supported by the returned TensorStore.