std::is_floating_point
De cppreference.com
<tbody>
</tbody>
| Definido en el archivo de 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, o long double, incluyendo las variantes calificadas-cv. De lo contrario, value es igual a false.
El comportamiento de un programa que añade especializaciones para is_floating_point o is_floating_point_v (desde C++17) no está definido.
Parámetros de plantilla
| T | - | Un tipo a comprobar. |
Plantilla de variable auxiliar
<tbody> </tbody> template< class T > inline constexpr bool is_floating_point_v = is_floating_point<T>::value; |
(desde C++17) | |
Heredado de std::integral_constant
Constantes miembro
value [estático] |
true si T es un tipo de punto flotante (posiblemente calificado-cv), de lo contrario false. (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>
|
Posible implementación
template< class T >
struct is_floating_point
: std::integral_constant<
bool,
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
> {};
|
Ejemplo
Ejecuta este código
#include <iostream>
#include <type_traits>
class A {};
int main()
{
std::cout << std::boolalpha;
std::cout << std::is_floating_point<A>::value << '\n';
std::cout << std::is_floating_point<float>::value << '\n';
std::cout << std::is_floating_point<float&>::value << '\n';
std::cout << std::is_floating_point<int>::value << '\n';
}
Salida:
false
true
false
false
Véase también
[estático] |
identifica los IEC 559/IEEE 754 tipos de punto flotante Original: identifies the IEC 559/IEEE 754 floating-point types The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática de std::numeric_limits)
|
(C++11) |
Comprueba si un tipo T es entero. (plantilla de clase) |
(C++11) |
Comprueba si un tipo es de tipo aritmético Original: checks if a type is arithmetic type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (plantilla de clase) |