Namespaces
Variants

std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>:: operator[]

From cppreference.net
template < class ... OtherIndexTypes >
constexpr reference operator [ ] ( OtherIndexTypes... indices ) const ;
(1) (C++23 이후)
template < class OtherIndexType >

constexpr reference operator [ ]

( std:: span < OtherIndexType, rank ( ) > indices ) const ;
(2) (C++23 이후)
template < class OtherIndexType >

constexpr reference operator [ ]

( const std:: array < OtherIndexType, rank ( ) > & indices ) const ;
(3) (C++23 이후)

mdspan의 indices 번째 요소에 대한 참조를 반환합니다.

1) 다음에 해당함 return acc_  . access ( ptr_ , map_  ( static_cast < index_type > ( std :: move ( indices ) ) ... ) ) ; .
이 오버로드는 다음의 모든 값이 true 인 경우에만 오버로드 해결에 참여합니다:

extents_type :: index-cast  ( std :: move ( indices ) ) extents ( ) 의 다차원 인덱스가 아닌 경우, 동작은 정의되지 않습니다.

(C++26까지)

extents_type :: index-cast  ( std :: move ( indices ) ) extents ( ) 의 다차원 인덱스가 아닌 경우:

  • 구현이 hardened 된 경우, 계약 위반 이 발생합니다. 또한 계약 위반 핸들러가 "observe" 평가 의미론 하에 반환하는 경우, 동작은 정의되지 않습니다.
  • 구현이 hardened되지 않은 경우, 동작은 정의되지 않습니다.
(C++26부터)
2,3) P 를 다음 조건을 만족하는 매개변수 팩이라고 하자: std:: is_same_v < std:: make_index_sequence < rank ( ) > ,
std:: index_sequence < P... >>
true 인 경우, 다음 코드와 동등하다: return operator [ ] ( extents_type :: index-cast  ( std:: as_const ( indices [ P ] ) ) ... ) ; .
이 오버로드는 다음의 모든 값이 true 인 경우에만 오버로드 해결에 참여합니다:

목차

매개변수

indices - 접근할 요소의 인덱스들

반환값

요소에 대한 참조입니다.

예제

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 3974 C++23 오버로드 (2,3) extents_type:: index-cast 를 적용하지 않음 적용함

참고 항목