Scroll to navigation

std::extents::rank(3) C++ Standard Libary std::extents::rank(3)

NAME

std::extents::rank - std::extents::rank

Synopsis


static constexpr rank_type rank() const noexcept; (since C++23)


Returns the number of dimensions in extents.

Parameters


(none)

Return value


The number of dimensions.

Example

// Run this code


#include <iostream>
#include <mdspan>


int main()
{
std::extents<int, 1, 2> e1;
std::extents<int, 3, 4, std::dynamic_extent> e2(5);
std::cout << e1.rank() << ", " << e2.rank() << '\n';
}

Output:


2, 3

See also


rank_dynamic returns the dynamic rank of an extents
[static] (public static member function)
rank obtains the number of dimensions of an array type
(C++11) (class template)

2024.06.10 http://cppreference.com