std::extent...tatic_extent(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::extents::static_extent β€” std::extents::static_extent. Yes bestie, the NAME section is literally the same thing twice, and we're on the std::extent...tatic_extent(3) page inside the C++ Standard Libary manual. Lowkey iconic.


✨ Synopsis ✨

static constexpr std::size_t static_extent( rank_type i ) noexcept;

(since C++23) β€” this one has been serving since C++23, periodt.

Okay so this returns the static extent size of an extents at the rank index i. If the rank index i is a dynamic extent, it returns std::dynamic_extent. Slay.


πŸŽ€ Parameters πŸŽ€

  • i β€” the rank index to get the static extent size of. That's the whole assignment, bestie.

πŸ¦‹ Return value πŸ¦‹

The static extent size, or the std::dynamic_extent value. Simple as that. πŸ’…


🌈 Example 🌈

Run this code, bestie:

// Run this code

        #include <iostream>
        #include <mdspan>

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

πŸ“ Output πŸ“

1, 2
0, 1, 1

πŸ‘‘ See also πŸ‘‘

  • extent β€” returns dynamic extent size of an extents at a certain rank index (public member function).
  • extent β€” obtains the size of an array type along a specified dimension (C++11) (class template).

mwah πŸ’‹ this little page is from http://cppreference.com, dated 2024.06.10, and the footer vibes are std::extent...tatic_extent(3). πŸŽ€

πŸ“¦ where this page comes from