MCPcopy Create free account
hub / github.com/0voice/cpp_new_features / main

Function main

cpp_11/003_rtti_extent.cpp:4–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include <type_traits>
3
4int main()
5{
6 std::cout << std::extent<int[3]>::value << '\n'; // < 默认维度为 0
7 std::cout << std::extent<int[3][4], 0>::value << '\n';
8 std::cout << std::extent<int[3][4], 1>::value << '\n';
9 std::cout << std::extent<int[3][4], 2>::value << '\n';
10 std::cout << std::extent<int[]>::value << '\n';
11
12 const auto ext = std::extent<int[9]>{};
13 std::cout << ext << '\n'; // < 隐式转换到 std::size_t
14
15 const int ints[] = {1,2,3,4};
16 std::cout << std::extent<decltype(ints)>::value << '\n'; // < 数组大小
17}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected