gpt4 book ai didi

What is the correlation of this accepted answer to the context of reference and constexpr?(这一被接受的答案与参考和常识的上下文有什么关联?)

转载 作者:bug小助手 更新时间:2023-10-25 22:17:36 24 4
gpt4 key购买 nike



My reference is to the following post:

我的参考是以下帖子:


Why is a constexpr function on a reference not constexpr?

为什么引用上的常量函数不是常量函数?


I read through the other answers and it made sense except for the answer accepted by the creator of the post:

我通读了其他答案,除了帖子创建者接受的答案外,其他答案都很有意义:



Unfortunately, the standard states that in a class member access expression The postfix expression before the dot or arrow is evaluated;63 [expr.ref]/1. A postfix expression is a in a.b. The note is really interesting because this is precisely the case here:




  1. If the class member access expression is evaluated, the subexpression evaluation happens even if the result is unnecessary to determine the value of the entire postfix expression, for example if the id-expression denotes a static member.



So data is evaluated even if it would not be necessary and the rule fore constant expression applies on it too.



What is the correlation to the context of reference and constexpr? Can someone explain?

与引用和常量的上下文有什么关联?有谁能解释一下吗?


更多回答
优秀答案推荐
更多回答

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