以下cpp表达式中的优先顺序是什么?

时间:2019-12-27 05:58:24

标签: c++ casting operator-precedence

uint64_t author.value = 0;
uint64_t timestamp    = 1577369253;    
uint128_t skey = static_cast<uint128_t>(author.value) << 64 | timestamp;

skey的价值是什么?无论时间戳的值如何,我都将其设置为零。可能是什么原因?

1 个答案:

答案 0 :(得分:0)

这应该有助于您停止担心该问题:

uint128_t skey = (static_cast<uint128_t>(author.value) << 64) | timestamp;

据此,按位移位(7)的优先级高于按位移位(13)的优先级: https://en.cppreference.com/w/cpp/language/operator_precedence