Which type trait can be used to determine whether a C++ type is a floating-point type?
Options
- A. std::is_integral
- B. std::is_floating_point
- C. std::is_pointer
- D. More than one of the above
- E. None of the above
Quiz Practice:
B. std::is_floating_point
Answer: (B) std::is_floating_point
std::is_floating_point checks whether a type is a floating-point type.
Common floating-point types in C++ include float, double and long double.
For example, std::is_floating_point<double>::value evaluates to true.
This type trait is useful in template programming when different behavior is required for floating-point and non-floating-point types.