加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C 11标准中“顶级cv-qualifiers”的定义在哪里?

发布时间:2020-12-16 05:55:02 所属栏目:百科 来源:网络整理
导读:在 the draft C++11 standard: N3337年,我发现几个参考顶级cv限定词,但没有定义. 解决方法 这个问题让我有机会学习新的东西,所以我在这里分享,我没有写下面的段落! 在C中,应用于类型的第一级的cv-qualifier称为toplevel cv-qualifier.例如,在: T *const p;
在 the draft C++11 standard: N3337年,我发现几个参考顶级cv限定词,但没有定义.

解决方法

这个问题让我有机会学习新的东西,所以我在这里分享,我没有写下面的段落!

在C中,应用于类型的第一级的cv-qualifier称为toplevel cv-qualifier.例如,在:

T *const p;

顶级cv-qualifier是const,并且在:

T const *volatile q;

顶级cv-qualifier是不稳定的.另一方面:

T const volatile *q;

没有顶级cv限定词.在这种情况下,cv-qualifiers const和volatile出现在第二级.

函数的签名包括出现在该函数参数类型中的所有cv限定符,除了出现在参数类型顶层的限定符除外.

例如,在:

int f(char const *p);

const限定符不在参数声明的顶层,因此它是函数签名的一部分.

另一方面,在:

int f(char *const p);

const限定符处于顶级,因此它不是函数签名的一部分.
此功能具有与以下相同的签名:

int f(char *p);

资料来源:Top-Level cv-Qualifiers in Function Parameters

我在标准中找不到定义,但是我在上面发布的内容在N3337§8.3.5-5中有明确规定

After producing the list of parameter types,any top-level
cv-qualifiers modifying a parameter type are deleted when forming the
function type.

编辑:
在撰写上述文章时,标准中的定义无法找到,但现在有一个as pointed out by Shafik:

n4296摘录:

In this International Standard,the notation cv (or cv1,cv2,etc.),used in the description of types,represents an arbitrary set of cv-qualifiers,i.e.,one of {const},{volatile},{const,volatile},or the empty set. For a type cv T,the top-level cv-qualifiers of that type are those denoted by cv. [Example: The type corresponding to the type-id const int& has no top-level cv-qualifiers. The type corresponding to the typeid volatile int * const has the top-level cv-qualifier const. For a class type C,the type corresponding to the type-id void (C::* volatile)(int) const has the top-level cv-qualifier volatile. — end example ]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读