Which C++ type trait removes all array dimensions from an array type?

Options

  • A. std::remove_extent
  • B. std::remove_all_extents
  • C. std::rank
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. std::remove_all_extents

Detailed Explanation

Answer: (B) std::remove_all_extents

std::remove_all_extents removes all array dimensions from an array type.

For example, if the type is int[2][3][4], applying std::remove_all_extents produces the underlying element type int.

This differs from std::remove_extent, which removes only the outermost array dimension.

These traits are useful in generic and template programming when the underlying element type is required.