考虑以下代码:
// E1 << E2 with E1 bool, and E2 an integer
true << static_cast<char>(1);
true << static_cast<short int>(1);
true << static_cast<int>(1);
true << static_cast<unsigned int>(1);
true << static_cast<long long int>(1);
true << static_cast<long long unsigned int>(1);
做操作的时候,E1
提升为与 相同的类型E2
,还是先提升到int
,再提升到std::common_type<E1, E2>::type
?
换句话说,就是:
true << static_cast<char>(9);
已定义或未定义的行为?