C ++ 11标准中的“顶级cv限定符”的定义在哪里? [英] Where is the definition of `top-level cv-qualifiers` in the C++11 Standard?

查看:780
本文介绍了C ++ 11标准中的“顶级cv限定符”的定义在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++ 11标准草案:N3337 我发现了几个引用顶级cv限定符,但没有定义。

In the draft C++11 standard: N3337 I found several references to top-level cv-qualifiers, but no definition.

推荐答案

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

This question gave me the chance of learning something new so I'm sharing it here, I didn't write the passage below!

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

In C++, a cv-qualifier that applies to the first level of a type is called a toplevel cv-qualifier. For example, in:

T *const p;

顶级cv-qualifier是 const ,and in:

the top-level cv-qualifier is const, and in:

T const *volatile q;

顶级cv限定符 volatile 。另一方面:

the top-level cv-qualifier is volatile. On the other hand:

T const volatile *q;

没有顶级cv限定符。在这种情况下,cv限定符 const volatile 出现在第二级。

has no top-level cv-qualifiers. In this case, the cv-qualifiers const and volatile appear at the second level.

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

The signature of a function includes all cv-qualifiers appearing in that function’s parameter types, except for those qualifiers appearing at the top-level of a parameter type.

例如,在:

int f(char const *p);

const 限定符不在顶部。在参数声明的水平,所以它是函数签名的一部分

the const qualifier is not at the top level in the parameter declaration, so it is part of the function’s signature.

在另一方面,在:

int f(char *const p);

const 限定符位于顶层,所以它不是函数的签名的一部分。
此函数具有相同的签名:

the const qualifier is at the top level, so it is not part of the function’s signature. This function has the same signature as:

int f(char *p);

资料来源:顶级CV-在功能参数预选赛

我找不到标准的定义,但无论是什么我上面张贴在N3337中明确指出§8.3.5-5

I couldn't find a definition in the standard either but what I posted above is explicitly stated in N3337 §8.3.5-5

生产参数类型列表后,任何顶级
cv修饰符修改一个参数类型正在形成的时候删除
函数类型。

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






编辑:
写上面的帖子在标准的定义无法找到,但现在出现了由沙菲克指出的1


At the time of writing the above post a definition in the standard could not be found but now there's one as pointed out by Shafik:

n4296摘录:

在本国际标准中,符号CV(或CV1, CV2等)中的类型的描述中使用,
,表示一个任意集合
cv修饰符,即,{常量}之一,{挥发性},{常量,挥发性},或
空集。对于类型cv T,
类型的顶级cv限定符是由cv表示的那些。 [示例:对应于
类型的类型const int&没有顶级cv限定符。对应于typeid volatile int * const的类型
具有顶层
cv-qualifier const。对于类类型C,对应于
type-id void(C :: * volatile)(int)const的类型具有顶级cv限定符
volatile。 - end example]

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 ]

这篇关于C ++ 11标准中的“顶级cv限定符”的定义在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆