命名空间
变体
操作

std::extents<IndexType,Extents...>::index-cast

来自 cppreference.cn
< cpp‎ | 容器‎ | mdspan‎ | extents
 
 
 
 
 
template< class OtherIndexType >
static constexpr auto /*index-cast*/( OtherIndexType&& i ) noexcept;
(C++23 起)
(仅作说明*)

将类型为 OtherIndexType 的索引 i 转换为某个整数类型。

它等价于

  • return i;,如果 OtherIndexType 是除 bool 之外的整数类型,并且
  • 否则为 return static_cast<index_type>(i);

[编辑] 参数

i - 要转换的索引

[编辑] 返回值

转换后的索引。

[编辑] 注意

对该函数的调用将始终返回除 bool 之外的整数类型。整数类类型可以使用 static_cast 分支而不会丢失精度,因为此函数的调用点已经限制了 OtherIndexTypeindex_type 的可转换性。