std:: is_floating_point
|
Definido en el encabezado
<type_traits>
|
||
|
template
<
class
T
>
struct is_floating_point ; |
(desde C++11) | |
std::is_floating_point
es un
UnaryTypeTrait
.
Comprueba si
T
es un tipo de punto flotante. Proporciona la constante miembro
value
que es igual a
true
, si
T
es el tipo
float
,
double
,
long
double
, o cualquier tipo de punto flotante extendido (
std::
float16_t
,
std::
float32_t
,
std::
float64_t
,
std::
float128_t
, o
std::
bfloat16_t
)
(since C++23)
, incluyendo cualquier variante calificada cv. De lo contrario,
value
es igual a
false
.
Si el programa añade especializaciones para
std::is_floating_point
o
std::is_floating_point_v
, el comportamiento es indefinido.
Contenidos |
Parámetros de plantilla
| T | - | un tipo a verificar |
Plantilla de variable auxiliar
|
template
<
class
T
>
constexpr bool is_floating_point_v = is_floating_point < T > :: value ; |
(desde C++17) | |
Heredado de std:: integral_constant
Constantes miembro
|
value
[static]
|
true
si
T
es un tipo de punto flotante (posiblemente calificado cv),
false
en caso contrario
(constante miembro pública estática) |
Funciones miembro
|
operator bool
|
convierte el objeto a
bool
, devuelve
value
(función miembro pública) |
|
operator()
(C++14)
|
devuelve
value
(función miembro pública) |
Tipos miembro
| Tipo | Definición |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
Implementación posible
template<class T> struct is_floating_point : std::integral_constant< bool, // Nota: tipos estándar de punto flotante std::is_same<float, typename std::remove_cv<T>::type>::value || std::is_same<double, typename std::remove_cv<T>::type>::value || std::is_same<long double, typename std::remove_cv<T>::type>::value // Nota: tipos extendidos de punto flotante (C++23, si están soportados) || std::is_same<std::float16_t, typename std::remove_cv<T>::type>::value || std::is_same<std::float32_t, typename std::remove_cv<T>::type>::value || std::is_same<std::float64_t, typename std::remove_cv<T>::type>::value || std::is_same<std::float128_t, typename std::remove_cv<T>::type>::value || std::is_same<std::bfloat16_t, typename std::remove_cv<T>::type>::value > {}; |
Ejemplo
#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() {}
Véase también
|
[static]
|
identifica los tipos de punto flotante IEC 559/IEEE 754
(constante de miembro estática pública de
std::numeric_limits<T>
)
|
|
(C++11)
|
verifica si un tipo es un tipo integral
(plantilla de clase) |
|
(C++11)
|
verifica si un tipo es un tipo aritmético
(plantilla de clase) |
|
(C++20)
|
especifica que un tipo es un tipo de punto flotante
(concepto) |