It seems the following is guaranteed to pass (asked already here):
#include <type_traits>
static_assert(!std::is_same_v<char, signed char>);
static_assert(!std::is_same_v<char, unsigned char>);
To quote cppreference
[
char] has the same representation and alignment as eithersigned charorunsigned char, but is always a distinct type
Is it also guaranteed that int8_t and uint8_t are defined in terms of the explicitly signed types not defined in terms of char, and therefore also form a set of 3 distinct types with char?
#include <cstdint>
#include <type_traits>
static_assert(!std::is_same_v<char, int8_t>);
static_assert(!std::is_same_v<char, uint8_t>);
On your first point, yes, char, signed char, and unsigned char must always be distinct types.
On the second point, int8_t and uint8_t might be or might not be the same type as a char (or its signed or unsigned variants); i.e. there is no guarantee for or against.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With