What does std::extent<int[5]>::value return in C++?

Options

  • B. 1
  • C. 5
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. 5

Detailed Explanation

Answer: (C) 5

std::extent returns the number of elements in a particular dimension of an array.

For a one-dimensional type int[5], the first dimension contains 5 elements. Therefore, std::extent<int[5]>::value returns 5.

This is different from std::rank<int[5]>::value, which would return 1 because the array has only one dimension.