Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++14) |
Defined in header <type_traits> | ||
template<class T> struct is_floating_point; | (since C++11) | |
std::is_floating_point
is aUnaryTypeTrait.
Checks whetherT
is a floating-point type. Provides the member constantvalue which is equal totrue, ifT
is the typefloat,double,longdouble, or any extended floating-point types (std::float16_t,std::float32_t,std::float64_t,std::float128_t, orstd::bfloat16_t)(since C++23), including any cv-qualified variants. Otherwise,value is equal tofalse.
If the program adds specializations forstd::is_floating_point
orstd::is_floating_point_v
, the behavior is undefined.
Contents |
T | - | a type to check |
template<class T> constexprbool is_floating_point_v= is_floating_point<T>::value; | (since C++17) | |
value [static] | true ifT is a floating-point type (possibly cv-qualified),false otherwise(public static member constant) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
template<class T>struct is_floating_point:std::integral_constant<bool,// Note: standard floating-point typesstd::is_same<float,typenamestd::remove_cv<T>::type>::value||std::is_same<double,typenamestd::remove_cv<T>::type>::value||std::is_same<longdouble,typenamestd::remove_cv<T>::type>::value// Note: extended floating-point types (C++23, if supported)||std::is_same<std::float16_t,typenamestd::remove_cv<T>::type>::value||std::is_same<std::float32_t,typenamestd::remove_cv<T>::type>::value||std::is_same<std::float64_t,typenamestd::remove_cv<T>::type>::value||std::is_same<std::float128_t,typenamestd::remove_cv<T>::type>::value||std::is_same<std::bfloat16_t,typenamestd::remove_cv<T>::type>::value>{}; |
#include <type_traits> class A{};static_assert(!std::is_floating_point_v<A>); static_assert(std::is_floating_point_v<float>);static_assert(!std::is_floating_point_v<float&>);static_assert(std::is_floating_point_v<double>);static_assert(!std::is_floating_point_v<double&>);static_assert(!std::is_floating_point_v<int>); int main(){}
[static] | identifies the IEC 559/IEEE 754 floating-point types (public static member constant of std::numeric_limits<T> )[edit] |
(C++11) | checks if a type is an integral type (class template)[edit] |
(C++11) | checks if a type is an arithmetic type (class template)[edit] |
(C++20) | specifies that a type is a floating-point type (concept)[edit] |