C++ Quiz66 of 173
Difficulty:
⬅️ Prev: 151Quiz ID: 152Next: 153 ➡️

According to the C++23 standard, what is the output of this program?

#include <iostream>
#include <type_traits>

int main() {
    if(std::is_signed<char>::value){
        std::cout << std::is_same<char, signed char>::value;
    }else{
        std::cout << std::is_same<char, unsigned char>::value;
    }
}
Hint

The answer is different for the case of int and signed int.

Reveal answer

0

Explanation

Plain char, signed char, and unsigned char are three distinct types.

§[basic.fundamental]¶7 in the standard:

Type char is a distinct type that has an implementation-defined choice of “signed char” or “unsigned char” as its underlying type.

⬅️ Prev: 151Quiz ID: 152Next: 153 ➡️