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

来自cppreference.com
< cpp‎ | container‎ | mdspan‎ | extents
 
 
 
 
 
template< class OtherIndexType >
static constexpr auto /*index-cast*/( OtherIndexType&& i ) noexcept;
(C++23 起)
(仅用于阐述*)

OtherIndexType 类型的索引 i 转型为特定的整数类型。

等价于:

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

参数

i-要转型的索引

返回值

转型的索引。

注解

对此函数的调用总会返回 bool 之外的整数类型。由于此函数的调用点已经受到 OtherIndexTypeindex_type 类型转换性的约束,整数类类型可以使用 static_cast 分支而不会导致精度损失。