微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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 ]

原文地址:https://www.jb51.cc/c/113394.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐