Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::full_extent,std::full_extent_t

      From cppreference.com
      <cpp‎ |container‎ |mdspan
       
       
       
       
      Defined in header<mdspan>
      struct full_extent_t{explicit full_extent_t()=default;};
      (1)(since C++26)
      inlineconstexpr std::full_extent_t full_extent{};
      (2)(since C++26)
      1) The classstd::full_extent_t is a slice specifier type that can be used instd::submdspan.
      2) The correspondingstd::full_extent instance of(1) is a slice specifier to indicate full range of indices in the specified extent instd::submdspan.

      [edit]Example

      Run this code
      #include <mdspan>#include <print> void print(auto view){    static_assert(view.rank()<=2); ifconstexpr(view.rank()==2){for(std::size_t i=0; i!= view.extent(0);++i){for(std::size_t j=0; j!= view.extent(1);++j)std::print("{} ", view[i, j]);std::println();}}elseifconstexpr(view.rank()==1){for(std::size_t i=0; i!= view.extent(0);++i)std::print("{} ", view[i]);std::println();}elsestd::println("{}", view[]); std::println();} int main(){constchar letters[]{'A','B','C','D','E','F','G','H','I'};conststd::mdspan view(letters,3,3);     print(view);    print(std::submdspan(view, std::full_extent, std::full_extent));    print(std::submdspan(view, std::full_extent,1));    print(std::submdspan(view,1, std::full_extent));    print(std::submdspan(view,2,1));}

      Possible output:

      A B CD E FG H I A B CD E FG H I B E H D E F H

      [edit]See also

      (C++26)
      returns a view of a subset of an existingmdspan
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/container/mdspan/full_extent&oldid=172793"

      [8]ページ先頭

      ©2009-2026 Movatter.jp