Espacios de nombres
Variantes
Acciones

User-defined literals (desde C++11)

De cppreference.com
< cpp‎ | language

 
 
Lenguaje C++
Los temas generales
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Control de flujo
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Sentencias condicionales ejecución
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Instrucciones de iteración
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Ir declaraciones
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funciones
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declaración de la función
lambda declaración de la función
función de plantilla
especificador inline
especificaciones de excepción (obsoleto)
noexcept especificador (C++11)
Excepciones
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Los espacios de nombres
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
Los especificadores
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv especificadores
almacenamiento duración especificadores
constexpr especificador (C++11)
auto especificador (C++11)
alignas especificador (C++11)
Inicialización
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Los literales
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Los literales booleanos
nullptr (C++11)
definido por el usuario (C++11)
Expresiones
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
representaciones alternativas
Utilidades
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
alias de tipo de declaración (C++11)
atributos (C++11)
Lanza
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversiones implícitas
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-cast estilo y funcional
De asignación de memoria
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Clases
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Clase propiedades específicas de la función
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funciones especiales miembro
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Plantillas
Original:
Templates
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
función de plantilla
plantilla de especialización
paquetes de parámetros (C++11)
Varios
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Montaje en línea
 
C + 11 introduce la posibilidad de añadir sufijos personalizados a los literales con el fin de proporcionar diferentes valores .
Original:
C++11 introduced the ability to add custom suffixes to literals in order to provide different values.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Sufijo literal se puede sobrecargar de manera muy similar a los operadores .
Original:
Literal suffixed can be overloaded in a way very similar to operators.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Sintaxis

return decl operator"" name ( unsigned long long n ) { body }
return decl operator"" name ( long double d ) { body }
return decl operator"" name ( char c ) { body }
return decl operator"" name ( const char* str, size_t sz ) { body }
return decl operator"" name ( const char* cstr ) { body }

[editar] Explicación

return -
Valor de retorno
Original:
Return value
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decl -
Declaración secuencia especificador, puede contener palabras clave como constexpr o inline
Original:
Declaration specifier sequence, can contain keywords as constexpr or inline
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
name -
A valido C + + identificador, precedido por un guión bajo. Identificadores sin subrayar están reservados para uso futuro
Original:
A valid C++ identifier, prefixed with an underscore. Identifiers without underscore are reserved for future use
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n -
Valor resultante de una integral literal
Original:
Value resulting from an integral literal
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
d -
Valor resultante de un literal de punto flotante
Original:
Value resulting from a floating-point literal
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
c -
Valor resultante de un carácter literal
Original:
Value resulting from a character literal
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cstr -
Terminada en nulo como analizado por el compilador, para los literales enteros y de punto flotante
Original:
Null-terminated string as parsed by the compiler, for integer and floating point literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
str/sz -
Buffer y el tamaño de una cadena literal
Original:
Buffer and size from a string literal
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
body -
Función del cuerpo
Original:
Function body
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplos

// used as conversion
inline constexpr long double operator"" _deg ( long double deg )
{
    return deg*3.141592/180;
}
...
double x = 90.0_deg; // x = 1.570796


// used with custom type
struct mytype
{
    ...
    mytype ( unsigned long long );
};
mytype operator"" _mytype ( unsigned long long n )
{
    return mytype(n);
}
...
mytype x = 123_mytype;


// used for side-effects
void operator"" _print ( const char* str )
{
    std::cout << str;
}
...
0x123ABC_print;

Output:

0x123ABC