std::is_scalar
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <type_traits>
|
||
| template< class T > struct is_scalar; |
(ya que C + +11) | |
Si
T es un tipo escalar (es decir, tipo aritmético, el tipo de enumeración, puntero, puntero a miembro, o std::nullptr_t, incluidas las variantes cv-calificados), establece en el miembro constante value true iguales. Para cualquier otro tipo, es value false .Original:
If
T is a scalar type (that is, arithmetic type, enumeration type, pointer, pointer to member, or std::nullptr_t, including any cv-qualified variants), provides the member constant value equal true. For any other type, value is false.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Contenido |
Inherited from std::integral_constant
Member constants
| value [estático] |
true si T is a scalar type , false lo contrario Original: true if T is a scalar type , false otherwise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (público miembro constante estática) |
Member functions
| operator bool |
convierte el objeto a bool, devuelve value Original: converts the object to bool, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) |
Member types
| Tipo
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
[editar] Notas
Cada ubicación de la memoria individual en el modelo de C + + de memoria, incluyendo las posiciones de memoria ocultos utilizados por las características del lenguaje (por ejemplo puntero de tabla virtual), es de tipo escalar (o es una secuencia de bits contiguos campos de longitud diferente de cero). La secuenciación de los efectos secundarios en la evaluación de la expresión, la sincronización interthread, y la dependencia de pedido son definidos en términos de objetos escalares individuales .
Original:
Each individual memory location in the C++ memory model, including the hidden memory locations used by language features (e.g virtual table pointer), has scalar type (or is a sequence of adjacent bit-fields of non-zero length). Sequencing of side-effects in expression evaluation, interthread synchronization, and dependency ordering are all defined in terms of individual scalar objects.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[editar] Posible implementación
template< class T > struct is_scalar : std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_pointer<T>::value || std::is_member_pointer<T>::value || std::is_same<std::nullptr_t, typename std::remove_cv<T>::type>::value> {}; |
[editar] Ejemplo
#include <iostream> #include <type_traits> int main() { class cls {}; std::cout << (std::is_scalar<int>::value ? "T is scalar" : "T is not a scalar") << '\n'; std::cout << (std::is_scalar<cls>::value ? "T is scalar" : "T is not a scalar") << '\n'; }
Output:
T is scalar T is not a scalar
[editar] Ver también
| (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. (clase de plantilla) |
| (C++11) |
Comprueba si un tipo es un tipo de enumeración Original: checks if a type is an enumeration type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (clase de plantilla) |
| (C++11) |
Comprueba si un tipo es un tipo de puntero Original: checks if a type is a pointer type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (clase de plantilla) |
| (C++11) |
checks if a type is a pointer to a non-static member function or object (clase de plantilla) |