Which C++ type trait checks whether a given type is an array type?

Options

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

Correct Answer (Detailed Explanation is Below)

A. std::is_array

Detailed Explanation

Answer: (A) std::is_array

std::is_array is a C++ type trait provided by the <type_traits> header. It checks whether a specified type is an array type.

For example, std::is_array<int[5]>::value is true because int[5] is an array type.

For a normal type such as int, the result is false.

This is useful when generic or template code needs to behave differently depending on whether the supplied type is an array.