| 2 | #include <type_traits> |
| 3 | |
| 4 | int 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected