std:: is_fundamental
| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++14)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definido en el encabezado
<type_traits>
|
||
|
template
<
class
T
>
struct is_fundamental ; |
(desde C++11) | |
std::is_fundamental
es un
UnaryTypeTrait
.
Si
T
es un
tipo fundamental
(es decir, tipo aritmético,
void
, o
nullptr_t
), proporciona la constante miembro
value
igual a
true
. Para cualquier otro tipo,
value
es
false
.
Si el programa añade especializaciones para
std::is_fundamental
o
std::is_fundamental_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_fundamental_v = is_fundamental < T > :: value ; |
(desde C++17) | |
Heredado de std:: integral_constant
Constantes miembro
|
value
[static]
|
true
si
T
es un tipo fundamental,
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_fundamental : std::integral_constant< bool, std::is_arithmetic<T>::value || std::is_void<T>::value || std::is_same<std::nullptr_t, typename std::remove_cv<T>::type>::value // también puedes usar 'std::is_null_pointer<T>::value' en su lugar en C++14 > {}; |
Ejemplo
#include <type_traits> static_assert(std::is_fundamental_v<int> == true); static_assert(std::is_fundamental_v<int&> == false); static_assert(std::is_fundamental_v<int*> == false); static_assert(std::is_fundamental_v<void> == true); static_assert(std::is_fundamental_v<void*> == false); static_assert(std::is_fundamental_v<float> == true); static_assert(std::is_fundamental_v<float&> == false); static_assert(std::is_fundamental_v<float*> == false); static_assert(std::is_fundamental_v<std::nullptr_t> == true); static_assert(std::is_fundamental_v<std::is_fundamental<int>> == false); class A {}; static_assert(std::is_fundamental_v<A> == false); static_assert(std::is_fundamental_v<std::is_fundamental<A>::value_type>); int main() {}
Véase también
|
(C++11)
|
verifica si un tipo es un tipo compuesto
(class template) |
|
(C++11)
|
verifica si un tipo es un tipo aritmético
(class template) |
|
(C++11)
|
verifica si un tipo es
void
(class template) |
|
(C++11)
(
DR*
)
|
verifica si un tipo es
std::nullptr_t
(class template) |