std::full_e...ull_extent_t(3)
okay so π this is the std::full_e...ull_extent_t(3) page from the C++ Standard Libary manual, and it's literally about the slice-specifier duo std::full_extent and std::full_extent_t. bestie, they're the βgimme the whole rangeβ besties for std::submdspan, no cap. π«Ά
π NAME π
std::full_extent,std::full_extent_t β std::full_extent,std::full_extent_t
yes bestie, the name is exactly that, comma and all. iconic. π
β¨ Synopsis β¨
Defined in header <mdspan>:
struct full_extent_t { explicit full_extent_t() = default; }; (1)
(since C++26)
inline constexpr std::full_extent_t full_extent {}; (2)
(since C++26)
okay so 1) the class std::full_extent_t is a slice specifier type that can be used in std::submdspan.
and 2) the corresponding std::full_extent instance of (1) is a slice specifier to indicate full range of indices in the specified extent in std::submdspan. periodt. β¨
since C++26, bestie β this is the new-new era, so keep that in mind. π¦
πΈ Example πΈ
// Run this code
#include <mdspan>
#include <print>
void print_view(auto view)
{
static_assert(view.rank() <= 2);
if constexpr (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("");
}
}
else if constexpr (view.rank() == 1)
{
for (std::size_t i = 0; i < view.extent(0); ++i)
std::print("{} ", view[i]);
std::println("");
}
else
{
std::println("{}", view[]);
}
std::println("");
}
int main()
{
char letters [] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I' };
std::mdspan view (letters, 3, 3);
print_view(view);
print_view(std::submdspan(view, std::full_extent,
std::full_extent));
print_view(std::submdspan(view, std::full_extent, 1));
print_view(std::submdspan(view, 1, std::full_extent));
print_view(std::submdspan(view, 2, 1));
}
π Possible output π
A B C
D E F
G H I
A B C
D E F
G H I
B E H
D E F
H
π¦ See also π¦
submdspanβ returns a view of a subset of an existingmdspan(C++26) (function template)
made with π by the http://cppreference.com girlies, version/date 2024.06.10, and the page is std::full_e...ull_extent_t(3). periodt. π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms