【发布时间】:2016-01-11 15:52:45
【问题描述】:
我正在尝试了解积分提升如何与算术移位运算符一起使用。特别想知道a, b, c, d, e, f, g, h的哪些值是完全按照C++14标准定义的,哪些可以依赖于平台/硬件/编译器(假设sizeof(int) == 4)。
int a = true << 3;
int b = true >> 3;
int c = true << 3U;
int d = true >> 3U;
int e = true << 31;
int f = true >> 31;
int g = true << 31U;
int h = true >> 31U;
【问题讨论】:
-
@ThomasMatthews 您链接的问题根本没有谈到位移。
标签: c++ standards c++14 bit-shift integer-promotion