Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

      From cppreference.com
      <cpp‎ |container‎ |mdspan
       
       
       
       
      template<class...OtherIndexTypes>
      constexpr reference operator[]( OtherIndexTypes...indices)const;
      (1)(since C++23)
      template<class OtherIndexType>

      constexpr reference operator[]

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

      constexpr reference operator[]

         (conststd::array<OtherIndexType, rank()>& indices)const;
      (3)(since C++23)

      Returns a reference to theindicesth element of the mdspan.

      1) Equivalent toreturn acc_ .access(ptr_, map_ (static_cast<index_type>(std::move(indices))...));.
      This overload participates in overload resolution only if all following values aretrue:

      Ifextents_type::index-cast (std::move(indices)) is not a multidimensional index inextents(), the behavior is undefined.

      (until C++26)

      Ifextents_type::index-cast (std::move(indices)) is not a multidimensional index inextents():

      • If the implementation ishardened, acontract violation occurs. Moreover, if the contract-violation handler returns under “observe” evaluation semantic, the behavior is undefined.
      • If the implementation is not hardened, the behavior is undefined.
      (since C++26)
      2,3) LetP be a parameter pack such thatstd::is_same_v<std::make_index_sequence<rank()>,
                     std::index_sequence<P...>>
      istrue, equivalent toreturn operator[](extents_type::index-cast (std::as_const(indices[P]))...);.
      This overload participates in overload resolution only if all following values aretrue:

      Contents

      [edit]Parameters

      indices - the indices of the element to access

      [edit]Return value

      A reference to the element.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3974C++23overloads(2,3) did not applyextents_type::index-castapplies

      [edit]See also

      This section is incomplete
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/container/mdspan/operator_at&oldid=182299"

      [8]ページ先頭

      ©2009-2025 Movatter.jp