Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

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

      LayoutMapping controls the mapping of a multidimensional index to a one-dimensional offset to data handle instd::mdspan.

      Contents

      [edit]Requirements

      A typeM satisfiesLayoutMapping if it modelscopyable andequality_comparable, 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
      M a layout mapping class
      Value Definition
      m a value of type (possibly const-qualified)M
      i,j packs of (possibly const-qualified) integers that are multidimensional indices inm.extents()
      r a (possibly const-qualified) rank index oftypename M​::​extents_type
      d_r a pack of (possibly const-qualified) integers for whichsizeof...(d_r)== M​::​extents_type​::​rank() istrue, the element at rank indexr is equal to1, and all other elements are equal to0

      [edit]Member types

      NameTypeRequirements
      M::extents_typeSpecialization of class templatestd::extents
      M::index_typetypename M::extents_type::index_type
      M::rank_typetypename M::extents_type::rank_type
      M::layout_typeLayout mapping policyMP wheretypename MP::template mapping<E> isM
      for some extents typeE
      LayoutMappingPolicy for whichM is mapping type ofMP

      [edit]Member functions and operators

      ExpressionReturn typeSemantics
      m.extents()consttypename M​::​extents_type&Returns constant reference to associated multidimensional index space
      m(i...)typename M​::​index_type
      • Returns a nonnegative integero such thato<std::numeric_limits<typename M​::​index_type>::​max() ando<=std::numeric_limits<std::size_t>::​max() are bothtrue.
      • Such expression is equivalent tom(static_cast<typename M::index_type>(i)...).
      m.required_span_size()typename M​::​index_type
      • Returns1 plus the maximum value ofm(i...) for alli if the size of the multidimensional index spacem.extents() is not 0.
      • Otherwise, returns0.
      m.is_unique()boolReturnstrue only if for everyi andj where(i!= j|| ...) istrue,m(i...)!= m(j...) istrue.[note 1]
      m.is_exhaustive()boolReturnstrue only if for allk in the range[0m.required_span_size()), there exists ani such thatm(i...) equalsk.[note 2]
      m.is_strided()boolReturnstrue only if for every rank indexr ofm.extents(), there exists an integers_r such that, for alli where(i+ d_r) is a multidimensional index inm.extents(),m((i+ d_r)...)- m(i...) equalss_r.[note 3]
      m.stride(r)typename M​::​index_type
      • The precondition is thatm.is_strided() istrue.
      • Returns a strides_r at rank indexr as defined inm.is_strided() above.
      M::is_always_unique()bool
      • Returnstrue only ifm.is_unique() istrue for all possible objectsm of typeM.[note 4]
      • The return value is always a constant expression.
      M::is_always_exhaustive()bool
      • Returnstrue only ifm.is_exhaustive() istrue for all possible objectsm of typeM.[note 5]
      • The return value is always a constant expression.
      M::is_always_strided()bool
      • Returnstrue only ifm.is_strided() istrue for all possible objectsm of typeM.[note 6]
      • The return value is always a constant expression.
      1. A mapping can returnfalse even if the condition is met. For certain layouts, it is possibly not feasible to determine efficiently whether the layout is unique.
      2. Same as above, but in the case of exhaustive layouts.
      3. Same as above, but in the case of strided layouts.
      4. A mapping can returnfalse even if the condition is met. For certain layout mappings, it is possibly not feasible to determine whether every instance is unique.
      5. Same as above, but in the case of exhaustive instances.
      6. Same as above, but in the case of strided instances.

      [edit]Concept

      For the constraints uses understd::layout_stride::mapping, the following exposition-only concept is defined.

      template<class M>

      concept/*layout-mapping-alike*/= requires
      {
          requires/*is-extents*/<typename M::extents_type>;
         { M::is_always_strided()}    ->std::same_as<bool>;
         { M::is_always_exhaustive()}->std::same_as<bool>;
         { M::is_always_unique()}    ->std::same_as<bool>;
         std::bool_constant<M::is_always_strided()>::value;
         std::bool_constant<M::is_always_exhaustive()>::value;
         std::bool_constant<M::is_always_unique()>::value;

      };
      (exposition only*)

      Defines the minimal usability constraints of theLayoutMapping requirement. This concept checks that the predicate mapping trait functions above exist, are constant expressions, and have a return type ofbool.

      /*is-extents*/<E> istrue if and only ifE is a specialization ofstd::extents.

      [edit]Standard library

      The following standard library types satisfyLayoutMapping requirements:

      a layout mapping oflayout_left
      (public member class template ofstd::layout_left)[edit]
      a layout mapping oflayout_right
      (public member class template ofstd::layout_right)[edit]
      a layout mapping oflayout_stride
      (public member class template ofstd::layout_stride)[edit]
      a layout mapping oflayout_left_padded
      (public member class template ofstd::layout_left_padded<PaddingValue>)[edit]
      a layout mapping oflayout_right_padded
      (public member class template ofstd::layout_right_padded<PaddingValue>)[edit]

      [edit]See also

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/LayoutMapping&oldid=178868"

      [8]ページ先頭

      ©2009-2025 Movatter.jp