As from subject. I saw this terminology in a question I recently asked, and apparently it's a well established term, but I am not able to find anything on stackoverflow.
问题:
回答1:
There are fundamental types and compound types. Fundamental types are the arithmetic types, void
, and std::nullptr_t
. Compound types are arrays, functions, pointers, references, classes, unions, enumerations, and pointers to non-static members.
A cv-unqualified type is any of those types.
For any cv-unqualified type, there are three corresponding cv-qualified types:
- const-qualified - with the
const
cv-qualifier - volatile-qualified - with the
volatile
cv-qualifier - const-volatile-qualified - with both the
const
andvolatile
cv-qualifiers
Note, however, that cv-qualifiers applied to an array type actually apply to its elements.
The cv-qualified and cv-unqualified types are distinct. That is int
is a distinct type from const int
.
回答2:
A type is "cv-unqualified" if it doesn't have any cv-qualifiers. A cv-qualifer is either const
or volatile
.
回答3:
cv-unqualified type is a type that hasn't been specified by any of cv-qualifiers. These define two basic properties of a type: constness and volatility. See C++03 3.9.3 CV-qualifiers §1:
A type mentioned in 3.9.1 and 3.9.2 is a cv-unqualified type. Each type which is a cv-unqualified complete or incomplete object type or is void (3.9) has three corresponding cv-qualified versions of its type:
- a const-qualified version,
- a volatile-qualified version, and
- a const-volatile-qualified version.
The term object type (1.8) includes the cv-qualifiers specified when the object is created.
The presence of a
const
specifier in a decl-specifier-seq declares an object of const-qualified object type; such object is called aconst object
.The presence of a
volatile
specifier in a decl-specifier-seq declares an object of volatilequalified object type; such object is called avolatile object
.The presence of both cv-qualifiers in a declspecifier-seq declares an object of const-volatile-qualified object type; such object is called a
const volatile object
.
回答4:
cv stands for const
and volatile
(and more rarely mutable
), two attributes qualifying a type. You can manipulate them with std::remove_const
and the like in C++11.
The excellent cppreference site gives you more info.
To answer your question, a cv-unqualified type either doesn't have or is stripped from its cv-qualifiers. For instance int
is the cv-unqualified part of const volatile int
.
std::remove_cv
is the cv-unqualified partof T
.
回答5:
Generally it means "the same type, but with any cv-qualifier removed", so (for example) the cv-unqualified version of void volatile * const x
would be void *x
.
Note that here, however, I'm removing the cv-qualifiers from both the pointer itself and what it points at. In most cases, cv-unqualified
will refer only to one object at a time, so a cv-unqualified version of the pointer itself would still be void volatile *x
, whereas a cv-unqualfied version of what it points at would be void *const x
.