gpt4 book ai didi

C++ const 引用声明

转载 作者:太空狗 更新时间:2023-10-29 23:09:48 25 4
gpt4 key购买 nike

下面的声明如何先用const表达(不用typedef)?

double* const (&data)[6]
// ?? const double* (&data)[6] // incorrect, elements, not reference, are const

谢谢

最佳答案

你做不到。

根据 C++ 标准 8.3.2/1:

Cv-qualified references are ill-formed except when the cv-qualifiers are introduced through the use of a typedef (7.1.3) or of a template type argument (14.3), in which case the cv-qualifiers are ignored.

关于C++ const 引用声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3553386/

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