Namespaces
Variants
Actions

std::extents<IndexType,Extents...>::rank

From cppreference.com
< cpp‎ | container‎ | mdspan‎ | extents
 
C++
 
Containers library
 
std::mdspan
 
std::extents
static constexpr rank_type rank() const noexcept;
(since C++23)

Returns the number of dimensions in extents.

Contents

[edit] Parameters

(none)

[edit] Return value

The number of dimensions.

[edit] Example

#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

[edit] See also

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

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant