gpt4 book ai didi

c++ - 为什么bool转换明确提到prvalue

转载 作者:行者123 更新时间:2023-11-30 05:17:07 25 4
gpt4 key购买 nike

在 4.14 http://eel.is/c++draft/conv.bool#1

它说:

A prvalue of arithmetic, unscoped enumeration, pointer, or pointer to member type can be converted to a prvalue of type bool.

为什么要特别强调右值?

算术类型的左值也可以转换为bool。

最佳答案

标准不希望 bool 值转换影响左值,因此不允许。

您当然可以将算术类型的左值转换为 bool 类型,但这不是通过(仅) bool 转换来完成的。将算术左值转换为 bool 是一个标准的转换序列,由 lvalue-to-rvalue 转换boolean 转换组成。

关于c++ - 为什么bool转换明确提到prvalue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42266003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com