Espacios de nombres
Variantes
Acciones

std::numeric_limits::is_modulo

De cppreference.com
 
 
Biblioteca de servicios
 
Apoyo de tipos
Propiedades de tipos
(C++11)
(C++11)
(C++14)
(C++11)
(C++11)(hasta C++20)
(C++11)(en desuso en C++20)
(C++11)
Constantes de rasgos de tipos
Metafunciones
(C++17)
Contexto de evaluación constante
Operaciones soportadas
Relaciones y consultas de propiedades
Modificaciones de tipos
Transformaciones de tipos
(C++11)
(C++11)
(C++17)
(C++11)(hasta C++20)(C++17)
 
 
staticconstbool is_modulo
(hasta C++11)
staticconstexprbool is_modulo
(desde C++11)

The value of std::numeric_limits<T>::is_modulo is true for all arithmetic types T that handle overflows with modulo arithmetic, that is, if the result of addition, subtraction, multiplication, or division of this type would fall outside the range [min(), max()], the value returned by such operation differs from the expected value by a multiple of max()-min()+1.

[editar]Especializaciones estándar

T
valor de std::numeric_limits<T>::is_modulo
Original:
value of std::numeric_limits<T>::is_modulo
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
/* non-specialized */ false
boolfalse
chartrue
signedchartrue
unsignedchartrue
wchar_ttrue
char16_ttrue
char32_ttrue
shorttrue
unsignedshorttrue
inttrue
unsignedinttrue
longtrue
unsignedlongtrue
longlongtrue
unsignedlonglongtrue
floatfalse
doublefalse
longdoublefalse

[editar]Ejemplo

Demonstrates the behavior of modulo types

#include <iostream>#include <type_traits>#include <limits>   template<class T>typenamestd::enable_if<std::numeric_limits<T>::is_modulo>::type check_overflow(){std::cout<<"\nmax value is "<<std::numeric_limits<T>::max()<<'\n'<<"min value is "<<std::numeric_limits<T>::min()<<'\n'<<"max value + 1 is "<<std::numeric_limits<T>::max()+1<<'\n';}   int main(){ check_overflow<int>(); check_overflow<unsignedlong>();// check_overflow<float>(); // compile-time error, not a modulo type}

Salida:

max value is 2147483647 min value is -2147483648 max value + 1 is -2147483648   max value is 18446744073709551615 min value is 0 max value + 1 is 0

[editar]Ver también

[estático]
identifica los tipos enteros
Original:
identifies integer 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)[editar]
[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)[editar]
[estático]
identifica los tipos exactos
Original:
identifies exact 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)[editar]
close