<xstd/ints/type_traits/make_signed.hpp>¶
xstd::make_signed, xstd::make_signed_t¶
template<class T>
struct make_signed;
template<class T>
using make_signed_t = typename make_signed<T>::type;
The signed counterpart of an integral, enumeration or integer-class type.
Member types¶
| Type | Definition |
|---|---|
type |
the signed counterpart of T, where it has one, as below |
- For a cv-unqualified integral or enumeration type other than
bool, the membertypeisstd::make_signed_t<T>. - So
make_signed_t<char>issigned char, a third type besidechar. - For a cv-unqualified type that models
integer_class, is notstd::integraland is signed,typeisT. - For a cv-qualified
Twhose unqualified type has a membertype,typeis that with the same qualifiers. A cv-qualified type takes no other path, so it has a membertypeexactly when its unqualified type does. - Otherwise there is no member
type, somake_signed_t<T>is a substitution failure:boolanddoublehave none. - An unsigned integer-class type that no specialization pairs has none either.
Remarks¶
A program may specialize it for the unsigned half of an integer-class pair, as the ext headers do.
Notes¶
Every unsigned exact-width type maps to a type modelling signed_integer.
See also¶
| Entity | Relation |
|---|---|
make_unsigned |
the other direction |
integer |
asks that the two be mutually inverse |
boost::int128, absl::int128 |
the ext headers' specializations |
std::make_signed |
the standard trait it extends |
xstd::make_signed<unsigned _BitInt(N)>, xstd::make_unsigned<signed _BitInt(N)>¶
// (1)
template<> struct make_signed<unsigned _BitInt(1)>;
// (2)
template<size_t N> struct make_signed<unsigned _BitInt(N)>;
// (3)
template<> struct make_unsigned<unsigned _BitInt(1)>;
// (4)
template<size_t N> struct make_unsigned<signed _BitInt(N)>;
The bit-precise specializations. Each is declared, where the compiler defines __BITINT_MAXWIDTH__, in the header that
declares its primary template.
make_signed<unsigned _BitInt(1)>is an explicit specialization with no membertype: Clang does not yet implement WG14 N3747'ssigned _BitInt(1). Somake_signed_tofunsigned _BitInt(1), cv-qualified or not, is a substitution failure, andintegerandunsigned_integerarefalsefor it rather than ill-formed.- The member
typeis the same width with the other signedness. make_unsigned<unsigned _BitInt(1)>::typeisunsigned _BitInt(1), which libc++'sstd::make_unsignedrefuses, and through the cv-qualified specializations the qualifiers carry over.- The member
typeis the same width with the other signedness.
Remarks¶
A translation unit that can name either trait has them, whatever else it includes.
Notes¶
They are more specialized than the partial specialization that forwards to the standard library, so they apply on
libc++, which makes _BitInt integral, as well as elsewhere.
See also¶
| Entity | Relation |
|---|---|
bit_int, bit_uint |
the aliases that name the bit-precise types |
numeric_limits<signed _BitInt(N)> |
the limits of the same types |