What is the value of std::rank<int[2][3][4]>::value in C++?

Options

  • A. 1
  • B. 2
  • C. 3
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. 3

Detailed Explanation

Answer: (C) 3

The std::rank type trait returns the number of dimensions of an array type.

The type int[2][3][4] contains three array dimensions: the first dimension is 2, the second is 3, and the third is 4.

Therefore, std::rank<int[2][3][4]>::value is 3.

The values 2, 3 and 4 represent the extents of the dimensions; they do not represent the rank.