Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:AccessorPolicy(since C++23)

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      AccessorPolicy defines how elements are accessed from a given data handle to such elements and an index. It is used as a policy instd::mdspan to specify the access to a reference of an element using an underlying 1D index.

      Contents

      [edit]Requirements

      A typeA satisfiesAccessorPolicy if it modelscopyable, and the following aretrue:

      And, given the following types and values, the expressions shown in the table below are valid and have the indicated semantics:

      [edit]Legend

      Type Definition
      A an accessor policy type
      OP an offset policy type
      Value Definition
      a a value of type (possibly const-qualified)A
      p a value of type (possibly const-qualified)A::data_handle_type
      i,j,n values of typestd::size_t

      [edit]Member types

      TypeDefinitionRequirements
      A::element_typeunspecified
      • A complete object type that is not an abstract class type
      A::data_handle_typeunspecified[1]
      • Modelscopyable
      • The following values are alltrue:
      A::referenceunspecified[2]
      A::offset_policyOP
      • Satisfies the requirements ofAccessorPolicy
      • std::constructible_from<OP,const A&> istrue
      • typename OP​::​element_type andtypename A​::​element_type are the same type
      1. Not required to beelement_type*.
      2. Not required to beelement_type&.

      [edit]Member functions

      ExpressionReturn typeSemantics
      a.access(p, i)typename A::reference
      a.offset(p, i)typename A::offset_policy
                ::data_handle_type
      • A valueq such that forb beingA::offset_policy(a), and any integern for which[0n) is an accessible range (see below) ofp anda.
      • [0n- i) is an accessible range ofq andb; and
      • b.access(q, j) provides access to the same element asa.access(p, i+ j), for everyj in the range[0n- i).

      [edit]Accessible range

      A range of indices[0N) is anaccessible range of a given data handle and an accessor if, for each index in the range, theaccess member function produces a valid reference to an element.

      [edit]Standard library

      The following standard library types satisfyAccessorPolicy requirements:

      a type for indexed access to elements ofmdspan
      (class template)[edit]
      a type for aligned access to elements ofmdspan
      (class template)[edit]
      Defined in namespacestd::linalg
      std::mdspan accessor policy whose reference represents the product of a scaling factor that is fixed and its nestedstd::mdspan accessor's reference
      (class template)[edit]
      std::mdspan accessor policy whose reference represents the complex conjugate of its nestedstd::mdspan accessor's reference
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/AccessorPolicy&oldid=182297"

      [8]ページ先頭

      ©2009-2025 Movatter.jp