Namespaces
Variants

std:: make_unsigned

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
(C++11) (C++11) (C++11)
make_unsigned
(C++11)
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
Definido en el encabezado <type_traits>
template < class T >
struct make_unsigned ;
(desde C++11)

Si T es un tipo integral (excepto bool ) o de enumeración, proporciona el typedef miembro type que es el tipo entero sin signo correspondiente a T , con los mismos calificadores cv.

Si T es signed o unsigned char , short , int , long , long long ; se proporciona el tipo unsigned correspondiente de esta lista para T .

Si T es un tipo de enumeración o char , wchar_t , char8_t (desde C++20) , char16_t , char32_t ; se proporciona el tipo entero sin signo con el menor rango que tenga el mismo sizeof que T .

De lo contrario, el comportamiento es indefinido.

(until C++20)

De lo contrario, el programa está mal formado.

(since C++20)

Si el programa añade especializaciones para std::make_unsigned , el comportamiento no está definido.

Contenidos

Tipos de miembros

Nombre Definición
type el tipo entero sin signo correspondiente a T

Tipos auxiliares

template < class T >
using make_unsigned_t = typename make_unsigned < T > :: type ;
(desde C++14)

Ejemplo

#include <type_traits>
int main()
{
    using uchar_type = std::make_unsigned_t<char>;
    using uint_type  = std::make_unsigned_t<int>;
    using ulong_type = std::make_unsigned_t<volatile long>;
    static_assert(
        std::is_same_v<uchar_type, unsigned char> and
        std::is_same_v<uint_type, unsigned int> and
        std::is_same_v<ulong_type, volatile unsigned long>
    );
}

Véase también

(C++11)
verifica si un tipo es un tipo aritmético con signo
(class template)
verifica si un tipo es un tipo aritmético sin signo
(class template)
obtiene el tipo con signo correspondiente para el tipo integral dado
(class template)