Which C++ type trait is used to determine whether a type is a reference type?

Options

  • A. std::is_reference
  • B. std::is_pointer
  • C. std::is_void
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. std::is_reference

Detailed Explanation

Answer: (A) std::is_reference

std::is_reference checks whether a specified type is a reference type.

For example, std::is_reference<int&>::value returns true because int& is an lvalue reference type.

A normal type such as int is not a reference, so the result would be false.

This trait is commonly useful in template metaprogramming and generic programming.